LaTEX for the terrified

John Butler

June 3, 1994

1 Introduction

LaTEX is daunting at first sight. In practice knowledge of a small subset of LaTEX plus a couple of editable examples will at least enable one to get started. Once the initial barrier has been overcome, other documents will do the rest.

This note is a commentary on its own LaTEX source text which is used as an example.

If you don’t have a copy of this document’s source text, list one off now. See section 2.7 for details on how to do this.

2 How to produce a document like this

2.1 Producing a document with LaTEX

This is a three-stage process:

1. Edit the source

2. Use LaTEX to produce a .DVI file

3. Preview it, and when satisfied with the result print it

2.2 Editing the LaTEX source

This note assumes that your document comprises

• A title • Paragraphs of text

• Itemised lists (like this)

• Tabulated columns

• Some hierarchy of sections, subsections and so on.

• A few odd characters like &, %, >

2.2.1 Commands

LaTEX commands are usually preceded by a back-slash and may have parameters in curly or square brackets.

2.3 The document header and trailer

This document is in article style, A4, 12 point. The first line of the header says this. There are numerous other styles. The next line begins the document and the last line of the document is a matching end.

2.3.1 The title

LaTEX has a set of constructs for generating document titles.

You will see that this document sets up an Author, Title and Date then instructs LaTEX to use them to generate a title. The date is optional. Author and title are not.

2.3.2 Paragraphs of text

If you supply TEX with text it will assume that blank lines delimit paragraphs.

TEX will indent paragraphs by about 3 spaces and leave no space between them unless you tell it otherwise. I personally don’t like that so I use:

\parskip .1in   % to set the paragraph separation to 1/10 inch.
\parindent 0in  % to set the paragraph indentation to be zero.

2.3.3 Itemised lists

LaTEX provides three rather nice itemisation commands. You’ve seen one above. The structure is pretty apparent if you examine the source. Note the begin and end and that itemize is spelt with a Z. Items may be nested.

The other two are enumeration which looks like this

1. This is item one – LaTEX will do the sensible thing if this item extends beyond one line.

2. This is a short item.

and description.

itemization produces unnumbered items with bullets

enumeration produces numbered items

description produces a list of items with the keyword or words highlighted, like this.

2.3.4 Tabulation

Table 1 shows how tables can be done in LaTEX.

1987 Apple Mac+/ext drive (AT #1) F528173M0001WP
1987 Apple Mac+/ext drive (AT #2) F52140MM0001WP
1987 Apple Mac+/ext drive (AT #3) F5213CJM0001WP
1987 Apple Mac+/ext drive (AT #4) F52137VM0001WP
1987 Apple Mac+ (AT #5)  C7350HKM0001AP
1987 Apple Mac+ (AT #6)  C7350EMM0001AP

Table 1: Macintosh serial numbers

If you look at the source you’ll see how it is done. The braces at the start of the tabular environment contain letters which indicate whether each column is left aligned, right aligned, or centred. Each column in a row is separated by the & character.

Note the double backslashes. LaTEX always uses double backslash as a newline instruction. Usually it is not required but LaTEX is much more fussy in tabular and other equivalent environments, and the line breaks must be supplied explicitly here.

Horizontal lines can be inserted between rows by putting \hline after the double backslash, and vertical lines can be inserted between columns by putting | between the letters in the braces after \begin{tabular}.

2.4 Verbatim text

It is often necessary to include program fragments, scripts or other text where a fixed pitch font is needed and the original spacing has to be retained. Do this with the verbatim environment. Example:

**************************************
* Push an item onto a circular queue *
**************************************
type
  ptr = ^qf;
  qf = record
          link: ptr;
          data: integer
  end;
procedure push(q,new: ptr);
begin
   if q = nil then begin
      q := new;
      new^.link := new
   end else begin
      new^.link := q^.link;
      q^.link := new;
      q := new
   end
end;  {of Push}

2.4.1 Sectioning

You can see the section/subsection/subsubsection constructs in the source. You can suppress the section numbers by putting an asterisk in front of the curly bracket.

An unnumbered sub-sub-section about odd characters

Some characters are difficult to produce in the normal text mode of LaTEX, such as α, β, ♭, ♯, ♣ and ♡. A good number of these are however available in the “math environment”. The math environment can be entered or left by the form \( … \), or the short form $ … $. Here is an example of math mode: ∑_{α=1}^{γ} x_{α} → ∫_{0}^{1} f(x′).

The displayed math environment is similar to the math environment, but puts the equation in a space of its own. The displayed math environment can be entered or left by the form \[ … \]:

∑_{α=1}^{γ} x_{α} → ∫_{0}^{1} f(x′)

.

There is a whole range of tools for producing formulæ.

2.5 Converting it to the intermediate DVI format

If your source document were called “noddy.tex”:

On Unix “latex noddy”

2.6 Previewing it

On Unix under “X” xdvi -s 2 -S 20 noddy

xdvi will then accept page numbers as input or “q” to exit. the -s parameter is a scaling command. -s 2 is about the smallest scale which fits completely on the screen. Each of the mouse buttons provides a magnifying glass of a different size.

It is important that documents are carefully previewed wherever possible before printing. Printing badly formatted documents is a totally avoidable waste of time and of about 2 KČ/page.

2.7 Printing or copying the source document

Start up xtn (if you are not already in it) and select the appropriate option. Originals may be found, in directory:- /packages/share/tex/doc.

Original latex file

\documentstyle[a4,12pt,verbatim]{article}
\begin{document}
%%% These lines are comments
%%% Changed by AJCD 23/11/89 to clean up bad bits...
%%%  Changed TeX to \TeX{}
%%%  Clarified what facilities provided by \LaTeX{} rather than \TeX{}
%%%  Removed spaces from around ties (~). Defeats purpose.
%%%  Changed hyphen to en-dash in example of enumeration; semi-colon would
%%%    probably be more correct.
%%%  Changed quoted control sequences to use \verb||
%%%  Changed ... to \ldots (ellipsis) in math mode explanation
%%%  Changed wording of parskip example to avoid overfull hbox and added
%%%    comment character in case anyone copies it verbatim. Note: the
%%%    paragraph separation should be specified in font units (e.g.~3ex).
%%%  AJCD 9/9/90:
%%%  Changed tabbing to tabular, and added table environment.
%%%  Changed bit about math mode to use a little more math.
%%%  Added verbatim mode to include itself
%%%  Altered printing info to new location and ordering of technotes
%%%  ddr 28/5/92
%%%  Updated for the environment at MU Brno, CZ
%%%  ps 03/06/94
%%%  End of comments
\author{John Butler}
\title{\LaTeX{} for the terrified  %ps \\ CS-TN-7
}
%ps %\date{3.\,6. 1994} % this would force given date
\maketitle
\parskip=0.1in
\section{Introduction}
\LaTeX{} is daunting at first sight. In practice knowledge of a small
subset of \LaTeX{} plus a couple of editable examples will at least
enable one to get started.  Once the initial barrier has been overcome,
other documents will do the rest.
This note is a commentary on its own \LaTeX{} source text which is
used as an example.
{\em If you don't have a copy of this document's source text, list one
off now.  See section~\ref{myreference} for details on how to do
this.}
%%% Note use of \em to emphasise.  Note also the planted reference. You
%%% have to run latex TWICE on the source to fill this reference with the
%%% correct section number.  (a bit like a compiler forward reference).
%%% There is a matching \label further on which MYREFERENCE refers to.

\section{How to produce a document like this}
\subsection{Producing a document with \LaTeX{}}
This is a three-stage process:
\begin{enumerate}
\item Edit the source
\item Use \LaTeX{} to produce a .DVI file
\item Preview it, and {\em when satisfied with the result\/} print it
%%% The italic correction \/ should be placed after each block of emphasised
%%% or italic text.
\end{enumerate}
\subsection{Editing the \LaTeX{} source}
This note assumes that your document comprises
\begin{itemize}
\item A title
\item Paragraphs of text
\item Itemised lists (like this)
\item Tabulated columns
\item Some hierarchy of sections, subsections and so on.
\item A few odd characters like \&, \%, $>$
\end{itemize}
\subsubsection{Commands}
\LaTeX{} commands are usually preceded by a back-slash and may have parameters
in curly or square brackets.
\subsection{The document header and trailer}
This document is in article style, A4, 12 point.  The first line of
the header says this. There are numerous other styles.  The next line
begins the document and the last line of the document is a matching
end.
\subsubsection{The title}
\LaTeX{} has a set of constructs for generating document titles.
You will see that this document sets up an Author, Title and Date then
instructs \LaTeX{} to use them to generate a title. The date is
optional.  Author and title are not.
\subsubsection{Paragraphs of text}
If you supply \TeX{} with text it will assume that blank lines delimit
paragraphs.

\TeX{} will indent paragraphs by about 3 spaces and leave no space between
them unless you tell it otherwise. I personally don't like that so I use:
\begin{verbatim}
\parskip .1in   % to set the paragraph separation to 1/10 inch.
\parindent 0in  % to set the paragraph indentation to be zero.
\end{verbatim}
\subsubsection{Itemised lists}
\LaTeX{} provides three rather nice itemisation commands.  You've seen
one above.  The structure is pretty apparent if you examine the
source.  Note the begin and end and that itemize is spelt with a Z\@.
Items may be nested.
%%% Note the use of \@ before above the full stop above. LaTeX normally thinks
%%% that capital letters followed by full stops are abbreviations, and puts a
%%% smaller space after them. The \@ tells LaTeX that the full stop is the end
%%% of a sentence.
The other two are {\em enumeration\/} which looks like this
\begin{enumerate}
\item This is item one -- \LaTeX{} will do the sensible thing if this item
extends beyond one line.
\item This is a short item.
\end{enumerate}
and {\em description\/}.
\begin{description}
\item[itemization] produces unnumbered items with bullets
\item[enumeration] produces numbered items
\item[description] produces a list of items with the keyword or words
highlighted, like this.
\end{description}
\subsubsection{Tabulation}
Table~\ref{mactable} shows how tables can be done in \LaTeX.
%%% This is a floating table; it may not appear exactly here in the output. I
%%% want it to be as close to here as possible, but it can appear at the
%%% bottom of the page, or the top of the next page, so I use the
%%% specification [hbt].
\begin{table}[hbt]%
\centering
\begin{tabular}{llll} % This table has four left-justified columns.
1987 & Apple & Mac+/ext drive (AT  \#1) & F528173M0001WP \\
1987 & Apple & Mac+/ext drive (AT  \#2) & F52140MM0001WP \\
1987 & Apple & Mac+/ext drive (AT  \#3) & F5213CJM0001WP \\
1987 & Apple & Mac+/ext drive (AT  \#4) & F52137VM0001WP \\

1987 & Apple & Mac+ (AT  \#5) &           C7350HKM0001AP \\
1987 & Apple & Mac+ (AT  \#6) &           C7350EMM0001AP \\
\end{tabular}
\caption{Macintosh serial numbers}\label{mactable}
\end{table}
If you look at the source you'll see how it is done. The braces at the
start of the tabular environment contain letters which indicate
whether each column is left aligned, right aligned, or centred.  Each
column in a row is separated by the \& character.
Note the double backslashes.  \LaTeX{} always uses double backslash as
a newline instruction. Usually it is not required but \LaTeX{} is much
more fussy in tabular and other equivalent environments, and the line
breaks {\em must\/} be supplied explicitly here.
Horizontal lines can be inserted between rows by putting \verb|\hline|
after the double backslash, and vertical lines can be inserted between
columns by putting \verb+|+ between the letters in the braces after
\verb|\begin{tabular}|.
%%% Note how we used \verb|...| or \verb+|+ above to delimit a verbatim
%%% sequence.
\subsection{Verbatim text}
It is often necessary to include program fragments, scripts or other
text where a fixed pitch font is needed and the original spacing has
to be retained.  Do this with the {\em verbatim\/} environment.
Example:
\begin{verbatim}
**************************************
* Push an item onto a circular queue *
**************************************
type
  ptr = ^qf;
  qf = record
          link: ptr;
          data: integer
  end;
procedure push(q,new: ptr);
begin
   if q = nil then begin
      q := new;
      new^.link := new
   end else begin
      new^.link := q^.link;
      q^.link := new;
      q := new

   end
end;  {of Push}
\end{verbatim}
\subsubsection{Sectioning}
You can see the section/subsection/subsubsection constructs in the
source. You can suppress the section numbers by putting an asterisk in
front of the curly bracket.
\subsubsection*{An unnumbered sub-sub-section about odd characters}
Some characters are difficult to produce in the normal text mode of
\LaTeX{}, such as $\alpha$, $\beta$, $\flat$, $\sharp$, $\clubsuit$
and $\heartsuit$.  A good number of these are however available in the
``math environment''.  The math environment can be entered or left by
the form \verb+\(+\,\ldots\verb+\)+, or the short form \$\,\ldots\$.
Here is an example of math mode:
\(\sum_{\alpha=1}^{\gamma} x_{\alpha} \rightarrow \int_{0}^{1} f(x\prime)\).
%%% Note the ``thin space'' \, in the previous paragraph; this improves the
%%% appearance of these constructs. Also not the double quotes; the left quote
%%% is set with ``, and the right quote with ''.
The displayed math environment is similar to the math environment, but
puts the equation in a space of its own. The displayed math
environment can be entered or left by the form
\verb+\[+\,\ldots\verb+\]+:
\[\sum_{\alpha=1}^{\gamma} x_{\alpha} \rightarrow \int_{0}^{1} f(x\prime)\].
There is a whole range of tools for producing
formul\ae. %%% Note the dipthong here
\subsection{Converting it to the intermediate DVI format}
If your source document were called ``noddy.tex'':
\begin{description}
\item[On Unix] ``latex noddy''
\end{description}
\subsection{Previewing it}
\begin{description}
\item[On Unix under ``X''] xdvi -s 2 -S 20 noddy
\end{description}
xdvi will then accept page numbers as input or ``q'' to exit.  the
\verb|-s| parameter is a scaling command. \verb|-s 2| is about the
smallest scale which fits completely on the screen.  Each of the mouse
buttons provides a magnifying glass of a different size.

It is important that documents are carefully previewed wherever
possible before printing.  Printing badly formatted documents is a
totally avoidable waste of time and of about 2~K\v{C}/page.
\subsection{Printing or copying the source document} \label{myreference}
Start up xtn (if you are not already in it) and select the appropriate
option.  Originals may be found, in directory:-\\
/packages/share/tex/doc.
\newpage
\begin{Large}
\begin{center}
{\bf Original latex file}
\end{center}
\end{Large}
{\footnotesize\verbatiminput{terrified.tex}}
\subsection{Printing it}
To print it at the printer at secretary office (LaserJet4),
\begin{verbatim}
dvips -Plj4 -oterrified.ps /packages/share/tex/doc/terrified.dvi
lp -d lj4 terrified.ps
\end{verbatim}
\end{document}

2.8 Printing it

To print it at the printer at secretary office (LaserJet4),

dvips -Plj4 -oterrified.ps /packages/share/tex/doc/terrified.dvi
lp -d lj4 terrified.ps