# Monotonicity of number-of-pages as a function of the number-of-characters

I often prepare papers for conferences with an upper limit on the number of pages. I spend a lot of time thinking what words and characters to delete in order to make the paper fit in the page limit.

Recently, I run into an interesting and paradoxical phoenomenon: I remove some words, and the number of pages increases! As an example: I have a two-column paper. I remove two words from the top of column #2 at page #1. As a result, LaTeX takes the last line from column #1 and puts it on top of column #2. Now, the last line of column #2 is pushed to page #2, and so on, and this leads to page overflow.

It is very difficult to create a minimal working example since this behavior doesn't make much sense to me. So before I spend time to create an MWE, I will be happy to know if this behavior is known.

• i'm really not sure why this question has been down-voted. the behavior is definitely known, and i'm sure i've seen it explained somewhere, although at the moment i can't remember where. – barbara beeton Jan 27 '18 at 20:10
• @barbarabeeton I've up-voted it. I also have vague memories (something to do about references to another item in a paper) where LaTeX oscillates between OK and NBG as the reference shifts the referenced item, which invalidates the reference which modifies it which .... – Peter Wilson Jan 27 '18 at 20:54

For example, there is a paragraph with four lines, two lines are at the bottom of the column A and two lines are at the top of the next column B. Then, one or more words are removed with the result that TeX breaks the paragraph in three lines instead of four.

The document has set \clubpenalty and \widowpenalty to 10000 to prevent widows and orphans (page break right after the first line or right before the last line of a paragraph). The result is that TeX cannot break the paragraph of three lines.

If there is not enough place in column A (likely), then LaTeX has to move the paragraph to column B. Before the deletion of some words, column B got two lines, now column B takes the whole paragraph with three lines. The extra line can now cause a further page, because at every next page breaks stuff is moved to the next page.

• Very nice explanation! Is there a way to mark the regions in which removing words will make the document longer and/or adding words will make it shorter? In other words, is there a variable that one may watch, some kind of badness or so? – user121799 Jan 27 '18 at 20:36
• @marmot No, there are too many parameters to consider, what is deleted, where it is deleted, influence on line breaking, influence on page breaking, float placement, ... – Heiko Oberdiek Jan 27 '18 at 20:52

Here is a very simpleminded approach to the problem. (And yes, I also remember that I experienced similar things.) This fragile code marks paragraphs that TeX thinks are "bad".

\documentclass[twocolumn]{article}
\usepackage{lipsum}
\newcounter{Pars}
\let\oldpar\par
\def\par{\stepcounter{Pars}%
\typeout{paragraph \thePars good}%
\else%
\marginpar{\vspace*{-\baselineskip}$\uparrow$}\relax%\vspace*{-\baselineskip}\makebox[0pt][l]{\color{red}$\uparrow$\color{black}}\relax%
\fi
\oldpar}
\begin{document}
\lipsum[1]

\lipsum[2]

\lipsum[3]

\lipsum[4]

\lipsum[5]

\lipsum[6]

\lipsum[7-20]
\end{document}


Let me stress that I am not an expert and hope not to do any major harm. However, this snippet seems really to identify some "problematic" paragraphs. And of course one can play with the threshold or replace \badness by some other measure. And, as Heiko explained, of course the problematic positions may shift if one makes changes at other places. Nevertheless, my hope is that this code may help you to identify locations worthwhile being modified somewhat more efficiently.