LaTeX Typesetting – Basics

November 28th, 2010

The LaTeX typesetting is used to create professional looking documents on a home computer. It may have a steeper learning curve than using a Word Processor, but this initial effort will often pay off reasonably quickly. The system is almost a necessity for anyone writing documents with a large amount of mathematics as most alternatives are painful to use efficiently.


Fast Tube by Casper

In a LaTeX document we need to specify a class, which is a file that defines the formatting styles applied to a document. The standard classes available include article, book, letter and custom classes can be defined to create different visual styles for a LaTeX document.

At the top of the document we use the \documentclass command to specify the class to use for the document. For an article we would have:

\documentclass{article}

The preamble after this command and before the main body of the document can be used to include other packages, define environments or various other actions. The body of the document is included within these commands:

\begin{document}
...
\end{document}

It is straightforward to include title information in the document by specifying an author, title and date then followed by a \maketitle command. Note that note all of these are compulsory for a document. A simple example of creating a title:

\title{Using R}
\author{An R Fanatic}
\maketitle

We write the text of our LaTeX document as we would a basic text document and then add commands where we want to make changes to the appearance of text. For example we might want to emphasise some of the text using the \emph:

The \emph{assumptions} underlying the choice of model need to be investigated.

There are a few special symbols worth being aware of when creating LaTeX documents:

  • Percentages need to be specified as \%, otherwise they will be confused as meaning a comment so will be ignored.
  • Curly brackets are special characters so you need to write \{ and \} if you want to use them in the text.
  • Hash (#), dollar ($) and ampersand (&) are all also special characters.

To align a block of text the center, flushright and flushleft environments can be used. Examples of using these:

\begin{center}
Text is centred.
\end{center}
 
\begin{flushright}
Text is flush right.
\end{flushright}
 
\begin{flushleft}
Text is flush left.
\end{flushleft}

The size of the font can be changed using various declarations, which include \small, \normalsize, \large, \Large and \LARGE.

Useful software for working with LaTeX includes:

Other useful resources are provided on the Supplementary Material page. A google search will also through up a large number of good online resources for LaTeX.

Comments are closed.