[NTG-context] fancy chapter setup

Henning Hraban Ramm texml at fiee.net
Sat Jan 11 16:04:18 CET 2020


Hi all,
I’m trying to setup a book layout where each chapter begins with a quote and an image on the left page, followed by title and text start on the right page.

While the quote & image thing works, I can’t get the title on the right page, ConTeXt always puts it right of the image, even if that’s as wide as the text width. \page[right] doesn’t do anything.
Where’s my mistake?

There are also chapters without that intro, therefore I use \doifnot{\structureuservariable{subtitle}}, but those should also start on a right page. I could also use a different section name. But I don’t think that’s the problem.

(The page number should appear on the right page; it wouldn’t hurt on the left page, but the chapter title should only appear on following pages.)

Best, Hraban

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\define[2]\FancyChapter{%
\doifnot{\structureuservariable{subtitle}}{}{%
\startstandardmakeup
  \framed[
    width=\textwidth,height=fit,
    offset=overlay,
    align=flushleft,
  ]{%
    \definedfont[SerifItalic at 16pt]
    \structureuservariable{subtitle}%
  }
  \framed[width=\textwidth]{%
    \externalfigure[dummy][width=\textwidth]%
  }
  %\hfill\vfill\strut % doesn’t help
\stopstandardmakeup
}
\page[right]
%
\framed[
  width=\textwidth,
  offset=overlay,
  align=flushleft,
]{%
  \definedfont[Sans at 32pt]%#2
  \structurevariable{title}%
}%
}

\setupheadertexts[][pagenumber][pagenumber][chapter]
\setuphead[chapter][
  page=left,
  number=no,
  header=high,
  command=\FancyChapter,
]

\starttext

\startchapter[title={My Normal Text}]

\input knuth

\stopchapter

\startchapter[title={My Fancy Story}]
[subtitle={\quotation{I thought that was real.}}]

\input tufte

\stopchapter

\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


More information about the ntg-context mailing list