TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

Widows and orphans
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

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" ...
    \clubpenalty=10000
    \widowpenalty=10000 
    \displaywidowpenalty=10000
  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
         \eject 
      \fi \endgroup}

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

local time: Wed Oct 16 21:14:32 CEST 2019 ; file is: 115.437916666667 days old
contact webmaster _at_ TeXnik.de