I use \widowpenalty
and \clubpenalty
to avoid widow and orphan lines. However, latex automatically increases the line spacing of my document. How do I prevent the increment of line spacing while using these two variables?
[Tex/LaTex] When using \widowpenalty and \clubpenalty, how can I prevent spacing increasing
widows-orphans
Related Solutions
Let's look at what we get when we add \showoutput
. I just show the diagnostic messages relative to the first pair of lines:
Completed box being shipped out [1]
\vbox(633.0+0.0)x407.0
.\glue 16.0
.\vbox(617.0+0.0)x345.0, shifted 62.0
..\vbox(12.0+0.0)x345.0, glue set 12.0fil
...\glue 0.0 plus 1.0fil
...\hbox(0.0+0.0)x345.0
..\glue 25.0
..\glue(\lineskip) 0.0
..\vbox(550.0+0.0)x345.0
...\write-{}
...\glue(\topskip) 10.0
...\rule(0.0+0.0)x*
...\penalty 10000
...\glue 384.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.05556
...\hbox(6.94444+0.0)x345.0, glue set 306.11107fil
....\hbox(0.0+0.0)x15.0
....\OT1/cmr/m/n/10 l
....\OT1/cmr/m/n/10 i
....\OT1/cmr/m/n/10 n
....\OT1/cmr/m/n/10 e
....\glue 3.33333 plus 1.66666 minus 1.11111
....\OT1/cmr/m/n/10 1
....\penalty 10000
....\glue 0.0 plus 1.0fil
....\penalty -10000
....\glue(\rightskip) 0.0
....\glue(\rightskip) 0.0
...\penalty 10000
...\penalty 300
...\glue(\baselineskip) 5.05556
...\hbox(6.94444+0.0)x345.0, glue set 321.11107fil
....\OT1/cmr/m/n/10 l
....\OT1/cmr/m/n/10 i
....\OT1/cmr/m/n/10 n
....\OT1/cmr/m/n/10 e
....\glue 3.33333 plus 1.66666 minus 1.11111
....\OT1/cmr/m/n/10 2
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.05556
It's quite clear what happens: the command \\*
does \vadjust{\penalty10000}
and this \vadjust
item find its way after the line containing line 1
. But also the normal penalty pertaining to the paragraphs are added. In this case, the sum of \clubpenalty
and \widowpenalty
is inserted, resulting in \penalty300
. Any penalty in the outer vertical list is a feasible page break point, and TeX can and does choose it in the seventh two line pair.
What does this mean? Simply that \\*
should not be used in a paragraph for inhibiting a page break. In general \\
should not be used for breaking a line, to tell the complete truth.
You should worry about these details only when the document is finished and is in its really-really-no-more-changes-to-the-text status.
At that point, you may realize that your “Bibliography” line is no longer alone in the second page. But it could, or there might be two lines.
Moving one line to the first page is easy: add \addtocontents{toc}{\protect\enlargethispage*{\baselineskip}}
to your document:
\documentclass{report}
\begin{document}
\addtocontents{toc}{\protect\enlargethispage*{\baselineskip}}
\tableofcontents
\chapter{Introduction}
\chapter{Background}
\chapter{Setup}
\chapter{Methodology}
\chapter{Data}
\chapter{Statistical Selection}
\chapter{Uncertainties}
\chapter{Results}
\section{Results of methodology 1}
\section{Results of methodology 2}
\section{Results of methodology 3}
\section{Results of methodology 4}
\section{Results of methodology 5}
\section{Resuts of methodology 6}
\section{Results of methodology 7}
\newpage
\section{Results of methodology 8}
\section{Results of methodology 9}
\section{Results of methodology 10}
\section{Results of methodology 11}
\section{Results of methodology 12}
\section{Results of methodology 13}
\section{Results of methodology 14}
\section{Resullts of methodology 15}
\chapter{Conclusions}
\chapter{Appendix}
\chapter{Bibliography}
\end{document}
and after a couple of LaTeX runs you'll obtain the desired output
If instead the second page of the table of contents turns out to have two or three lines, it may be impossible to squeeze them in the first page, but you can shorten the first page so as to move a couple of lines more in the second page, with
\addtocontents{toc}{\protect\enlargethispage{-3\baselineskip}
or with a different factor, depending on what you actually have at the bottom of the first page.
But, I insist, do this only when the document is in its final state, really no more changes to the text.
Best Answer
Changing
\widowpenalty
and\clubpenalty
does not alter the line spacing as the following example shows:However, because increasing these penalties makes it harder for LaTeX to find good page breaks, additional spacing must appear somewhere to fill out the pages. Depending on your settings, this might be at the bottom of pages, between sections or paragraphs etc. Basically, the space has to go somewhere in order to ensure that, for example, an additional line or so gets pushed past a page break when needed.
Without an example, it isn't possible to say precisely what is going on in your case or how you might alter it.
But note that the more restrictions you place on LaTeX, the worse the results will be in general so constraining typesetting to exclude widows and orphans will force LaTeX to make worse choices than it otherwise would regarding other aspects of the document, probably including uneven and excessive spacing in some cases.