LaTeX Tips
Published:
This page is a collection of LaTeX tips applicable when typesetting documents using pre-defined formats.
Compiling
Use latexmk and not pdflatex.
The command latexmk runs the other latex tools the correct number of times and in the correct order.
You may have noticed that latex compilation creates a lot of “unnecessary” files.
The command latexmk -c main.tex deletes those files.
However, these files cache data produced by previous runs and speed up subsequent compilation.
To keep them in a separate directory _aux, use latexmk --aux-directory=_aux main.tex.
Overfull boxes
To mark overfull boxes in the pdf output when using latex, add \overfullrule=5pt to the preamble.
For the final output, change it to \overfullrule=0pt to remove any remaining marks.
An overfull box usually happens when TeX cannot find good line breaks due to lack of hyphenation patterns.
The easiest, non-technical fix is to rewrite the sentence so that better line breaks are available in the new text.
If that is not possible, we can add discretionary hyphens using \-.
Consider the word pneumonoultramicroscopicsilicovolcanoconiosis..
We can type it as follows:
pneumono\-ultra\-microscopic\-silico\-volcano\-conio\-sis
to encourage tex to hyphenate this word at those positions if necessary.
Another common reason for overfull boxes are large math boxes.
Most often, we can avoid them by splitting the math mode sensibly.
For example, instead of $a,b,c$, write $a$,$b$,$c$.
Better typography
Always put \usepackage{microtype} in the preamble if you are using LaTeX.
This package makes only minor (micro) adjustments to text yet makes it look better overall.