Sample LaTeX file

The name of this file is texintro.tex.
\documentclass[10pt,oneside]{article}
\usepackage{color,graphics}
\usepackage{verbatim}
\usepackage{amsmath}    % need for subequations

\setlength{\baselineskip}{16.0pt}    % 16 pt usual spacing between lines
\begin{comment}
\pagestyle{empty} % use if do not want page numbers
\end{comment}

\begin{document}

\begin{center}
Introduction to \LaTeX \\   % \\ = new line
Harvey Gould \\
January 30, 2001
\end{center}

\section{Introduction}
\TeX\ (a special symbol) looks more difficult than it
really 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
subscripts
$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.

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

The default font is Computer Modern. It includes \textit{italics}
or {\it italics}, \textbf{boldface} or {\bf boldface},
\textsl{slanted} or {\sl slanted}, and \texttt{monospaced} or {\tt
monospaced} (typewriter) fonts.

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

We can give an equation a label so that we can refer to it
later.
\begin{equation}
E = -J \sum_{i=1}^N s_i s_{i+1} , \label{eq:ising}
\end{equation}
Equation~(\ref{eq:ising}) expresses the energy of a configuration
of spins.\footnote{It is necessary to process 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:
\begin{verbatim}
 \newcommand{\lb}{{\langle}}
 \newcommand{\rb}{{\rangle}}
\end{verbatim}
\newcommand{\lb}{{\langle}}
\newcommand{\rb}{{\rangle}}
Then we can write the average value of $x$ as
\begin{verbatim}
\begin{equation}
\lb x \rb = 3
\end{equation}
\end{verbatim}
The result is
\begin{equation}
\lb x \rb = 3 .
\end{equation}

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

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

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

\section{Tables}
Tables are a little more difficult until you get the knack. TeX
automatically calculates the width of the columns.

\begin{table}[h]
\begin{center}
\begin{tabular}{|l|l|r|l|}
\hline
lattice & $d$ & $q$ & $T_{\rm mf}/T_c$ \\
\hline
square & 2 & 4 & 1.763 \\
\hline
triangular & 2 & 6 & 1.648 \\
\hline
diamond & 3 & 4 & 1.479 \\
\hline
simple cubic & 3 & 6 & 1.330 \\
\hline
bcc & 3 & 8 & 1.260 \\
\hline
fcc & 3 & 12 & 1.225 \\
\hline
\end{tabular}
\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.}
\end{center}
\end{table}

\section{Lists}

Some example of formatted lists include the
following:

\begin{enumerate}

\item bread

\item cheese

\end{enumerate}

\begin{itemize}

\item Tom

\item Dick

\end{itemize}

\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:
\begin{verbatim}
   public void computeArea()
   {
      this.area = this.length*this.length;
      System.out.println("Area = " + this.area);
   }
\end{verbatim}
The command \verb {\verbatiminput{programs/Square.java}} \
will allow you to list the file Square.java in the directory
programs.
\section{Special Symbols}

\subsection{Common Greek letters}

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

$\alpha, 
\beta, \gamma, \Gamma,
\delta,\Delta,
\epsilon, \zeta, \eta, \theta, \Theta, \kappa,
\lambda, \Lambda, \mu, \nu,
\xi, \Xi,
\pi, \Pi,
\rho,
\sigma, 
\tau,
\phi, \Phi,
\chi,
\psi, \Psi,
\omega, \Omega$

\subsection{Special symbols}

The derivative is defined as
\begin{equation}
{dy \over dx} = \lim_{\Delta x \to 0}{\Delta y
\over
\Delta x}
\end{equation}
\begin{equation}
f(x) \to y \quad {\rm as} \quad x \to
x_{0}
\end{equation}
\begin{equation}
f(x) \mathop {\longrightarrow}
\limits_{x \to x_0} y
\end{equation}

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

Finally we can skip some space by using a command such as
\begin{verbatim}
\bigskip    \medskip    \smallskip
\vspace{space}
\end{verbatim}
The space can be negative.

\section{Figures}

Figure~\ref{fig:typical} is an eps file.
\begin{figure}[h]
\begin{center}
\includegraphics{figures/sine.eps}
\caption{\label{fig:typical}Show me a sine.}
\end{center}
\end{figure}

\section{References}

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

\end{document}