L^{A}TEX Math

Miki Havlíčková

February 19, 2004

1 Formulas

To put formula in a text, simply put a $ sign before and after is, such as $a+b^2$, which will occur simply as a + b^{2}. To separate a formula from the text, put

\begin{equation}
a+b^2
\end{equation}

which will produce

a + b^{2}  (1)

with a number. To omit the number, put an asterisk after equation.

To produce multiple equation aligned by something in the equation (usually equality sign), write

\begin{eqnarray}
3x + y & = & 0 \\
6 - y & = & 3z + 2x
\end{eqnarray}

This will print

3x + y = 0  (2)
6 − y = 3z + 2x  (3)

The double slash indicates end of line, and the & separates left, center and right parts of the equation; the lines are aligned by their center parts.

2 Symbols and functions

Use the keyboard symbols to produce the usual symbols such as + - ! ( ). Most of the other symbols and commands in this section will only work in math mode, that is in text and displayed formulas.

Brackets

To put a curly brace and have it print instead of count as part of some command, put a backslash in front of it: \{. Square and round brackets are fine by themselves, but will always print in 12pt size. To have your brackets be sized according to whatever goes inside them, use the command \left( followed by the expression inside (possibly including other brackets), followed by \right). You can do this with any type of bracket, again with backslash for curly ones. It becomes a bit more complicated if you want the ending bracket be on a different line or not appear at all; see references for details on that.

Marks on letters

To put exponents or subscripts, use ^and _, as in a^n - b_1 + b_2^{n-1} which will print a^{n} − b_{1} + b_{2}^{n−1}. You can make the sub/superscript longer than one letter by putting curly braces around it, and you can iterate multiple sub/superscripts. To put vector mark, bar, or tilde over a letter put \vec{a} \bar{b} \tilde{c} which prints as a⃗ b̄ c̃. To produce underlines, write \underline\{x + 3\}, and you get \underline{x + 3}.

Operations

To produce fractions, write \frac\{a\}\{m-1\}, producing \frac{a}{m−1}. You get roots by \sqrt[n]\{3\} which makes ^{n} \sqrt{3}; the n is an optional argument, by default set empty (as in a square root). Sums and integrals are produce by \sum_1^n and \int_a^b making ∑_{1}^{n} and ∫_{a}^{b}. The indices are optional and can be omitted. In displayed formulas they will actually go below and above the sum sign; they get squished a little in text formulas.

Other

A few other math examples are Greek letters such as ω are produced by their names, \omega, ”normal” letters ABC by \mathcal{ABC} various symbols like ∀ … → by \forall \ldots \rightarrow. Functions like arcsin(3x) come by their names, as \arcsin(3x) and so forth; see references for a full list. Some of these symbols (such as tensor product, integral etc.) will be smaller in text formulas then in displayed ones.

For letters like ℂ, you have to add the line \usepackage{amsfonts} in your preamble (which is the part of your document between documentclass specification and \begin{document}). You can then use the command \mathbb{C}.

To put extra space in math formulas, use \, \: \; listed in increasing size of space, or \! for negative space. For larger spaces, write \quad or

\qquad.

3 Examples

Hats and fractions

\begin{equation}
H=\frac{\vec{p}^{\;2}}{2m} + \frac{1}{2}m\omega^2\vec{x}^{\,2}
\end{equation}

H = \frac{p^{2}}{2m} + \frac{1}{2}mω^{2}x^{2}  (4)

Roots and spaces

\begin{equation}
a_i=\sqrt{\frac{m\omega}{2h}}\left(x_i+i\frac{p_i}{m\omega}\right)
\qquad\qquad
b_i=\sqrt{\frac{m\omega}{2h}}\left(x_i-\frac{p_i}{m\omega}\right)
\end{equation}

a_{i} = \sqrt{\frac{mω}{2h}} (x_{i} + i\frac{p_{i}}{mω} )  b_{i} = \sqrt{\frac{mω}{2h}} (x_{i} − \frac{p_{i}}{mω} )  (5)

Dots

\begin{equation}\label{state}
|n_1\ldots n_N> =
\frac{(b_1)^{n_1}\cdots(b_N)^{n_N}}{\sqrt{n_1\!\cdots n_N\!}}|0>
\end{equation}

|n_{1} … n_{N} >= \frac{(b_{1})^{n_{1}} ⋯ (b_{N})^{n_{N}}}{\sqrt{n_{1}⋯ n_{N}}} |0 >  (6)

Direct sums

\begin{equation}\label{dec}
\sym{2n} = \bigoplus_{l=0}^{l=n} \har{2l}, \qquad
\sym{2n+1} = \bigoplus_{l=0}^{l=n} \har{2l+1}.
\end{equation}

S^{2n} = ⨁_{l=0}^{l=n} H_{2l},  S^{2n+1} = ⨁_{l=0}^{l=n} H_{2l+1}.  (7)

Greek symbols and subscripts

\begin{equation}\label{bosoniz1}
L_n = -\frac12 \sum_{p \in \mathbb{Z}+1/2} (p+1/2)
:\psi^{+}_{p} \psi^{-}_{n-p}: - \frac12 \sum_{p \in \mathbb{Z}+1/2}
(p+1/2): \psi^{-}_{p} \psi^{+}_{n-p} :\,.
\end{equation}

L_{n} = −\frac{1}{2} ∑_{p∈ℤ+1/2}(p + 1/2) : ψ_{p}^{+}ψ_{n−p}^{−} : −\frac{1}{2} ∑_{p∈ℤ+1/2}(p + 1/2) : ψ_{p}^{−}ψ_{n−p}^{+} : . (8)

Curly braces and dels

\begin{equation}
\{ P, Q \} = \sum_{\alpha, \beta, i, j} \frac{\partial P}{\partial
  u_i^{(\alpha)}} \frac{\partial Q}{\partial u_j^{(\beta)}}
  \partial^\alpha_x \partial^\beta_y B_{ij}[u](x,y)\,.
\end{equation}

\{P, Q\} = ∑_{α,β,i,j} \frac{∂P}{∂u_{i}^{(α)}} \frac{∂Q}{∂u_{j}^{(β)}} ∂_{x}^{α}∂_{y}^{β}B_{ij}[u](x, y) .  (9)

Arrays, integrals and alignment

Note that the first line is not aligned with the rest at the equality sign; this is because the top right-hand side of the equation wouldn’t have fit next to it on the page. For this there is a special command; \lefteqn{your equation} will put what is inside the curly braces on the first line, and align all the other lines underneath it at a convenient place.

\begin{eqnarray*}
\lefteqn{(a_{(-1)}b)_{(-1)}c - a_{(-1)}(b_{(-1)}c) =}\\
&=& \sum_{j\in\mathbb{Z}_+} a_{(-j-2)}(b_{(j)}c)
+ p(a,b)\sum_{j\in\mathbb{Z}_+} b_{(-j-2)}(a_{(j)}c) \\
&=& \left( \int_0^{-T} d \lambda a \right)_{(-1)}[b_\lambda c] +
p(a,b)\left( \int_0^{-T} d \lambda b \right)_{(-1)}[a_\lambda c]
\end{eqnarray*}

(a_{(−1)}b)_{(−1)}c − a_{(−1)}(b_{(−1)}c) =
= ∑_{j∈ℤ_{+}} a_{(−j−2)}(b_{(j)}c) + p(a, b) ∑_{j∈ℤ_{+}} b_{(−j−2)}(a_{(j)}c)

= (∫_{0}^{−T} dλa)_{(−1)} [b_{λ}c] + p(a, b) (∫_{0}^{−T} dλb)_{(−1)} [a_{λ}c]

4 Theorems

To write theorems, lemmas etc., put the following lines in your preamble.

\newtheorem{thm}{Theorem}
\newtheorem{lemma}[thm]{Lemma}

The [thm] command in the lemma line is optional, telling it that for numbering purposes, it should count theorems and lemmas together instead of having a separate counter for each. You can then use the commands

\begin{thm}
All integers are real numbers
\end{thm}

which will produce

Theorem 1 All integers are real numbers

If you follow it by

\begin{lemma}
All real numbers have nonnegative absolute value
\end{lemma}

you will get

Lemma 2 All real numbers have nonnegative absolute value

5 References

The command \label{name} following some of the \begin{equation} in the examples assigns a name to the equation, which lets you refer to it without worrying what its number is.

Warning: If you have citations, always compile your document twice in a row before printing. The reason for this is that the first time around, L^{A}TEX will determine the numbering of everything in the document, and the second time it will actually print the correct references. It will remember the numbering, though if you insert or delete a formula somewhere in the middle, it will again take two compilations to get the references right.

To refer to the equation (6) I typed equation~(\ref{state}). The tilde attaches the reference to the word equation so they don’t get separated by a line break (you can use that for any two or more expression that you want staying next to each other). To refer to section 5, which gets labeled the same way as equations by \label{name} following the \section{title} command, I need to write section~\ref{Cit}. Note the absence of parentheses, since that is by convention only used for equations. Labels of theorems, tables, and other things work exactly the same way.

6 Citations and Bibliography

The easiest way to put in a bibliography is adding the following lines at the end of your .tex file, just before \end{document}.

\begin{thebibliography}{9}
\bibitem{kopka} Helmut Kopka and Patrick Daly.
{\sl A Guide to \LaTeXe}. Addison-Wesley Co., 1995
\end{thebibliography}

The number 9 is a dummy indicating the largest reference number; it tells L^{A}TEX how much space to leave in the labels. That is, if you have approximately 40 references, write a two-digit number there, three-digit if you have 500, etc.

Every \bibitem{label} command begins a new reference; the label is a name that you can cite it by. To do that somewhere in the text, put the command \cite{label}. The references will go in an automatically created References section at the end of your document, as is the case here.

As with equation numbers, it’s a good idea to compile your L^{A}TEX file twice if you have citations, since if any of them have changed since the last time, L^{A}TEX will not be able to both detect and correct it in a single run.

There is a somewhat more complicated, but more efficient and better designed way to write a bibliography. Instead of putting the entries in every .tex file that cites it, you can keep a few files around that have all your references, and tell your .tex document to look in those. The references there also have a standard pre-designed form so you don’t have to worry about how you want the entry to look. For information on how to do that, see Appendix B of [1]

References

[1] Helmut Kopka and Patrick Daly. A Guide to L^{A}TEX 2ε. Addison-Wesley Co., 1995

[2] The class website now has a few links to math related L^{A}TEX sites, as well as links to tables of L^{A}TEX symbols.