# Adding empty pages to fill up a book page quota

I am writing a book and have already made contract for x pages with the printing company, so I want to create a PDF containing x pages. However, say that I only have material enough to fill x − y pages. Is there some package or simple hack available for adding y empty pages at the end of the document? I.e. I want to add empty pages until the latest added page is page number x.

-
You could add clearpage\null the appropriate number of times. (And add \pagestyle{empty} after the first \clearpage\null.) –  lockstep Aug 6 '11 at 9:34

You can do this using a simple loop.

The following code will ensure the document to be e.g. 100 pages in size:

\documentclass{article}

\usepackage{lipsum}

\newcommand\emptypages[1]{%
\loop\ifnum\value{page}<#1\relax
\clearpage
\null
\thispagestyle{empty}%
\repeat
\clearpage
}
\AtEndDocument{\emptypages{100}}

\begin{document}

\lipsum[1-20]

\end{document}

-

The memoir package provides the \leavespergathering{} command for a purpose closely related to yours. Ipsis literis from the manual:

The command \leavespergathering{num} ensures that there will be exactly the right number of pages output to make a complete set of gatherings of num leaves (2× num pages) each --- if necessary blank pages will be output at the end to make up the correct tally. If num is less than two (the default) then no additional pages will be output.

Thus, to fill to 84 pages, for example, you would use \leavespergathering{42}

-