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:

\documentclass{article}
\begin{document}

\title{\LaTeX\ by example}
\author{Jim Hall}
\date{\today}
\maketitle

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

\begin{quotation}
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.}
\end{quotation}

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:

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

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

$$ \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:

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

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:

\begin{enumerate}
\item The first step
\item The next step
\item The last step
\end{enumerate}

\end{document}

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