# Optimize space usage of paragraphs

I have sometimes encountered the problem in TeX, that a paragraph does not fit on one single page and is therefore splitted over two pages. This behavior makes of course sense.

However, I noticed that for some document classes, this split is wasting some space. I.e., if I have a paragraph like this:

``````Line1
Line2
Line3
Line4
``````

Assume that these four lines fit perfectly on one single page, being aligned to the bottom of that page (so the page is full).

However, now I add another sentence to that paragraph, I get the following:

``````Line1
Line2
Line3
------> page changes here
Line4
Line5
``````

So as you can see, although there seems to be enough space for 4 lines on the first page (first example), in the second one only 3 lines are placed there, thus wasting space of 1 line on that page, which doesn't make any sense to me.

I have tried using `\filbreak` and that works, but then I have to interupt the paragraph, making if effectivly two paragraphs which is not always desired.

Unfortunatly I was not able to reproduce that behavior with the standard standalone/article class, so I am not really sure where this problem originates.

Question: Did anyone ever had a similar problem and was able to resolve it? How can I optimize space by using all available lines on a page without splitting paragraphs?

it is normally considered bad style to break the page leaving just the first line on one page or just the last line on the next page, and tex has penalities (widowpenalty and clubpenalty) to discourage this. Note that TeX will only take the additional line over if there is sufficient stretch specified on the previous page, so if you are seeing that you must have enough white space stretch on that page to make up for the line.

TeX is not making the judgement here, you (or the class file settings you are using) have specified that white space (between paragraphs or around headings and lists etc) or at the bottom of the page is flexible enough to allow this.

you could set `\widowpenalty=0` and `\clubpenalty=0` so that TeX is not worried about separating off single lines. (The usual question is rather the opposite on how to absolutely prevent ever getting a widow line)

• Well, the problem is that this does not only occur with single lines, but also if the paragraph is made longer by multiple lines. Imagine I add 10 new lines, then there should be no penalty, because there are many additional lines on the second page. However, there is still the "wasted line" problem happening. I tried widowpenalty, clubpenalty and displaywidowpenalty (setting all to 0 or very high values), but unfortunatly that didn't change anything... – SampleTime Nov 10 '18 at 17:58
• @SampleTime if you provided an example it would be simple to trace tex's page breaking and explain why it broke were it didn't and how to change the parameters so it breaks at a different line. Without an example only very generic comments as I gave above are possible. (Basically almost every question should include a complete but small example document.) – David Carlisle Nov 10 '18 at 18:04