Introduction to LATEX
©2006 by Harvey Gould
December 5, 2006

### 1 Introduction

TEX looks more diﬃcult 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$, $sinx$, $\hslash$, $\lambda$, $\dots$ 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. More information can be found in Ref. [1].

We just made a new paragraph. Extra lines and spaces make no diﬀerence. Note that all formulas are enclosed by \$ and occur in math mode.

The default font is Computer Modern. It includes italics, boldface, slanted, and monospaced fonts.

### 2 Equations

Let us see how easy it is to write equations.

 $\Delta =\sum _{i=1}^{N}{w}_{i}{\left({x}_{i}-\stackrel{̄}{x}\right)}^{2}.$ (1)

It is a good idea to number equations, but we can have a equation without a number by writing

 $P\left(x\right)=\frac{x-a}{b-a},$

and

 $g=\frac{1}{2}\sqrt{2\pi }.$

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},$ (2)

Equation (2) expresses the energy of a conﬁguration of spins in the Ising model.1

We can deﬁne our own macros to save typing. For example, suppose that we introduce the macros:

\newcommand{\lb}{{\langle}}
\newcommand{\rb}{{\rangle}}

Then we can write the average value of $x$ as

\lb x \rb = 3

The result is

 $⟨x⟩=3.$ (3)

Examples of more complicated equations:

 $I=\phantom{\rule{0em}{0ex}}{\int }_{-\infty }^{\infty }f\left(x\right)\phantom{\rule{0em}{0ex}}dx.$ (4)

We can do some ﬁne tuning by adding small amounts of horizontal spacing:

\, small space       \! negative space

as is done in Eq. (4).

We also can align several equations:

$\begin{array}{lll}\hfill a& =b\phantom{\rule{2em}{0ex}}& \hfill \text{(5)}\\ \hfill c& =d,\phantom{\rule{2em}{0ex}}& \hfill \text{(6)}\end{array}$

or number them as subequations:

$\begin{array}{lll}\hfill a& =b\phantom{\rule{2em}{0ex}}& \hfill \text{(7a)}\\ \hfill c& =d.\phantom{\rule{2em}{0ex}}& \hfill \text{(7b)}\end{array}$

We can also have diﬀerent cases:

 $m\left(T\right)=\left\{\begin{array}{cc}0\phantom{\rule{1em}{0ex}}\hfill & \text{}T>{T}_{c}\text{}\hfill \\ {\left(1-{\left[sinh2\beta J\right]}^{-4}\right)}^{\phantom{\rule{0em}{0ex}}1∕8}\phantom{\rule{1em}{0ex}}\hfill & \text{}T<{T}_{c}\text{}\hfill \end{array}\right\$ (8)

write matrices

$\begin{array}{llll}\hfill \mathbf{\text{T}}& =\left(\begin{array}{cc}\hfill {T}_{++}\hfill & \hfill {T}_{+-}\hfill \\ \hfill {T}_{-+}\hfill & \hfill {T}_{--}\hfill \end{array}\right),\phantom{\rule{2em}{0ex}}& \hfill & \phantom{\rule{2em}{0ex}}\\ \hfill & =\left(\begin{array}{cc}\hfill {e}^{\beta \left(J+B\right)}\hfill & \hfill {e}^{-\beta J}\hfill \\ \hfill {e}^{-\beta J}\hfill & \hfill {e}^{\beta \left(J-B\right)}\hfill \end{array}\right).\phantom{\rule{2em}{0ex}}& \hfill \text{(9)}\end{array}$

and

 $\sum _{i}\stackrel{\to }{A}\cdot \stackrel{\to }{B}=-P\phantom{\rule{0em}{0ex}}\int \phantom{\rule{0em}{0ex}}\mathbf{\text{r}}\cdot \stackrel{̂}{n}\phantom{\rule{0em}{0ex}}dA=P\phantom{\rule{0em}{0ex}}\int \phantom{\rule{0em}{0ex}}\stackrel{\to }{\nabla }\cdot \mathbf{\text{r}}\phantom{\rule{0em}{0ex}}dV.$ (10)

### 3 Tables

Tables are a little more diﬃcult. TeX automatically calculates the width of the columns.

 lattice $d$ $q$ ${T}_{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

 Table 1: Comparison of the mean-ﬁeld predictions for the critical temperature of the Ising model with exact results and the best known estimates for diﬀerent spatial dimensions $d$ and lattice symmetries.

### 4 Lists

Some example of formatted lists include the following:

2. cheese
• Tom
• Dick

### 5 Figures

We can make ﬁgures bigger or smaller by scaling them. Figure ?? has been scaled by 60%.

### 6 Literal text

It is desirable to print program code exactly as it is typed in a monospaced font. Use \begin{verbatim}and \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 \verbatiminput{programs/Square.java}\allows you to list the ﬁle Square.java in the directory programs.

### 7 Special Symbols

#### 7.1 Common Greek letters

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

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

#### 7.2 Special symbols

The derivative is deﬁned as

 $\frac{dy}{dx}=\underset{\Delta x\to 0}{lim}\frac{\Delta y}{\Delta x}$ (11)
 $f\left(x\right)\to y\phantom{\rule{1em}{0ex}}\text{as}\phantom{\rule{1em}{0ex}}x\to {x}_{0}$ (12)
 $f\left(x\right)\underset{x\to {x}_{0}}{\to }y$ (13)

Order of magnitude:

 ${log}_{10}f\simeq n$ (14)
 $f\left(x\right)\sim 1{0}^{n}$ (15)

Approximate equality:

 $f\left(x\right)\simeq g\left(x\right)$ (16)

LATEX is simple if we keep everything in proportion:

 $f\left(x\right)\propto {x}^{3}.$ (17)

Finally we can skip some space by using commands such as

\bigskip    \medskip    \smallskip    \vspace{1pc}

The space can be negative.

### 8 Use of Color

We can change colors for emphasis, but who is going pay for the ink?

### 9 Subﬁgures

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 ﬁgures side by side.

We ﬁrst have to include the necessary package, \usepackage{subfigure}, which has to go in the preamble (before \begin{document}). It sometimes can be diﬃcult to place a ﬁgure in the desired place.

Your LaTeX document can be easily modiﬁed 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.

### References

[1]   Helmut Kopka and Patrick W. Daly, A Guide to LATEX: Document Preparation for Beginners and Advanced Users, fourth edition, Addison-Wesley (2004).

[2]   Some useful links are given at .

Updated 5 December 2006.