ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* fancy chapter setup
@ 2020-01-11 15:04 Henning Hraban Ramm
  2020-01-11 18:49 ` Rik Kabel
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2020-01-11 15:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fancy chapter setup
  2020-01-11 15:04 fancy chapter setup Henning Hraban Ramm
@ 2020-01-11 18:49 ` Rik Kabel
  2020-01-11 19:24   ` Henning Hraban Ramm
  2020-01-12 13:40   ` Henning Hraban Ramm
  0 siblings, 2 replies; 7+ messages in thread
From: Rik Kabel @ 2020-01-11 18:49 UTC (permalink / raw)
  To: ntg-context, Henning Hraban Ramm


[-- Attachment #1.1: Type: text/plain, Size: 6106 bytes --]

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




[-- Attachment #1.2: Type: text/html, Size: 9011 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fancy chapter setup
  2020-01-11 18:49 ` Rik Kabel
@ 2020-01-11 19:24   ` Henning Hraban Ramm
  2020-01-12 13:40   ` Henning Hraban Ramm
  1 sibling, 0 replies; 7+ messages in thread
From: Henning Hraban Ramm @ 2020-01-11 19:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 2020-01-11 um 19:49 schrieb Rik Kabel <context@rik.users.panix.com>:
> 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 …

Thank you, looks interesting. I’ll try to adapt that before=\directsetup approach to my project.

Best, Hraban

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fancy chapter setup
  2020-01-11 18:49 ` Rik Kabel
  2020-01-11 19:24   ` Henning Hraban Ramm
@ 2020-01-12 13:40   ` Henning Hraban Ramm
  2020-01-12 15:07     ` Henning Hraban Ramm
  1 sibling, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2020-01-12 13:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 2020-01-11 um 19:49 schrieb Rik Kabel <context@rik.users.panix.com>:
> 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 ...

Here’s my approach. Right/left stuff and placement is good, but I get always the extra contents of the previous chapter, i.e. “Another Fancy Story” gets the subtitle/quote from “My Fancy Story”, while “My Fancy Story” doesn’t show anything.
Is that why you used buffers?
Since I only need two user settings (image name and quote), only one in the example, I’d like to avoid a buffer for every chapter.

\startsetups FancyChapter
  \setupheadertexts[][][][]
  \doifnot{\structureuservariable{subtitle}}{}{
    \doifoddpageelse
      {\page[left]}
      {\donothing}
    {\definedfont[SerifItalic at 16pt]\structureuservariable{subtitle}\par}
    \externalfigure[dummy][width=\textwidth]
  }
  \page[right]
\stopsetups

\setupheadertexts[][pagenumber][pagenumber][chapter]
\setuphead[chapter][
  page=yes,
  before={\directsetup{FancyChapter}},
]

\setuppagenumbering[alternative=doublesided]

\starttext

\completecontent

\startchapter[title={My Normal Text}]
\input knuth
\stopchapter

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

\startchapter[title={Another Fancy Story}]
[subtitle={\quotation{Never mind the bollocks.}}]
\input zapf
\stopchapter

\startchapter[title={Another Normal Text}]
\input knuth
\stopchapter

\stoptext


Best, Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fancy chapter setup
  2020-01-12 13:40   ` Henning Hraban Ramm
@ 2020-01-12 15:07     ` Henning Hraban Ramm
  2020-01-13 18:21       ` Henning Hraban Ramm
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2020-01-12 15:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Since the structureuservariables of a section aren’t defined in that section’s "before", I would need a macro or buffer to define the contents of that epigraph page, like this:


\def\PreImg{Dummy}

\startsetups FancyChapter
  \setupheadertexts[][][][]
  \doifelsebuffer{Quote}{
    \doifoddpageelse
      {\page[left]}
      {\donothing}
    {\definedfont[SerifItalic at 16pt]\quotation{\getbuffer[Quote]}\par}
    \externalfigure[\PreImg][width=\textwidth]
    \resetbuffer[Quote]
  }{}
  \page[right]
\stopsetups

\setupheadertexts[][pagenumber][pagenumber][chapter]
\setuphead[chapter][
  page=yes,
  before={\directsetup{FancyChapter}},
]

\setuppagenumbering[alternative=doublesided]

\starttext

\completecontent

\startchapter[title={My Normal Text}]
\input knuth
\stopchapter

\def\PreImg{Real}
\startbuffer[Quote]
I thought that was real.
\stopbuffer

\startchapter[title={My Fancy Story}]
\input tufte
\stopchapter

\def\PreImg{Love}
\startbuffer[Quote]
All you need is love.
\stopbuffer

\startchapter[title={Another Fancy Story}]
\input zapf
\stopchapter

\startchapter[title={Another Normal Text}]
\input knuth
\stopchapter

\stoptext


That’s possible, but ugly. I would really like to set those quotes and image names in the chapter command.

Best, Hraban


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fancy chapter setup
  2020-01-12 15:07     ` Henning Hraban Ramm
@ 2020-01-13 18:21       ` Henning Hraban Ramm
  2020-01-13 21:48         ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2020-01-13 18:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 2020-01-12 um 16:07 schrieb Henning Hraban Ramm <texml@fiee.net>:
> 
> Since the structureuservariables of a section aren’t defined in that section’s "before", I would need a macro or buffer to define the contents of that epigraph page, like this:
> 
> That’s possible, but ugly. I would really like to set those quotes and image names in the chapter command.

Finally I used the after parameter and needed to define different section commands for chapters with and without epigraph (i.e. starting on a left or right page). When I had that distinction and the \page command in my setup, the header text changed too early.

Best, Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: fancy chapter setup
  2020-01-13 18:21       ` Henning Hraban Ramm
@ 2020-01-13 21:48         ` Wolfgang Schuster
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2020-01-13 21:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Henning Hraban Ramm

Henning Hraban Ramm schrieb am 13.01.2020 um 19:21:
>> Am 2020-01-12 um 16:07 schrieb Henning Hraban Ramm <texml@fiee.net>:
>>
>> Since the structureuservariables of a section aren’t defined in that section’s "before", I would need a macro or buffer to define the contents of that epigraph page, like this:
>>
>> That’s possible, but ugly. I would really like to set those quotes and image names in the chapter command.
> Finally I used the after parameter and needed to define different section commands for chapters with and without epigraph (i.e. starting on a left or right page). When I had that distinction and the \page command in my setup, the header text changed too early.

\definedataset[chapter]

\startsetups[chapter:leftpage]

     \page[left]

     \doglobal\increment\ChapterData

     \doifsomething{\datasetvariable{chapter}{\ChapterData}{subtitle}}
         {
             \starttabulate
             \NC Title    \EQ 
\datasetvariable{chapter}{\ChapterData}{title} \NC\NR
             \NC Subtitle \EQ 
\datasetvariable{chapter}{\ChapterData}{subtitle} \NC\NR
             \stoptabulate
         }

     \page[right]

\stopsetups

\startsetups[chapter:savedata]

     \setdataset
         [chapter]
         [\ChapterData]
         [   title=\structurevariable{title},
          subtitle=\structureuservariable{subtitle}]

\stopsetups

\setuphead
   [chapter]
   [page=,
    beforesection=\directsetup{chapter:leftpage},
    insidesection=\directsetup{chapter:savedata}]

\setuppagenumbering[alternative=doublesided]

\starttext

\startchapter[title={My Normal Text}]
\input knuth
\stopchapter

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

\startchapter[title={Another Fancy Story}][subtitle={Never mind the 
bollocks.}]
\input zapf
\stopchapter

\startchapter[title={Another Normal Text}]
\input knuth
\stopchapter

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-13 21:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-11 15:04 fancy chapter setup Henning Hraban Ramm
2020-01-11 18:49 ` Rik Kabel
2020-01-11 19:24   ` Henning Hraban Ramm
2020-01-12 13:40   ` Henning Hraban Ramm
2020-01-12 15:07     ` Henning Hraban Ramm
2020-01-13 18:21       ` Henning Hraban Ramm
2020-01-13 21:48         ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).