A Very Brief Introduction to LATEX
Stuart Field
Department of Physics, Colorado State University
Version 1.0, January 29, 2012
1
Obtaining a TEX installation
There are numerous high-quality, free TEX/LATEX installations available. For the Mac, I suggest TeXShop. TeXShop is
just the front end (editor and menus) to a full TEX installation. To install everything—TeXShop and LATEX—download
and install from the file MacTeX.mpkg.zip, a link to which is available on the TeXShop “Obtaining” page. Like all
full TEX installations, this is a big file, over a gigabyte.
For Windows, there seem to be two popular alternatives, MikTeX and TeX Live. I tried out MiKTeX and it seems
to work well. You can install the Basic MiKTeX 2.9 installer, at around 160 MB, or the full install, which is much
bigger. The full installation installs just about every package that’s out there (as does TeX Live and TeXShop for
the Mac, which uses TeX Live under its hood), while the basic installation installs only a small subset of packages.
However, if, when you run latex, a package you need is not available, MiKTeX will download it automatically. I found
that for the LATEX files and packages that we’ll be using, MiKTeX will need to do a few downloads, so for the first time
or so you latex a file there may be longish delays in processing.
Use the file Template.tex on RamCT to get started. The header—everything above and including the begin{document}
command—can be left as is. Fill in the title{}, author{}, and affiliation{} brackets, and replace the text between \begin{abstract} and \end{abstract}. Then, you can just fill in the \section{} brackets, and go ahead
and type in your text. Below are some hints on how to use some other common features of LATEX. This is hardly a
comprehensive treatment. For more information, see Leslie Lamport’s book, LATEX, A Document Preparation System.
2
Preliminaries
In this document, the text you type into your .tex file is shown on the left, and the formatted LATEX output is shown
on the right.
LaTeX ignores multiple spaces. One space is as
good as
two. LaTeX also ignores single
carriage returns,
as
you
can see. To get a new paragraph, you need to
insert a blank line.
LaTeX ignores multiple spaces. One space is as good
as two. LaTeX also ignores single carriage returns, as
you can see. To get a new paragraph, you need to insert
a blank line.
Like this...
Like this...
3
Math
One of the main reasons for using LATEX is that it produces very high-quality mathematical output. It is significantly
better than that produced by Word’s Equation Editor, and much much better than that typically produced by a PH425
student. Here I’ll just touch on a few common math techniques. The example file shows a few more things.
To type symbols and equations inline, you need to bracket them with dollar signs $. . . $. Thus we have
1
Einstein’s famous equation,
$E = mc^2$, relates mass...
Einstein’s famous equation, E = mc2 , relates mass...
Note that all symbols are math, and so should be bracketed with $. . . $.
...where $x$ is the particle’s position,
$v$ its velocity, and $\theta$ its angle
of launch.
...where x is the particle’s position, v its velocity, and
θ its angle of launch.
Often you want to type display equations, that is, equations that are shown on their own line. A numbered display
equation is formatted using the equation environment. Note that no $...$ are needed.
\begin{equation}
E = mc^2
\label{eq:Einstein}
\end{equation}
E = mc2
(1)
Presumably, if you number an equation you’ll want to refer to it in the text. This is done using the \label command.
The text inside the brackets (eq:Einstein) is the label. It can be any text you like without spaces. I use the eq: part
to remind myself that this is a label for an equation (figures and tables are labeled similarly), but you don’t need to
do things this way. To refer to the equation in the text, you type Equation~\ref{eq:Einstein} at the beginning
of a sentence, or Eq.~\ref{eq:Einstein} within a sentence. This will show up in the output file as “Equation ??”
or “Eq. ??”, respectively. The hyphen ~ is a non-breaking space, so that the word “Equation” and the number don’t
appear on separate lines.
An un-numbered equation is written
\begin{equation*}
E = mc^2
\end{equation*}
E = mc2
There are a very large number of LATEX math symbols available. They are typed in your LATEX file as a backslash
(\) command, always in math mode ($. . . $). Many of them have pretty obvious command names. Thus, for instance,
the Greek letter alpha is typed as \alpha. See the file “LaTeX Math Symbols” for a comprehensive list. Some of the
common ones you might need in this course are
α
β
γ
δ
θ
\alpha
\beta
\gamma
\delta
\theta
µ
π
ρ
σ
τ
\mu
\pi
\rho
\sigma
\tau
φ
ω
Ω
∆
±
\phi
\omega
\Omega
\Delta
\pm
×
≤
≥
h̄
∇
\times
\leq
\geq
\hbar
\nabla
\sum
∑
R
\int
cos \cos
sin \sin
tan \tan
Note that the trig function names such as sin result in the characters “sin” being typeset in non-italic letters, which is
how function names should be typeset. Compare
sin2 u + cos2 u = 1
\sin^2 u + \cos^2 u = 1
with
sin2 u + cos2 u = 1
sin^2 u + cos^2 u = 1
2
There are also a number of LATEX structures you’ll commonly be using. These include:
• Superscripts and subscripts:
x2
x2y
x0
x02
x^2
x^{2 y}
x_0
x^2_0
Subscripts that represent symbols are typeset in math mode, but subscripts that are words are in Roman font:
The velocity vx
The applied field Bmagnet
The velocity $v_x$
The applied field $B_\mathrm{magnet}$
• Fractions:
x = \frac{y^2}{z}
x=
y2
z
• Square roots:
r = \sqrt{x^2 + y^2}
r=
p
x2 + y2
• One thing above another:
\overline{x}
\dot{x}
\hat{a}
\ddot{x}
x
ẋ
\bar{u}
\vec{v}
â ū
ẍ ~v
• Boldface and normal (Roman) font in math mode:
cosθ = A · B
$\mathrm{cos}\theta = \mathbf{A \cdot B}$
4
Figures
Figures can be inserted using the \includegraphics command, inside a figure environment:
16x10
-9
19
2.0x10
RH
←
14
2
3
4
5
6
7
\begin{figure}[h]
\centering
\includegraphics[scale=0.7]{myFigure.pdf}
\caption{This is the caption. It describes
what the figure is about.}
\label{fig:myFigure}
\end{figure}
RH (Ω⋅cm/G)
1
1.5
10
8
1.0
6
4
0.5
n
→
2
0
Carrier Density (cm-3)
12
0.0
-8
-6
-4
-2
0
B (kG)
2
4
6
8
Figure 1: This is the caption. It describes what the
figure is about.
In line 1, the [h] tries to put the figure “here”, as close as possible to where the \includegraphics command
is. Other choices are [t] for the top of the page and [b] for the bottom of the page. Line 2 centers the figure on the
3
page. Line 3 actually places the graphic. Between the square brackets you can put a parameter to scale the figure, or
to set its absolute width ([width = 3.0 in]). If you omit the square brackets entirely, the figure will be placed at
its natural width.
The filename of your figure goes between the braces {...}. In both TeXShop and MiKTeX you can use .pdf, .jpg,
and .png files. Of course, .pdf files are preferred because they are resolution-independent. You can put the graphics
files in the same folder as the .tex file. Or, you can put them in a folder (say, “myFigures”) in the folder that contains
the .tex file. Then (see Template.tex) you’ll need to include \graphicspath{{myFigures/}} at the top of your file.
Every figure needs a caption in braces, as shown in lines 4–5. Finally, because every figure needs to be referenced
in the text, you need some way to refer to it. To do so, use the \label command, as shown in line 6. The label in the
braces can be any text (without spaces) you like. I often use fig: to remind myself that this is a figure label. You can
then refer to the figure elsewhere in the text as Fig.~\ref{fig:myFigure}, which appears in the text as “Fig. ??”.
Always refer to figures by their numbers, as shown above. Never refer to them in the form, “in the figure below
we see that. . . ” or something similar. Also, it’s common for a figure reference that starts a sentence to have the word
“Figure” written out in full, while a reference in the middle of a sentence uses the abbreviation “Fig.” Also note that
in each case the Figure or Fig. is capitalized.
5
Tables
Tables in LATEX are somewhat tricky. There’s an example table in Template.tex that you can look at:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
\begin{table}[h]
\centering
\begin{tabular}{ccccl}
\hline
~$\rho $~ &
$~~~~T_c~~~~$ &~~$\lambda(T/T_c = 0.9)$~~ & $\kappa$ &Source\\
($\mu\Omega\cdot\mathrm{cm})$ & (K) & (nm) & & \\
\hline
10.8 & 1.64 & 510 & 2.6 & Ekin\\
20.8 & 1.81 & 675 & 5.0 & Ekin (interpolated)\\
35.0 & 2.0 & 830 & 8.4 & Daldini {\it et al.}\\
\hline
\end{tabular}
\caption{Properties of several granular aluminum films. $\kappa$ is the
Ginzburg-Landau parameter.}
\label{table:superconductors}
\end{table}
which gives
ρ
(µΩ · cm)
10.8
20.8
35.0
Tc
(K)
1.64
1.81
2.0
λ (T /Tc = 0.9)
(nm)
510
675
830
κ
2.6
5.0
8.4
Source
Ekin
Ekin (interpolated)
Daldini et al.
Table 1: Properties of several granular aluminum films. κ is the Ginzburg-Landau parameter.
Lines 1 and 2 are similar to their figure counterparts. Line 3 starts the table. In the brackets you need to put one
letter for each column of your table, either c for a centered column, l for a left-justified column, or r for a right-justified
column. Whenever you want a horizontal line in your column, use \hline. Each row of the table contains the table
data separated by ampersand (&) characters; the end of each row should have two backslashes (\\). The caption and
reference are handled similarly to a figure; refer to the table above using Table~\ref{table:superconductors}.
In Table ??, I used a number of non-breaking spaces (~) in the header row to space out the columns a little. There
is a way to add space by using actual numerical spacing, but it’s so complicated as to not really be worth it.
4
6
References
It’s likely that your report will have some references. Here’s how to put them in. In the text, where you eventually want
the superscripted citation to appear (. . . as shown in 1978 by Smith23 ), you write ...by Smith\cite{Smith1978}.
The Smith1978 is your cite key, and it can be any text you like. The author’s last name followed by the year is a good
way to keep track of things. You can have more than one reference at a time:
...by several researchers\cite{Smith1978,Jone1996}
. . . by several researchers23, 24
Then, at the end of the file, after the thebibilography command, you create a series of bibitems, each with the
corresponding key. See Template.tex for details.
To get the references properly numbered (as wells equations and figures) you’ll need to run LaTeX twice. Also
note that punctuation goes before the citation: . . . in 1978 by Smith.23 (not . . . in 1978 by Smith23 .)
7
Miscellany
• An opening double quote is made with two acute (‘) characters (to the left of the 1 key); the closing quote is
two apostrophes (’). Thus Shakespeare wrote ‘‘to be or not to be’’ typesets to Shakespeare wrote
“to be or not to be”.
• LATEX automatically adds extra space after a period, except if the period follows a single capital letter (so that
initials of names don’t have extra space after them). Sometimes you don’t want this extra space, such as when
you type Dept. of Energy. If I type this as Dept. of Energy I get Dept. of Energy, which you can see has
a little too much space after the “Dept.” To prevent this, use a “regular space” command \ . Then, typing
Dept.\ of Energy I get Dept. of Energy, which is correctly spaced.
• Sometimes you need a non-breaking space, so that the two words separated by the space cannot be broken across
two lines. An example would be the space between the “Fig.” and the “1” in Fig. 1. This looks bad as Fig.
1. So put a non-breaking space (tilde, or ~) between them. Note that this also fixes the extra space you’d get
after the period in Fig. Another use for the nonbreaking space is between a number and its unit: 23~V.
• You can italicize text by using {\it my text}, giving my text; bold text can be written using {\bf...}.
• A simple hyphen is used to, well, hyphenate: ...a two-electron state (. . . a two-electron state). For
a run of numbers, one uses an “n dash”, created by two hyphens, which is a little longer than a hyphen:
...from 34--65 (“. . . from 34–65”). Finally, an “m dash” is formed by three hyphens:
...the neutron---discovered in 1932---was found to have...
. . . the neutron—discovered in 1932—was found to have. . .
5
© Copyright 2026 Paperzz