Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a document that looks like this:

 __________________ __________________
|                  |                  |
| Chapter Title    | Section  ....... |
|                  | .......  ....... |
| Section  ....... | .......  ....... |
| .......  ....... | .......  ....... |
| .......  ....... | .......  ....... |
| .......  ....... | .......  ....... |
| .......  ....... | .......  Section |
| .......          | .......  ....... |
| .......          | .......  ....... |
|__________________|__________________|

I want to add some white space to all of the pages in the document, so that the top of the paragraphs of text aligns on all pages and the chapter titles and section titles have their own space at the top, like this:

 __________________ __________________
|                  |                  |
| Chapter Title    |                  | <-- Chapter titles
|                  |                  |
| Section          | Section          | <-- Section titles
|                  |                  |
| .......  ....... | .......  ....... | <-- Text begins here
| .......  ....... | .......  ....... |
| .......  ....... | .......  ....... |
| .......  ....... | .......  ....... |
| .......  ....... | .......  ....... |
|__________________|__________________|

Even when no chapter or section titles appear on the page, the text still begins on the page at a fixed space, so it is consistent across all pages.

 __________________ __________________
|                  |                  |
|                  |                  | <-- Chapter titles
|                  |                  |
|                  |          Section | <-- Section titles
|                  |                  |
| .......  ....... | .......  ....... | <-- Text begins here
| .......  ....... | .......  ....... |
| .......  ....... | .......  ....... |
| .......  ....... |          ....... |
| .......  ....... |          ....... |
|__________________|__________________|

How can I add some white space to the top of the text such that only the chapter and section titles appears in this top area and the text appears at a fixed height?

share|improve this question
1  
Not very elegant, but maybe sufficient: \setuphead[chapter][before={\blank[-2cm,force]}] –  Marco Jun 8 '13 at 11:34
3  
+1 for the ASCII art ;) –  Papiro Jun 8 '13 at 11:34
    
+1 for @Marco's answer. Maybe a good mailing list question? –  Mica Jun 11 '13 at 4:02
    
There are a few ways to achieve this, but it depends on your exact spec. Should the space on the top of each page be fixed, or should it depend on how big the chapter title is? For example, in you ASCII ART does the output of page 2 depend on whether the chapter title is 1 line or 5 lines? –  Aditya Jun 11 '13 at 17:24
1  
I am guessing it is really difficult to get it to span across to the next page. Is there a setting which lets it just run off into the edge of the page? I edited my document so that none of the titles are too long. –  Village Jun 12 '13 at 3:56
show 3 more comments

1 Answer

up vote 3 down vote accepted
+200

One possible solution is to set the chapter title in a layer.

First, lets start with the page layout. Set a large headerdistance to get a large empty space on all pages.

\setuplayout
  [
    headerdistance=8cm,
    footerdistance=0cm,
  ]

Next, define a layer and set it as the page background. This layer will be used for the chapter title.

\definelayer[chapter]
\setupbackgrounds[page][background=chapter]

Finally, define a sectionheadalternative that sets the chapter title in a layer. I simply delegate the task of actual formatting of the section head to the default sectionhead rendered.

\defineheadalternative
  [layer]
  [
    alternative=vertical,
    renderingsetup=chapterlayer,
  ]

\unprotect
\startsetups[chapterlayer]
    \setlayerframed
        [chapter]
        [
          x=\layoutparameter{backspace},
          y=\the\dimexpr\layoutparameter{topspace}+\layoutparameter{header}+1cm\relax,
        ]
        [
          width=\textwidth,
          height=7cm,
          align=normal,
          foregroundstyle={\switchtobodyfont[32pt,ss]},
          frame=off,
        ]
        {\setups{\??headrenderings:\v!normal}}
\stopsetups
\protect

Finally, set the chapter alternative to this new sectionheadrenderer.

\setuphead[chapter]
          [
            style={\switchtobodyfont[32pt,ss]}, 
            alternative=layer,
            before=,
            after={\vskip -0.9\lineheight},
          ]

The \vskip -... is a kludge to get rid of a blank line that is introduced immediately after the section head. I am assuming that this is due a \par somewhere in the section macros. I couldn't figure out how to get rid of it, hence the kludge.

With the above setup, I get the following output:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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