Sample LaTeX file

The name of this file is intro.tex.

\usepackage{amsmath}    % need for subequations
\usepackage{graphicx}   % need for figures
\usepackage{verbatim}   % useful for program listings
\usepackage{color}      % use if color is used in text
\usepackage{subfigure}  % use for side-by-side figures
\usepackage{hyperref}   % use for hypertext links, including those to external documents and URLs

% don't need the following. simply use defaults
\setlength{\baselineskip}{16.0pt}    % 16 pt usual spacing between lines

\setlength{\parskip}{3pt plus 2pt}

\pagestyle{empty} % use if page numbers not wanted

% above is the preamble


{\large Introduction to \LaTeX} \\ % \\ = new line
\copyright 2006 by Harvey Gould \\
December 5, 2006

\TeX\ looks more difficult than it is. It is
almost as easy as $\pi$. See how easy it is to make special
symbols such as $\alpha$,
$\beta$, $\gamma$,
$\delta$, $\sin x$, $\hbar$, $\lambda$, $\ldots$ We also can make
$A_{x}$, $A_{xy}$ and superscripts, $e^x$, $e^{x^2}$, and
$e^{a^b}$. We will use \LaTeX, which is based on \TeX\ and has
many higher-level commands (macros) for formatting, making
tables, etc. More information can be found in Ref.~\cite{latex}.

We just made a new paragraph. Extra lines and spaces make no
difference. Note that all formulas are enclosed by
\$ and occur in \textit{math mode}.

The default font is Computer Modern. It includes \textit{italics},
\textsl{slanted}, and \texttt{monospaced} fonts.

Let us see how easy it is to write equations.
\Delta =\sum_{i=1}^N w_i (x_i - \bar{x})^2 .
It is a good idea to number equations, but we can have a
equation without a number by writing
P(x) = \frac{x - a}{b - a} , \nonumber
g = \frac{1}{2} \sqrt{2\pi} . \nonumber

We can give an equation a label so that we can refer to it later.
E = -J \sum_{i=1}^N s_i s_{i+1} ,
Equation~\eqref{eq:ising} expresses the energy of a configuration
of spins in the Ising model.\footnote{It is necessary to process (typeset) a
file twice to get the counters correct.}

We can define our own macros to save typing. For example, suppose
that we introduce the macros:
Then we can write the average value of $x$ as
\lb x \rb = 3
The result is
\lb x \rb = 3 .

Examples of more complicated equations:
I = \! \int_{-\infty}^\infty f(x)\,dx \label{eq:fine}.
We can do some fine tuning by adding small amounts of horizontal
 \, small space       \! negative space
as is done in Eq.~\eqref{eq:fine}.

We also can align several equations:
a & = b \\
c &= d ,
or number them as subequations:
a & = b \\
c &= d .

We can also have different cases:
m(T) =
0 & \text{$T > T_c$} \\
\bigl(1 - [\sinh 2 \beta J]^{-4} \bigr)^{\! 1/8} & \text{$T < T_c$}
write matrices
\textbf{T} &=
T_{++} \hfill & T_{+-} \\
T_{-+} & T_{--} \hfill 
\end{pmatrix} , \nonumber \\
& =
e^{\beta (J + B)} \hfill & e^{-\beta J} \hfill \\
e^{-\beta J} \hfill & e^{\beta (J - B)} \hfill
\sum_i \vec A \cdot \vec B = -P\!\int\! \rv \cdot
\hat{\mathbf{n}}\, dA = P\!\int \! {\vec \nabla} \cdot \rv\, dV.

Tables are a little more difficult. TeX
automatically calculates the width of the columns.

lattice & $d$ & $q$ & $T_{\rm mf}/T_c$ \\
square & 2 & 4 & 1.763 \\
triangular & 2 & 6 & 1.648 \\
diamond & 3 & 4 & 1.479 \\
simple cubic & 3 & 6 & 1.330 \\
bcc & 3 & 8 & 1.260 \\
fcc & 3 & 12 & 1.225 \\
\caption{\label{tab:5/tc}Comparison of the mean-field predictions
for the critical temperature of the Ising model with exact results
and the best known estimates for different spatial dimensions $d$
and lattice symmetries.}


Some example of formatted lists include the


\item bread

\item cheese



\item Tom

\item Dick



We can make figures bigger or smaller by scaling them. Figure~\ref{fig:lj}
has been scaled by 60\%.

\caption{\label{fig:typical}Show me a sine.}

\caption{\label{fig:lj}Plot of the
Lennard-Jones potential
$u(r)$. The potential is characterized by a length
$\sigma$ and an energy

\section{Literal text}
It is desirable to print program code exactly as it is typed in a
monospaced font. Use \verb \begin{verbatim} and
\verb \end{verbatim} as in the following example:
double y0 = 10; // example of declaration and assignment statement
double v0 = 0;  // initial velocity
double t = 0;   // time
double dt = 0.01; // time step
double y = y0;
The command \verb \verbatiminput{programs/}\ allows
you to list the file \texttt{} in the directory

\section{Special Symbols}

\subsection{Common Greek letters}

These commands may be used only in math mode. Only the most common
letters are included here.

\beta, \gamma, \Gamma,
\epsilon, \zeta, \eta, \theta, \Theta, \kappa,
\lambda, \Lambda, \mu, \nu,
\xi, \Xi,
\pi, \Pi,
\phi, \Phi,
\psi, \Psi,
\omega, \Omega$

\subsection{Special symbols}

The derivative is defined as
\frac{dy}{dx} = \lim_{\Delta x \to 0} \frac{\Delta y}
{\Delta x}
f(x) \to y \quad \mbox{as} \quad x \to
f(x) \mathop {\longrightarrow}
\limits_{x \to x_0} y

\noindent Order of magnitude:
\log_{10}f \simeq n
f(x)\sim 10^{n}
Approximate equality:
f(x)\simeq g(x)
\LaTeX\ is simple if we keep everything in proportion:
f(x) \propto x^3 .

Finally we can skip some space by using commands such as
\bigskip    \medskip    \smallskip    \vspace{1pc}
The space can be negative.

\section{\color{red}Use of Color}

{\color{blue}{We can change colors for emphasis}},
{\color{green}{but}} {\color{cyan}{who is going pay for the ink?}}


As soon as many students start becoming comfortable using \LaTeX, they want
to use some of its advanced features. So we now show how to place two
figures side by side.

\subfigure[Real and imaginary.]{
\subfigure[Amplitude and phase.]{
\caption{\label{fig:qm/complexfunctions} Two representations of complex
wave functions.}

We first have to include the necessary package,
\verb+\usepackage{subfigure}+, which has to go in the preamble (before
\verb+\begin{document}+). It sometimes can be difficult to place a figure in
the desired place.

Your LaTeX document can be easily modified to make a poster or a screen
presentation similar to (and better than) PowerPoint. Conversion to HTML is
straightforward. Comments on this tutorial are appreciated.


\bibitem{latex}Helmut Kopka and Patrick W. Daly, \textsl{A Guide to
\LaTeX: Document Preparation for Beginners and Advanced Users},
fourth edition, Addison-Wesley (2004).

\bibitem{website}Some useful links are
given at \url{}.


{\small \noindent Updated 5 December 2006.}
Updated 6 February 2006.