TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

Widows and orphans
TUG logo

Main page

Search CTAN:


Google c.t.t.

Google d.c.t.t.



LaTeX puts sometimes only one ore two lines on a new page, whicht looks very ugly. There is no special comment to prevend LaTeX from doing this. Try out one of the following four solutions. Put them always in the latex preamble. Here you'll find some more information.
  1. The "default" ...
  2. % my \keeptogether 
    \def\need{\begingroup\afterassignment\n@@d \dimen@}
    \def\n@@d{\vskip\z@ plus \dimen@ \penalty-60
                      \vskip \z@ plus-\dimen@ \endgroup}
    Unfortunately, this grabs only an approximate space, and the exact amount depends on the usual "badness" of a normal break. One way to ensure getting the right space is to eliminate the badness of ordinary breaks:
  3. \def\raggedbottom{\topskip 1\topskip plus1000\p@ \r@ggedbottomtrue} 
    \def\need#1{\vskip #1\penalty \z@ \vskip-#1}
    Which works pretty well, if you don't mind raggedbottom pages.

  4. Finally, there is another method that works very well, as long as you use it between paragraphs: (I.e., not in a \vadjust{}.)
    \def\need#1{\par \penalty-100 \begingroup % preserve \dimen@
      \dimen@\pagegoal \advance\dimen@-\pagetotal % space left
      \ifdim #1>\dimen@ % not enough space left
         \ifdim\dimen@>\z@ \vfil\fi % only do \vfil if some space left on page
      \fi \endgroup}

Alternative you can try on the page where the line should be:
play a bit with the size 2ex (2 lines).

local time: Tue Apr 16 08:31:27 CEST 2024 ; file is: 1758.90799768519 days old
contact webmaster _at_ TeXnik.de