LaTeX – Squeezing Space
Here are some tips on how to squeeze a little more onto LaTeX pages. Note that these methods may adversely affect the appearance of the document, so use them with caution. Rephrasing and editing your text often leads to better results.
The savetrees package executes many of these methods, packing as much text as possible onto each page.
Fonts
Without changing the point size of a font you might be able to fit more text on a page by choosing a more compact font like Times
Page Layout
The a4 package will give you narrower margins. To have more control use the geometry package. If you use the layout package then \layout will produce a test page showing the values of the
variables that control page layout.
Prof. Koenraad De Smedt’s suggested that by using \linespread{0.9} (which multiplies the normal space between lines by a factor 0.9) you can often get satisfactory results.
Changing lengths
There are many variables in LaTeX determining lengths. Two commands to change them are \addtolength and \setlength. The dimensions understood by LaTeX include cm, mm, in and pt. Variables can be set to a negative value.
Example: \addtolength{\parindent}{-5mm}
Some useful variables are
- Page Layout
- \columnsep: gap between columns
- \topmargin: gap above header
- \topskip: between header and text
- \textheight: height of main text
- \textwidth: width of text
- \oddsidemargin: odd page left margin
- \evensidemargin : even page left margin
- Paragraphs
- \parindent: indentation of paragraphs
- \parskip: gap between paragraphs
- Floats (tables and figures)
- \floatsep: space left between floats.
- \textfloatsep: space between last top float or first bottom float
and the text. - \intextsep : space left on top and bottom of an in-text float.
- \dbltextfloatsep is \textfloatsep for 2 column output.
- \dblfloatsep is \floatsep for 2 column output.
- \abovecaptionskip: space above caption
- \belowcaptionskip: space below caption
- Maths
- \abovedisplayskip: space before maths
- \belowdisplayskip: space after maths
- \arraycolsep: gap between columns of an array
- Lists
- \topsep: space between first item and preceding paragraph.
- \partopsep: extra space added to \topsep when
environment starts
a new paragraph. - \itemsep: space between successive items.
Environments
The atbeginend.sty package provides \BeforeBegin{environment}{code-to-execute}, \AfterEnd ... etc. These commands can be used to remove space around and within environments. This can be useful in situations where the environment resets values that over-ride those you’ve created. For example, \AfterBegin{itemize}{\addtolength{\itemsep}{-\baselineskip}} in a LaTeX file squeezes items together by resetting \itemsep inside the environment.
The mdwlist package has a itemize* environment.
The paralist package offers a compactitem environment (that puts less space between items) and an inparaenum environment (that doesn’t create new paragraphs for each item).
Figures and Tables
To save space, you can put more than one graphic inside a figure environment by using the subfigure package. It’s also possible to wrap text around a figure using the floatflt package.
Using “\begin{figure} ... \centering ...” rather than “\begin{figure} ... \begin{center} ...” saves space. Sometimes excessive white space around a figure isn’t LaTeX’s fault. It may be that a postscript figure contains a big white border. ps2epsi can be used to produce a minimal bounding box, or you can use the clipping feature of the \includegraphics command of the graphicx package.
By default, LaTeX doesn’t like to fill more than 0.7 of a text page with tables and graphics, nor does it like too many figures per page. This behaviour can be changed by placing lines like the following before \begin{document}
\renewcommand\floatpagefraction{.9} \renewcommand\dblfloatpagefraction{.9} % for two column documents \renewcommand\topfraction{.9} \renewcommand\dbltopfraction{.9} % for two column documents \renewcommand\bottomfraction{.9} \renewcommand\textfraction{.1} \setcounter{totalnumber}{50} \setcounter{topnumber}{50} \setcounter{bottomnumber}{50}
To reduce the size of captions use the caption package.
If you have a big table you might wish to bracket it by \begin{small} … \end{small}.
You can reduce the gap between table columns by using \setlength{\tabcolsep}{1pt}. It may also be possible to scale a whole table as you can a piece of graphics, using \resizebox{!}{5cm}{\begin{tabular} ... \end{tabular}} though you need to view the output as postscript.
Controlling where space goes
If latex can’t fill a page (perhaps because the next object is a figure or table that doesn’t fit, or because the next object is a heading that latex doesn’t want to put at the foot of a page) then by default it will spread the vertical white space on the page so that the “height” of the page is the default height. If you want all the extra white space to appear at the bottom of such pages, add \raggedbottom before your \begin{document} line.
Headings
Vertical space around a heading depends on \parskip, \baselineskip and other parameters that LaTeX sends to the @startsection routine. Remember also that LaTeX doesn’t like putting a heading right at the bottom of a page – it would rather leave space.
Unless you want to redefine the sectioning commands yourself, it’s worth looking at the titlesec package, which offers space-saving alternatives to the standard sectioning commands (especially \chapter). Even just \usepackage[small,compact]{titlesec} might save you quite a lot.
Contents and bibliography
The multitoc package
lets you have a two column table of contents in a single column document.
To reduce the linespacing in a bibliography (the same idea works for contents pages) use the
setspace package
\begin{spacing}{0.9} \tableofcontents \end{spacing} ... \begin{spacing}{0.9} \bibliographystyle{plain} \bibliography{refs} \end{spacing}
If you’re using the natbib package (recommended) then you can change the value of \bibsep to control the gap between items. Otherwise put the following (suggested by Axel Reichert) in the preamble
\let\oldthebibliography=\thebibliography \let\endoldthebibliography=\endthebibliography \renewenvironment{thebibliography}[1]{% \begin{oldthebibliography}{#1}% \setlength{\parskip}{0ex}% \setlength{\itemsep}{0ex}% }% {% \end{oldthebibliography}% }
You can use the same idea to modify other environments – theglossary, etc.