1 % http://sip.clarku.edu/tutorials/TeX/intro.html
2 \documentclass[12pt
]{article
}
4 \usepackage{amsmath
} % need for subequations
5 \usepackage{graphicx} % need for figures
6 \usepackage{verbatim
} % useful for program listings
7 \usepackage{color} % use if color is used in text
8 \usepackage{subfigure
} % use for side-by-side figures
9 \usepackage{hyperref
} % use for hypertext links, including those to external documents and URLs
11 % don't need the following. simply use defaults
12 \setlength{\baselineskip}{16.0pt
} % 16 pt usual spacing between lines
14 \setlength{\parskip}{3pt plus
2pt
}
15 \setlength{\parindent}{20pt
}
16 \setlength{\oddsidemargin}{0.5cm
}
17 \setlength{\evensidemargin}{0.5cm
}
18 \setlength{\marginparsep}{0.75cm
}
19 \setlength{\marginparwidth}{2.5cm
}
20 \setlength{\marginparpush}{1.0cm
}
21 \setlength{\textwidth}{150mm
}
24 \pagestyle{empty
} % use if page numbers not wanted
27 % above is the preamble
32 {\large Introduction to
\LaTeX} \\
% \\ = new line
33 \copyright 2006 by Harvey Gould \\
37 \section{Introduction
}
38 \TeX\ looks more difficult than it is. It is
39 almost as easy as $
\pi$. See how easy it is to make special
40 symbols such as $
\alpha$,
42 $
\delta$, $
\sin x$, $
\hbar$, $
\lambda$, $
\ldots$ We also can make
44 $A_
{x
}$, $A_
{xy
}$ and superscripts, $e^x$, $e^
{x^
2}$, and
45 $e^
{a^b
}$. We will use
\LaTeX, which is based on
\TeX\ and has
46 many higher-level commands (macros) for formatting, making
47 tables, etc. More information can be found in Ref.~
\cite{latex
}.
49 We just made a new paragraph. Extra lines and spaces make no
50 difference. Note that all formulas are enclosed by
51 \$ and occur in
\textit{math mode
}.
53 The default font is Computer Modern. It includes
\textit{italics
},
55 \textsl{slanted
}, and
\texttt{monospaced
} fonts.
58 Let us see how easy it is to write equations.
60 \Delta =
\sum_{i=
1}^N w_i (x_i -
\bar{x
})^
2 .
62 It is a good idea to number equations, but we can have a
63 equation without a number by writing
65 P(x) =
\frac{x - a
}{b - a
} ,
\nonumber
69 g =
\frac{1}{2} \sqrt{2\pi} .
\nonumber
72 We can give an equation a label so that we can refer to it later.
75 E = -J
\sum_{i=
1}^N s_i s_
{i+
1} ,
77 Equation~
\eqref{eq:ising
} expresses the energy of a configuration
78 of spins in the Ising model.
\footnote{It is necessary to process (typeset) a
79 file twice to get the counters correct.
}
81 We can define our own macros to save typing. For example, suppose
82 that we introduce the macros:
84 \newcommand{\lb}{{\langle}}
85 \newcommand{\rb}{{\rangle}}
87 \newcommand{\lb}{{\langle}}
88 \newcommand{\rb}{{\rangle}}
89 Then we can write the average value of $x$ as
100 Examples of more complicated equations:
102 I = \!
\int_{-
\infty}^
\infty f(x)\,dx
\label{eq:fine
}.
104 We can do some fine tuning by adding small amounts of horizontal
107 \, small space \! negative space
109 as is done in Eq.~
\eqref{eq:fine
}.
111 We also can align several equations:
116 or number them as subequations:
124 We can also have different cases:
129 0 &
\text{$T > T_c$
} \\
130 \bigl(
1 -
[\sinh 2 \beta J
]^
{-
4} \bigr)^
{\!
1/
8} &
\text{$T < T_c$
}
137 T_
{++
} \hfill & T_
{+-
} \\
138 T_
{-+
} & T_
{--
} \hfill
139 \end{pmatrix
} ,
\nonumber \\
142 e^
{\beta (J + B)
} \hfill & e^
{-
\beta J
} \hfill \\
143 e^
{-
\beta J
} \hfill & e^
{\beta (J - B)
} \hfill
147 \newcommand{\rv}{\textbf{r
}}
149 \sum_i \vec A
\cdot \vec B = -P\!
\int\!
\rv \cdot
150 \hat{\mathbf{n
}}\, dA = P\!
\int \!
{\vec \nabla} \cdot \rv\, dV.
154 Tables are a little more difficult. TeX
155 automatically calculates the width of the columns.
159 \begin{tabular
}{|l|l|r|l|
}
161 lattice & $d$ & $q$ & $T_
{\rm mf
}/T_c$ \\
163 square &
2 &
4 &
1.763 \\
165 triangular &
2 &
6 &
1.648 \\
167 diamond &
3 &
4 &
1.479 \\
169 simple cubic &
3 &
6 &
1.330 \\
171 bcc &
3 &
8 &
1.260 \\
173 fcc &
3 &
12 &
1.225 \\
176 \caption{\label{tab:
5/tc
}Comparison of the mean-field predictions
177 for the critical temperature of the Ising model with exact results
178 and the best known estimates for different spatial dimensions $d$
179 and lattice symmetries.
}
185 Some example of formatted lists include the
206 We can make figures bigger or smaller by scaling them. Figure~
\ref{fig:lj
}
207 has been scaled by
60\%.
211 \includegraphics{figures/sine
}
212 \caption{\label{fig:typical
}Show me a sine.
}
218 \scalebox{0.6}{\includegraphics{figures/lj
}}
219 \caption{\label{fig:lj
}Plot of the
220 Lennard-Jones potential
221 $u(r)$. The potential is characterized by a length
222 $
\sigma$ and an energy
227 \section{Literal text
}
228 It is desirable to print program code exactly as it is typed in a
229 monospaced font. Use
\verb \begin{verbatim
} and
230 \verb \end{verbatim
} as in the following example:
232 double y0 =
10; // example of declaration and assignment statement
233 double v0 =
0; // initial velocity
234 double t =
0; // time
235 double dt =
0.01; // time step
238 The command
\verb \verbatiminput{programs/Square.java
}\ allows
239 you to list the file
\texttt{Square.java
} in the directory
242 \section{Special Symbols
}
244 \subsection{Common Greek letters
}
246 These commands may be used only in math mode. Only the most common
247 letters are included here.
250 \beta,
\gamma,
\Gamma,
252 \epsilon,
\zeta,
\eta,
\theta,
\Theta,
\kappa,
253 \lambda,
\Lambda,
\mu,
\nu,
264 \subsection{Special symbols
}
266 The derivative is defined as
268 \frac{dy
}{dx
} =
\lim_{\Delta x
\to 0} \frac{\Delta y
}
272 f(x)
\to y
\quad \mbox{as
} \quad x
\to
276 f(x)
\mathop {\longrightarrow}
277 \limits_{x
\to x_0
} y
280 \noindent Order of magnitude:
287 Approximate equality:
291 \LaTeX\ is simple if we keep everything in proportion:
296 Finally we can skip some space by using commands such as
298 \bigskip \medskip \smallskip \vspace{1pc
}
300 The space can be negative.
302 \section{\color{red
}Use of Color
}
304 {\color{blue
}{We can change colors for emphasis
}},
305 {\color{green
}{but
}} {\color{cyan
}{who is going pay for the ink?
}}
307 \section{\label{morefig
}Subfigures
}
309 As soon as many students start becoming comfortable using
\LaTeX, they want
310 to use some of its advanced features. So we now show how to place two
311 figures side by side.
315 \subfigure[Real and imaginary.
]{
316 \includegraphics[scale=
0.5]{figures/reim
}}
317 \subfigure[Amplitude and phase.
]{
318 \includegraphics[scale=
0.5]{figures/phase
}}
319 \caption{\label{fig:qm/complexfunctions
} Two representations of complex
324 We first have to include the necessary package,
325 \verb+
\usepackage{subfigure
}+, which has to go in the preamble (before
326 \verb+
\begin{document}+). It sometimes can be difficult to place a figure in
329 Your LaTeX
document can be easily modified to make a poster or a screen
330 presentation similar to (and better than) PowerPoint. Conversion to HTML is
331 straightforward. Comments on this tutorial are appreciated.
333 \begin{thebibliography
}{5}
335 \bibitem{latex
}Helmut Kopka and Patrick W. Daly,
\textsl{A Guide to
336 \LaTeX: Document Preparation for Beginners and Advanced Users
},
337 fourth edition, Addison-Wesley (
2004).
339 \bibitem{website
}Some useful links are
342 \end{thebibliography
}
344 {\small \noindent Updated
5 December
2006.
}