Note: LaTeX is in /usr/local/tex3.1415/bin/ on csgrad.cs.vt.edu (and, theoretically, also on sequoia).
LaTeX is a system to markup the conceptual structure (sections, lists, mathematics, ...) of documents. Listed below are some of its advantages over other systems to compose typeset documents, such as WYSIWYG (what-you-see-is-what-you-get) word processors.
1. Introduction
to
I. Introduction
throughout an entire document.
The sectioning commands are:
\section{}
\subsection{}
\subsubsection{}
\paragraph{}
By using these commands, LaTeX will:
In particular, do not use {\bf ...} or \textbf{} in preference to \paragraph{..}
Shown below is an example of section headings.
\section{The Animal Kingdom}
The animal kingdom consists of an awful lot of species. [Note that
the first paragraph in a section starts with no indentation.]
\subsection{The Cat Family}
The most familiar species in the animal kingdom is the cat family.
\subsubsection{The Domestic Cat Family}
Of all cats, the domestic cat is the most numerous.
\paragraph{The Siamese Cat} The Siamese cat is very vocal. [Note the
boldface lead-in in this paragraph.]
The corresponding typeset result is shown below.
To justify text (e.g., make the text line up on the left and right edges of a column of text), LaTeX uses an algorithm to break lines of text. This algorithm is designed to violate right justification rather than generate a line of text that has too much white space in it. When a violation occurs, LaTeX generates a warning message that refers to an overfull \hbox that is a certain number of points (1 inch=72 points) too long. Whenever you see a \hbox message, you should either (1) rewrite the lines listed in the warning message so that the message disappears, or (2) insert \- into places in a word where LaTeX could introduction hyphenation.
Here is an example of the LaTeX error overfull \hbox warning:
This is TeX, Version 3.1415 (C version 6.1) ... Overfull \hbox (13.14766pt too wide) in paragraph at lines 16--20 \OT1/cmr/m/it/10 ex-pi-alodoshioussupercalofragilisticexpialodoshioussupercalof ragilisticexpialodoshious [1] (longline.aux) ) ...
Shown below is an example of a .tex file with a line that is too long.
%Simple LaTeX Paper
% Following line makes document look like an article
\section*{Problem 1}
{\em When LaTeX encounters
supercalofragilisticexpialodoshioussupercalofragilisticexpialodoshioussupercalofragilisticexpialodoshioussupercalofragilisticexpialodoshious
it generates an error message that is rather cryptic. The typeset
output extends past the right edge of the margin, too.}
Answer: 3
In the typeset result, shown below, right margin justification is violated.
Shown below is an example of a figure. Note that the figure's number is automatically assigned by LaTeX.
The conditional statement is illustrated in Figure~\ref{fig:conditional}.
\begin{figure}
\tt \small
\begin{verbatim}
if
(x>0)
then
return x
else
return -x;
\end{verbatim}
\caption{Example of a conditional statement.}
\label{fig:conditional}
\end{figure}
\LaTeX\ will move the figure to a point not earlier than the page on
which the text preceeding the figure lies. Note that a backslash is
required after the macro call to \verb+\LaTeX+ in the preceeding
sentence.
The corresponding typeset result is shown below.
First add in the preamble of the LaTeX document
\usepackage{epsf}
Then simply use the \epsffile{<filename>} command to insert an eps file. An eps file contains a bounding box that defines its physical dimensions, and these are used by LaTeX to determine the space on a page to allocate to the figure. Here's an example (from Neill Kipp):
\begin{figure}
\epsffile{triangle.eps}
\caption{The triangle.}
\label{fig:triangle}
Shown below is an example of a table. There are many options for laying out a table; see Lamport's book for further details.
The first two talks in the 1995-96 graduate seminar series are shown
in Table~\ref{tab:mytable}.
\begin{table}
\begin{center}
\begin{tabular}{l|lp{2in}} \hline
{\em Date} & {\em Speaker} & {\em Talk Title}
\\ \hline
30 August & Bill Wake & SortTables: A Browser for at
Digital Library
\\
6 September & Kim Langdorf & Lost in Space? ---
Satellite Communications and Navigation
\\
\end{tabular}
\end{center}
\caption{Example of a simple \LaTeX\ table.}
\label{tab:mytable}
\end{table}
The corresponding typeset result is shown below. The table puts cells in the third column into left and right justified text boxes that are two inches wide.
Shown below is an example comparing display and in-line equations.
The following sum is a {\em display equation}:
\begin{equation}
%
\int_{-\infty}^\infty u \cos{u} \mbox{\em du} = \cos u + u \sin u
%
\end{equation}
The following is an in-line formula:
$\int_{-\infty}^\infty u \cos{u} \mbox{\em du} = \cos u + u \sin u$.
The corresponding typeset result is shown below.
Shown below are two examples of equations containing fractions.
\[
x = \frac {a+b+c/2} {\alpha_i}
\]
\[
x = \frac {x^{2y}} {\log{x+y}}
\]
The corresponding typeset results are shown below.
Shown below is an example of an equation containing an array.
\[
f(x) = \left\{
\begin{array}{ll}
a & \mbox{if $x<.0$}
\\
c & \mbox{otherwise}
\end{array} \right.
\]
The corresponding typeset result is shown below.
You can define a macro as a shorthand for common notation used throughout your document.
General form:
\newcommand{\macroname}{{definition}}
Make "macroname" descriptive. This makes it easy to change a construct and provides logical structure to the document.
Each occurrence of "\macroname" in your .tex file is replaced by "definition". Example:
\newcommand{\aij}{{\alpha^i_{j_1}}}
Isn't $\aij$ the most beautiful symbol you've ever seen?
Typeset result:
A command may also take arguments. Here's an example with four arguments:
\newcommand{\graph}[4]{$#1\begin{array}{c}#2 \\
-\!\!\!-\!\!\!-\!\!\!\longrightarrow \\ #3?\end{array}#4$}
Consider \graph{i}{t}{c}{i \oplus 1}.
Typeset result:
If you wish to use a theorem, lemma, or example, you probably want:
Use the "\newtheorem" command to do this!
General form:
\newthereom{name}{textToPrint}
Each occurrence of "\macroname" in your .tex file is replaced by "definition". Example:
\newtheorem{example}{Example}
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}
\begin{theorem}\label{th:CR}
The length of the hypotenuse of a right triangle is the square root of
the sum of the square of the sides.
\smallskip \noindent {\bf Proof:}
{\em Let the sides be denoted $a$ and $b$. Then ...
\hfill $\Box$}
%
\end{theorem} % after proof to get space between proof & following text
Typeset result: