[NTG-context] page breaks before titles

Wolfgang Schuster schuster.wolfgang at gmail.com
Sat Mar 7 11:05:06 CET 2015


> Am 07.03.2015 um 00:46 schrieb mf <massifr at fastwebnet.it>:
> 
> Hello,
> I'm trying to typeset a book made of letters with ConTeXt.
> Every letter has a title a subtitle and a date, before it
> starts with "Dear ..."
> Like this:
> ---------------------------------
>          Title
>         subtitle
>                    where, when
> Dear ...,
> the rest of the letter
> ...                 
> ---------------------------------
> 
> The letters are very different in length -- some are long,
> some are made of a couple of lines --, so I'd like to
> typeset them continuously, without skipping to a new page
> every new letter (\setuphead[LetterTitle][page=no]).
> 
> This way a letter could finish beyond the half of a page,
> and the next one could have no space left to get the part
> from Title to the first lines of the body on the same page.
> 
> That's why I disabled page breaks from Title to the first
> paragraph after "Dear ...": it would be ugly having only
> the title in one page and the rest in the next ones.
> 
> But there's a side effect: the title of the new letter
> "pulls" the last two lines (the penalties are set to avoid
> one-line widows) of the previous letter to the new page,
> even when there's room for them on the previous page.
> In this case I would like ConTeXt to break the page at
> the end of the previous letter, before the next letter title.
> That's why I've set 
>  before={\blank[2*line]\page[preference]} 
> in LetterTitle. But it does not work.
> Example:
>         ---------------------       ---------------------
>         text of the previous        text of the previous 
>         letter with room to be      letter with room to be
>         all typeset here            all typeset here
> page 11                              last two lines of the
>         [room for >2 lines]         the previous letter
> 
> page break-------------------   ==>  -------------------
>         last two lines of the             Title
>         the previous letter             subtitle
>                                     ...
> page 12       Title
>            subtitle 
>         ...
> 
>         --------------------        --------------------
> 
> Is there a way to know the vertical location where the
> previous letter ends, to decide whether to skip to a new
> page?

You can use the \testpage command where you can set how many
lines should remain on the page before a page breaks happens.

\setuphead[LetterTitle][before={\testpage[8]\blank[2*line]}]

If this doesn’t help you should make a *working* minimal example.

Wolfgang


More information about the ntg-context mailing list