3-1: Placing and Spacing

One of the advantages of using LaTeX is that it will automatically format your document in a very visually appealing manner.  However, sometimes we would like to have a little more control over the appearance of information in our document.  For example, making a printable worksheet, writing a test, etc.

In cases where the change is something you want to make throughout the document, many times you can make a change in the preamble that will affect the entire document!  This lesson will focus on ways that you can set-up your document right from the beginning to make these customizations, and what you can do when you only need to make some minor changes.

Layout the Plan

We have discussed some of the reasoning behind why LaTeX chooses what may seem to be large margins, and we have also seen that the fullpage package allows the margins to be set to either 1 inch or 1.5 cm. Depending on your goals, this may not fit your plan for the document.

We can customize the size and layout of the document using the
\setlength{«parameter»}{«length»} command. The diagram below illustrates the different parameters and what they control.

For example, say I wanted to make a 8.5 inch \(\times\) 11 inch document with 1.5 inch borders, and I was not intending on using a header.  Then my preamble might look like the following:


% Document contents here

Note that \evensidemargin only needs to be specified if you are working with a two-sided document (see below).  If you intend on producing a document for printing, it can be helpful to know that some LaTeX compilers/distributions will set \pdfpagewidth and \pdfpageheight to A4 size by default (an international standard, 8.27 by 11.69 inches) instead of the typical North American letter size (8.5 by 11 inches).

If these parameters seem a little complex, you may want to consider reading the documentation for the geometry package, which can sometimes simplify this process.

Here are two other parameters that you might use with \setlength{}{}:

  • \parskip.  This parameter indicates how much extra space should be placed between successive paragraphs.
  • \parindent.  This parameter indicates how large the indent at the beginning of a paragraph is.  Set this value to 0in to remove indentation from your document.

\hspace{} and \hfill

We next discuss several spacing commands. \hspace{} can be used to generate a horizontal whitespace between two objects located on the same line.  Note that if this command is used within a paragraph and falls near a linebreak, it may be ignored similar to other white space. For example,

The following line \\
\hspace{2in} does not acknowledge the \textbackslash hspace command.

To force a horizontal space to always be noticed, place an asterisk in the \hspace*{} command.

\hfill is another horizontal spacing command, but this command does not take any parameters.  Instead, this command takes up as much horizontal space on a line as possible, stretching out to fill a line.

This content on left. \hfill This content on the right. \\
Next line of the paragraph


The \hfill command will only be effective if the user limits the amount of content placed on the same line.  Multiple \hfill commands can be used on the same line to evenly space out content.

\vspace{} and \vfill

These are the vertical counterparts of  \hspace{} and \hfill, with a couple of differences that should be noted.

\vspace{«len»} will put «len» amount of vertical space between the line where it is located and the following line.  Try typesetting:

Where will \vspace{2cm} the space go if I place the command in the centre of a line of text longer than one line?

Therefore, to be explicit about where you want LaTeX to place the space, it is recommended that you place an explicit line-end command immediately after this command:

  • you can use the line-break command \\ if you wish to have the following text be a part of the same paragraph
  • or you can use a blank line if you wish to start a new paragraph.

\vfill on the other hand will automatically start a new paragraph following where it is placed.  Similar to \hfill, mutiple commands can be used on a page, and keep in mind that the function is only effective when you limit the amount of information on a page.  Use the \clearpage command to force a new page to begin.

documentclass Options

In addition to specifying the document type (we’ve been using article), one can also specify options for that document. Using the syntax \documentclass{option1, option2, ...}[class]. Some of the more common ones are:

  • 10pt11pt, or 12pt, which you have already seen. These will change the font size within your document. The default size is 10pt.
  • twoside. This tells the document to use the \oddsidemargin for odd pages and the \evensidemargin for even pages.
  • twocolumn.  This will break the body of your document into two columns.

Thus, for a two-sided, 12pt font document, the first line of the .tex file would be


There is also a documentclass option for landscape mode, but it requires extra work. An easier solution is to load the geometry package like this: \usepackage[landscape]{geometry} (If you only want to change the orientation of some pages and not the whole document, you will need a different package.)

The setspace Package

While the \setlength{}{} command can be used to change the line spacing in your document, you may be affecting settings that you don’t necessarily want to.  The setspace package makes setting the distance between lines simple.

The four commands below can be used anywhere in your document (including the preamble).  They will change the line spacing of the paragraph they are included in, as well as any content following the command.

  • \singlespacing (default)
  • \onehalfspacing
  • \doublespacing
  • \setstretch{«num»} (scales single-spacing by a given factor)

Additionally, if you wish to set the spacing for a specific chunk of content, there are four environments that you can specify using \begin and \end:

  • \begin{singlespace}
  • \begin{onehalfspace}
  • \begin{doublespace}
  • \begin{spacing}{«len»}
These are course notes for the University of Waterloo's course Math 600: Mathematical Software.
© 2012—. Written and developed by David Pritchard and Stephen Tosh. Contact (goes to the CEMC)