LaTeX Tricks

Written by Josh on October 25, 2015

Recently, I have beeing using \LaTeX for almost all of my word processing. In general it is wonderful, but there are some things that are more difficult to set up than they should be. Below are some solutions to problems I have run across.

Simple headers

While the default title page format is nice for long documents, it is far too large for single page documents. The fancyhdr makes it easy to make simple headers. Simply include the package and set \pagestyle{fancy}, then use \fancyhead and \fancyfoot to set headers and footers. The first parameter determines where the header or footer is. L, C, and R left-, center-, or right-align it; E and O make it only appear on even or odd pages. The next parameter, in curly braces, is the text.

To make the text larger, you can use the standard \LaTeX font size modifiers (here is a list of the different size commands). When using bigger text, fancyhdr will complain that the header is not big enough and that you must use a certain command to increase it. Add \setlength{\headheight}{30pt} to the preamble, changing 30pt to the size it suggests, and it will be happy.

\fancyhead[C]{\LaTeX Tricks}

By default, there is a page number in the bottom middle. This can be removed with \fancyfoot[C]{}, as in the example above.

Narrower margins

\LaTeX by default has rather wide margins, which are good for properly typeset documents as it limits the number of characters per line. However, teachers tend to dislike this as it looks like you are trying to get away with writing a shorter essay. The geometry package allows you to set your own margins. The example below shows margins of 0.5in all around except for 0.75in on the top.


Multiple separate columns

The multicol pagckage makes it easy to flow text in multiple columns, but to have two separate chunks of text is more difficult. You can use \columnbreak to force a column break, but the line spacing is expanded so the text in each column takes up the same height. The workaround is to add \vspace*{\fill} to the bottom of each column. This adds as much vertical space as is needed to match the height of the longest column, adding blank space instead of widening the line spacing.


Column one


Column two


Degree sign

\LaTeX does not have a degree symbol built-in. You can get one by including the textcomp package and using \textdegree.

Text in math mode

An easy way to include a chunk of (normally typeset) text in math mode is to use the \text{<text block>} command from the amsmath package. amsmath also adds many helpful math-mode environments, such as align, to vertically align multiple parts of equations.

Double spaced lines

Add \usepackage[doublespacing]{setspace} to the document preamble to double the space between lines.

Change the document metadata

PDF’s have embedded metadata that says what program created it. To remove this metadata, put the following line in the preamble:

\usepackage[pdftex, pdfproducer={}, pdfcreator={}]{hyperref}

Put text inside the curly brackets to set it to something other than an empty string. See the chart here (scroll down some) to see the other metadata options you can change.

Mixed Bullets and Labels

The description environment lets you put arbitrary text instead of a bullet in a list. By default, you must have a label for all items, or there is no text in front and it looks strange. Using the enumitem package, one can set the itemize environment to use a bullet by default, or the user’s text of choice if an argument is set. In the example below, the first and last items use a bullet, while the middle item is given a label.

    \item Bullet
    \item[label] Text
    \item Bullet

This appears in the document like so:

Updated 11/22/2015 to add instructions about how to remove the document metadata and about how to mix bullets and labels in an itemize environment.

Copyright © 2014-2016 Joshua Oldenburg