7

When designing some documents, I hope I can set a global layout and another layout for the first page of all chapters. I have defined two layouts as follows:

\setuppagenumbering
[alternative=doublesided,
 location=]

% global layout for the whole document
\setuplayout
[backspace=2.5cm,
 width=16.5cm,
 topspace=2cm,
 height=25.2cm,
 header=\lineheight,
 headerdistance=\lineheight,
 footer=0cm]

% layout for the first page of Chapters
\definelayout
[firstpage]
[height=26.2cm,
 footerdistance=\lineheight,
 footer=\lineheight]

\starttext
\chapter{First Chapter}
I am in the first page.
\page
I am in the second page.
\stoptext

Now the question is that how I can apply this firstpage layout to the first page of the chapter First Chapter and switch back to the global layout after the first page of this chapter?

5

You can use \setuphead and the before key to change the layout when a new chapter starts. The setting is reset to the default value when a page is shipped out.

\setuppapersize [A6]  %% only for screenshot

\definelayout
  [firstpage]
  [height=8cm]

\setuphead
  [chapter]
  [before=\ChapterPageHook]

\starttexdefinition ChapterPageHook
  \appendtoks
    \setuplayout[reset]
  \to\everyshipout
  \setuplayout[firstpage]
\stoptexdefinition

\showframe
\starttext
  \startchapter [title=First Chapter]
  I am in the first page. \page
  I am in the second page.
  \stopchapter

  \startchapter [title=Second Chapter]
  I am in the first page. \page
  I am in the second page.
  \stopchapter
\stoptext

screenshot

  • \adpatlayout is simpler than the \appendtoks jugglary. – Aditya Aug 4 '13 at 22:07
  • @Aditya \adaptlayout only adjusts the text height. It does not allow to select a different layout, if I'm not mistaken. I tried to simplify the OPs code. Varying the text height probably wasn't the best choice. – Marco Aug 4 '13 at 22:21
  • You are right. \adaptlayout only checks for height and lines keys. However, one must use \setuplayout[reset] with care. In particular if the main layout is activated using \definelayout[name][...] followed by \setuplayout[name], then \setuplayout[reset] will reset to default layout rather than name layout. – Aditya Aug 5 '13 at 0:30
  • With headerdistance=1cm in the firstpagelayout, the textheight is reduced in all following pages. Is there any way to circumvent this? – tstenner May 3 at 13:07
  • Even with this MWE, try replacing the text ("I am…") with \the\textheight – the frame is larger, but the area for text is shrunk for all pages – tstenner May 6 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.