[NTG-context] fancy chapter setup

Rik Kabel ConTeXt at rik.users.panix.com
Sat Jan 11 19:49:47 CET 2020


On 1/11/2020 10:04, Henning Hraban Ramm wrote:
> 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
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

For what it is worth, here is how I address this. This lets me place 
epigraphs on the facing verso of a chapter, or under the section title, 
and set lettrines and first line treatment for chapters. I set page 
numbers in a separate overlay to better control the positioning. Perhaps 
a bit overthought, but it works for me ...

    \setupheadertexts [][{\it\getmarking[section]}]
                       [{\it\getmarking[chapter]}][]

    \startsetups section:epigraph
       \doifelsebuffer{SectionEpigraph}
         {\getbuffer  [SectionEpigraph]
          \resetbuffer[SectionEpigraph]}
         {\donothing}
    \stopsetups

    \startsetups chapter:epigraph
       \setupheadertexts [][][][]
       \doifelsebuffer{ChapterEpigraph}
         {\doifoddpageelse
           {\page[left]}
           {\donothing}
          \centerbox{\getbuffer[ChapterEpigraph]}
          \resetbuffer[ChapterEpigraph]
         }
         {\donothing}
       \page[right]
       \setupheadertexts [][{\it\getmarking[section]}]
                         [{\it\getmarking[chapter]}][]
    \stopsetups

    \startsectionblockenvironment[bodypart]
    \setuphead  [chapter][
                           style=\tfc\HeadFont,
                           page=yes,
                           separator=,
                           numbercolor=darkgray,
                           alternative=inmargin,
    before=\directsetup{chapter:epigraph},
    after={\resetshownsynonyms[dictionary]
    \setupsynonyms[dictionary][alternative=first]
    \doifsomething{\structureuservariable{setFirst}}
    {\setfirstline[\structureuservariable{setFirst}]}
    \doif{\structureuservariable{Lettrine}}
                                  {yes}{\setinitial}},
                          ]
    \setuphead  [section][
                           style=\tfb\HeadFont,
    insidesection=\setups{section:epigraph},
                           before={\blank[big]},
                           sectionseparatorset=reddot,
                           numbercolor=darkgray,
                           alternative=inmargin,
                          ]
    \setuphead  [subsection]
                          [
                           style=\tfa\HeadFont,
                           number=no,
                           distance=0pt,
    insidesection=\setups{section:epigraph},
                           before={\blank[big]},
                           alternative=normal,
                           after={\blank[halfline]},
                           numbercolor=,
                           sectionseparatorset=,
                          ]
    \stopsectionblockenvironment

    \definefirstline [5W][alternative=word, n=5,style=smallcaps]% and so
    on as you like
    \definefirstline [1L][alternative=line,     style=smallcaps]

    ...

    \starttext

    ...

    \startbuffer[ChapterEpigraph]

    \startEpigraph% brings in its own formatting

    The stuff of the epigraph

    \stopEpigraph

    \stopbuffer

    \startchapter[reference={cha:blah},
                   list={blah},     % toc
                   marking={blah},  % page heading
                   bookmark={blah}, % pdf bookmark
                   title={blah}]    % chapter head
                  [Lettrine=yes,setFirst=5W]

    ...

    \stopchapter

    \startchapter[reference={cha:more},
                   title={more stuff}]
                   [lettrine=yes]

    ...

    \stopchapter


-- 
Rik Kabel



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20200111/f5f02b6a/attachment-0001.htm>


More information about the ntg-context mailing list