Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force a maximum number of pages in LaTeX

Tags:

latex

Is there a way to give LaTeX a hint on the maximum number of pages I would like the document to have, so LaTeX at least tries to not exceed this maximum if possible?

like image 248
Christian Avatar asked Apr 27 '10 10:04

Christian


People also ask

How do I reduce the number of pages in LaTeX?

Go with the pt option of \documentclass available for most of the document classes. Reduce space in lists. Also, don't forget the \tightlists , \firmlists , \firmlists* commands in memoir class.

Is there a limit to overleaf?

Overleaf is free to use, while the paid subscription plans allow larger projects to compile, with a higher timeout limit. * Some larger files may remain editable under certain circumstances. To ensure that a file remains editable, please limit its size to 1MB or less. † There is no enforced limit on total project size.


2 Answers

While you can't make a "suggested" page length, you can enforce a page limit where any pages past the limit will not print. Here's an example of a command you can create in your preamble to do this:

\makeatletter
\newcounter{pagecount}
\newcommand{\limitpages}[1]{
    \setcounter{pagecount}{0}%
    \gdef\maxpages{#1}%
    \ifx\latex@outputpage\@undefined\relax%
        \global\let\latex@outputpage\@outputpage%
    \fi%
    \gdef\@outputpage{%
        \addtocounter{pagecount}{1}%
        \ifnum\value{pagecount}>\maxpages\relax%
            % Do not output the page
        \else%
            \latex@outputpage%
        \fi%
    }%
}
\makeatother
like image 55
Compholio Avatar answered Sep 23 '22 12:09

Compholio


No. LaTeX optimizes text at page level but not document level. So there is no way to automatically squeeze the text into a maximum number of pages. However, there are lots of ways to squeeze things in order to reduce the number of pages. See this blog post on "Squeezing space with LaTeX".

like image 22
Rob Hyndman Avatar answered Sep 19 '22 12:09

Rob Hyndman