How to tell Latex the preferred number of pages of the finished document?

I'm designing a booklet with 16 pages, and using Latex with Memoir class.

Latex does a very beautiful layout, and seems to prioritize to make the page breaks in good places according to the chapter divisions. That's great for the most part, but it's also very important for me that the book is exactly 16 pages. Now, however, it's 17.

I see that there are some extra space on some pages that could be used to cut down the book one page. How can I tell Latex that it's really important for me that the book is 16 pages. I'd prefer if I could do this in a way without putting hacks in the spaces in question, but instead continue letting Latex do the job, but with the change that it knows that it's important for me that the book is 16 pages. Can I do that? How?

• I don't think it's possible to do that. The way TeX's page building algorithm works does not allow it to know how many pages your document will have while building the beginning of the document. You could, after you finished the writing, do a few manual teaks. You can add `\looseness-1` to reduce one line from the paragraph you put this instruction on. You can change the `\parskip` a little bit. You can use `\enlargethispage{}` to make a couple more lines fit into it... – Phelype Oleinik May 16 '18 at 12:04
• @PhelypeOleinik really good tips! – PetaspeedBeaver May 16 '18 at 12:07

The `memoir` class includes a command

``````\leavespergathering{num}
``````

which will ensure that there will be the correct number of pages output to make a complete set of gatherings of `num` leaves (`2num` pages) each. Thus for a total of 16 pages (8 leaves 1 gathering)

``````\leavespergathering{8}
``````

will produce sets of 16 pages.

If there are only, say, 13 pages then three extra pages will be output. I can't remember if there is a minor overspill what happens. If in that case you get a total of 32 rather than 16 pages then you will have to do something to increase the text area of the pages --- increase the `\textwidth`, increase the `\textheight`, judicious use of `\enlargethispage`.

For more information on `\leavespergathering` see section Gatherings or signatures in the `memoir` manual (`< texdoc memoir`).