Quick Reference 

latex 

Run 

For file txfl.tex

latex to dvi
  latex txfl
view dvi
  xdvi txfl
dvi to postscript
  dvips txfl           to printer
  dvips txfl -o        to file: txfl.ps
view postscript
  gv txfl.ps
  imagetool txfl.ps

Barebone Latex file 

Example 1. Barebone Latex file

\documentclass[11pt]{article}

% Preamble

\begin{document}

%body

\end{document}

font 

*References*: [ASI] $2.1, p10.

Emphasising & Decorating 

In printed books, words are emphasized by typesetting them in an italic font,

around the edges by using \fbox instead. (More on framing in $6, p. 81.) The

vary the font style 

This is \textbf{boldface}.
This is \textit{italic}.
This is \textrm{roman}.
This is \textsc{small caps}.
This is \textsf{sans serif}.
This is \textsl{slanted}.
This is \texttt{typewriter}.

Some combinations of font styles can be produced. For example,

\textbf{\textit{bolditalic}}

\bf, \textbf and \bfseries 

> All the books I read (quite limited though :->) use \textbf for
> bolding, but I also see people use \bf.

\bf was borrowed from plain TeX and is now obsolete in LaTeX2e and should not be used.

> The recommended syntax is \textbf{stuff} unless the stuff
> is very long, in which case {\bfseries stuff} is better
> because TeX won't fill up your memory looking for the }
> of the argument.

More or less. {bfseries …} also works a bit more quickly and therefore has two reasons to be preferred by class and package writers

Vary the font size 

tex:sizes 

\tiny, \scriptsize, \footnotesize, or \small. \normalsize, \large, \Large, \LARGE, \huge or \Huge.

Molly Alene Edmonds

Help 

You can make the text {large large} or {Large larger} or even {LARGE larger still}. You can also make it {huge huge}. You might want to make something {small small} or {footnotesize smaller} or even {scriptsize smaller still}. You can make it really {tiny tiny}.

Dealing with large block of texts 

The use of braces to enclose a font size specification is like an environment. Optionally, we can explicitly use the environment syntax: environment syntax is useful when you want to keep the size for a large block of text, and the braces format is useful for short phrases.

There is no intrinsic environment for font styles.

Justifications 

flushleft and flushright 

The flushleft environment allows you to create a paragraph consisting of lines that are flushed left to the left-hand margin. Each line must be terminated with a \\.

\begin{flushleft}
Text on line 1 \\
Text on line 2 \\
....
....
\end{flushleft}

Same for flushright.

\raggedright 

This declaration corresponds to the flushleft environment. This declaration can be used inside an environment such as quote or in a parbox.

Unlike the flushleft environment, the \raggedright command does not start a new paragraph; it simply changes how LaTeX formats paragraph units. To affect a paragraph unit's format, the scope of the declaration must contain the blank line or \end command (of an environment like quote) that ends the paragraph unit.

Same for \raggedleft.

Centering 

To center the text/graphics, put them inside a center environment

\begin{center}
text
\includegraphics[width=2in]{graphic.eps}
\end{center}

If the \includegraphics command is inside an environment (such as minipage or figure), the \centering declaration centers the remaining output of the environment. For example

\begin{figure}
\centering
\includegraphics[width=2in]{graphic.eps}
\end{figure}

is similar to

\begin{figure}
\begin{center}
\includegraphics[width=2in]{graphic.eps}
\end{center}
\end{figure}

double vertical space above and below the figure due to the space produced by the figure environment and by the center environment. If extra vertical space is desired, the commands in Section 18.1 should be used.

horizontal spacing 

\hspace 

\hspace[*]{len}

The \hspace command adds horizontal space. The length of the space len can be expressed in any terms that LaTeX understands, i.e., points, inches, etc. You can add negative as well as positive space with an \hspace command. Adding negative space is like backspacing.

LaTeX removes horizontal space that comes at the end of a line. If you don't want LaTeX to remove this space, include the optional * argument. Then the space is never removed.

\hfill 

The \hfill fill command produces a rubber length which can stretch or shrink horizontally. It will be filled with spaces. It is equivalent to \hspace\fill.

vertical spacing 

line spacing 

\usepackage{setspace}
\singlespacing
\onehalfspacing
\doublespacing
more specific 
\begin{spacing}{1.2}
\end{spacing}
help 

The easiest way to control line spacing throughout your document is to specify

\singlespacing \onehalfspacing \doublespacing Right after you specify one of these, that spacing will commence.

extra spacing 

\linebreak
\smallskip
\medskip
\bigskip
\vspace{length}
\vspace{\stretch{1}} % to last line of the page

*References*: [ASI] $2.1, p12. $2.6, p26.

Line and Page Breaks 

Page break 

cmd:\newpage

or better:

\vfill\eject

if \footnote is a concern.

Help 

You can cause a new line by entering \linebreak. When text is justified (the default), this could result in an undesirable appearance, like the following:

\textsf{This example is \linebreak extreme.}

The \newline command forces a new line without justifying it.

\textsf{Here is the extreme \newline example.}

The \nolinebreak command works analogously, preventing a line break, even if it means extending into the right margin.

There are two commands to force a page break: \pagebreak and \newpage. The \newpage command follows the analogy with \newline in forcing a page break precisely at the point it is specified, rather than completing the line as \pagebreak does. The \nopagebreak command disallows a page break immediately following the next blank line. The \samepage command prevents a page break within its scope. Here is an example that keeps line 1 on the same page as line 2.

Lists 

There are three intrinsic list environments, distinguished by what appears at the beginning of each item: number, bullet, or your description (perhaps nothing).

itemize 

\begin{itemize}
\item This is item 1 and our task has just begun. Blank lines
      before an item have no effect.
\item This is item 2 and we shall limit to just this few.
A blank line within an item does create a new paragraph, using the
indentation of the itemize environment.
\begin{itemize}
\item A second (nested) itemized list changes the bullet
  and indents another level.
\end{itemize}
\end{itemize}

enumerate 

\begin{enumerate}
 \item This is item 1, and we are having fun.
 \item This is item 2, and it's time to number anew.
 \begin{enumerate}
   \item Back to item 1, but we are not yet done.
   \item Two is new.
       \begin{enumerate}
       \item One again!
       \item Two (b) or knot 2b?
       \end{enumerate}
 \end{enumerate}
\end{enumerate}

description 

\begin{description}
\item [Basic Document Preparation.] Knowing how to setup ...
\item [Making Tables.] \LaTeX~ provides a means ...
\item [Bibliography.] Knowing how to create a bibliography ...
\item [Mathematics.] This is the power of \LaTeX~ and one ...
\item [Graphics.] This has progressed a great deal in the ...
\item [Other.] There are a great many things to learn ...
\end{description}

macro commands 

\newcommand{\lib}{\begin{itemize}}     % item list begin
\newcommand{\lie}{\end{itemize}}       % item list end
\newcommand{\leb}{\begin{enumerate}}   % enumerate list begin
\newcommand{\lee}{\end{enumerate}}     % enumerate list end
\newcommand{\ldb}{\begin{description}} % description list begin
\newcommand{\lde}{\end{description}}   % description list end

Quotation 

Commands 

\begin{quote}
short quotes, generally one short paragraph (as above), or a sequence of one
line quotes, separated by blank lines
\end{quote}
\begin{quotation}
``The indentation is the same as the quote, except the first line of each new
paragraph is indented.
\bigskip
``Next paragraph.''
\hfill --- Author
\end{quotation}

Help 

Now consider ways to indent a block of text. Here is an example using the

The quote environment is intended for short quotes, generally one short paragraph (as above), or a sequence of one line quotes, separated by blank lines. The quotation environment is used for long quotations, having more than one paragraph (separated by blank lines). The indentation is the same as the quote, except the first line of each new paragraph is indented. (Just as in the regular text, this can be overridden by the \noindent command.) Here is an

The quotes are by two pioneers of algorithms, Alan M. Turing and Donald E. Knuth. Their names appear on the right, after their quote, by skipping a line and entering \hfill (which means horizontal fill), to make the line flush right. Here are some other things to notice about this example:

  • The dash that appears before each name is created by three minus signs, ---. The more minus signs you use, the longer the dash. The convention is that one dash is for hyphenation, two are for ranges, such as page numbers, and three are for punctuation — i.e., use --- preceding 'i.e.'
  • There is extra space between the two quotations. This was done with the \bigskip command.

Math mode 

*Tags*: expressions

Inline 

$ ... $

math display mode 

\[
...
\]
[Note]

NO empty line between \[ and \] allowed!

\[
(L_i < R_j < R_i) \iif  \mbox{$i$ is the ancestor of $j$}
\]

Numbered expressions 

Use 'equation' environment.

s|\\\[|\\begin{equation}|
s|\\]|\\end{equation}|

Help 

One can write mathematical expressions by entering math mode, signified by delimiters $ … $ or \[ … \]. The $ delimiter keeps the mathematical expression in the text, like this:

A consequence of Einstein's postulates is that $E = mc^2$.

The other form is math display mode, like this:

A consequence of Einstein's postulates is that \[E = mc^2.\])

Reference & Crossreference 

*References*: [ASI] s4, p43.

Basic Concepts 

A counter is a numerical value that refers to something that is being numbered, such as pages, sections, figures, and equations. A label is the identification of a particular value, and a reference is a citation to a the counter's value is set, where label is unique in the document. The LATEX defined:

\section{Bibliography with \Bibtex} \label{sec:Bibliography}

arbitrary, except do not use LATEX special characters or blanks, just as the labels in the bib file entries.

There are times when you just want to produce the counter value, without a label. This is done by \thecounter. For example, \thepage produces the page number. On the other hand, if you want to use the counter's numerical value as

Current Reference 

\thepage, \thesubsection \thesection
help 

You are looking at page 44, which I was able to print by writing \thepage. Similarly, you are reading subsection 4.2 of section 4, whose numbers I could write by \thesubsection and \thesection, respectively.

Crossreference 

define 
\subsection{The bib File} \label{subsec:bibfile}
\subsubsection{Web citations} \label{subsubsec:webcite}

To illustrate how I can reference other parts of this document, the above labels were defined (when the subsection and subsubsection were first written):

ref 

Then, I can refer to these as follows:

\S\ref{subsec:bibfile} => $3.2
\S\ref{subsubsec:webcite} => $3.2.2

I can also refer to their page numbers:

p.~\pageref{subsubsec:webcite} => p. 36
p.~\pageref{subsec:bibfile} => p. 31
help 

used to have a space without a linebreak, which is an element of good style.)

No leading space for short line: 

\begin{flushleft}
Dear Sir or Madam,
\end{flushleft}

No leading space for short line: 

You can also suppress indentation of the first line of a paragraph with the \noindent command. Here is an example:

\noindent This paragraph is not indented.

No leading space for short line: 

*Tags*: latex left margin

To suppress indentation of the first lines of all the paragraphs, use

\setlength{\parindent}{0pt}

Related command:

\setlength{\parskip}{9pt}

documented on: 2001.02.25