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 runacross.

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 thetext.

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 behappy.

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

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 thetop.

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 linespacing.

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 mathmode

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 ofequations.

Double spaced lines

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

Change the documentmetadata

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

\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 canchange.

Mixed Bullets andLabels

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 alabel.