programmer LaTeX by example

Looking for a quick start guide to writing documents with LaTeX? Use this sample file as a template for your next technical documentation project.

LaTeX (more formally stylized as LATEX) is a popular document preparation system for scientific papers. To help technical writers learn how to use LaTeX for technical documents, I wanted to share this reference document.

This sample file includes many of the common formatting you are likely to encounter with LaTeX, including paragraphs, bold, italics, block quotes, footnotes, lists, and equations:


\title{\LaTeX\ by example}
\author{Jim Hall}

\LaTeX\ is a powerful and flexible document preparation system.
To write a document in \LaTeX, start a new text file with a
\texttt{.tex} extension in your favorite text editor. Use this
document as an example or guide.

%% this is a comment
%% I've used a "backslash" plus a space where I need to add a
%% literal space. For example, "\LaTeX" without it would get
%% attached to the word the follows it.
Insert an \emph{em} dash (---) with three hyphens
or an \emph{en} dash (--) with two hyphens.
You can also add ``quotes'' around text.
Start new paragraphs with a blank line.

If you need to add a block quote, you can do that too!\footnote{This
is a footnote.}
You can also add a footnote.\footnote{This is another footnote.}

Equations are easy with a little practice.
You can add inline equations like $ A = \pi r^2 $ for the area of
a circle.

To start a numbered equation, use an \texttt{equation} block.
Type \texttt{\^} to indicate superscripts
or \texttt{\_} for subscripts.
%% this is a comment
%% You can make print most special characters by adding a
%% backslash in front of it, like \^ and \_
You can also add fractions and other symbols:

x(t) = x_0 + v_0 t + \frac{1}{2} a t^2

An unnumbered equation follows the same rules as a numbered
equation, but you use \texttt{\$\$} before and after the

$$ \sum_{n=0}^{10} n = 55 $$

To add a bullet list, use the \texttt{itemize} list type and
add an \texttt{item} instruction before each item in the list.
For example, some common formatting:

\item \textbf{bold}
\item \emph{emphasis}
\item \textit{italics}
\item \textsc{Small Caps}

The steps are basically the same for numbered lists.
Use the \texttt{enumerate} list type and add an \texttt{item}
instruction to start each item in the list:

\item The first step
\item The next step
\item The last step


Save this to a new text file called sample.tex and process it with the LaTeX system with this command:

$ pdflatex sample.tex

The LaTeX system will print a lot of output to tell you what it is doing, then it will generate a PDF file called sample.pdf.

LaTeX sample output, page 1

sample.pdf, page 1 (image by Jim Hall; Creative Commons)

LaTeX sample output, page 2

sample.pdf, page 2 (image by Jim Hall; Creative Commons)

Use this sample file as a starting point for your next technical documentation project!

Download: sample.pdf