AMSLATEX
Workshop #4
David Arnold
Friday, March 26, 1999
– Typeset by FoilTEX –
AMSLATEX
AMSLATEX is a set of macros designed by the
American Mathematics Society (AMS). To use these
macros, we must include them in our preamble with
the \usepackage command.
Enter the following source code, save as
workshop4.tex, LATEX, then preview.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Note that the \texttt{equation} environment works
in \AmS\LaTeX\ exactly as it does in \LaTeX2e.
\begin{equation}\label{eq:1}
\frac{x}{x+1}-\frac{x+1}{x}=1
\end{equation}
\end{document}
The equation environment displays and
automatically numbers an equation, while
\begin{equation*} . . . \end{equation*}
suppresses the numbering of the equation. Try it!
Introducing TEX/LATEX: David Arnold 1
Eqnarray vs. Align
The AMS align environment uses better spacing
around the equals sign.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Compare
\begin{eqnarray}\label{eq:1}
2x+3&=&7\\
2x+3-3&=&7-3\\
2x&=&4
\end{eqnarray}
with
\begin{align}\label{eq:2}
2x+3&=7\\
2x+3-3&=7-3\\
2x&=4.
\end{align}
\end{document}
You can suppress numbering of all equations with
\begin{align*}...\end{align*}. Try it!
Introducing TEX/LATEX: David Arnold 2
NoNumber and Referencing
You can suppress the numbering of an individual
equation in an align environment with \nonumber
and you can label and reference individual equations.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Consider
\begin{align}
2x+3&=7\label{david}\\
2x+3-3&=7-3\nonumber \\
2x&=4\nonumber \\
\frac{2x}2&=\frac42\nonumber \\
x&=2.\label{mary}
\end{align}
The solution of Eq.˜\eqref{david} is given in
Eq.˜\eqref{mary}.
\end{document}
LATEX your source twice to get references correct.
Note that the equation label has nothing to do with
the automatic numbering of the equation.
Introducing TEX/LATEX: David Arnold 3
Subequations
You can format numbering for subequations. Simply
surround your environment with
\begin{subequations}...\end{subequations}.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Consider
\begin{subequations}\label{system}
\begin{align}
2x+3y&=7\label{sys1}\\
3x-4y&=11\label{sys2}
\end{align}
\end{subequations}
In system˜\eqref{system}, first solve
Eq.˜\eqref{sys1} for $x$.
\end{document}
A \label command immediately following
\begin{subequations} will produce a reference of
the parent number. Referencing individual equations
produces subequation labels.
Introducing TEX/LATEX: David Arnold 4
Numberwithin
To have equation numbering tied to section
numbering, with automatic reset of the equation
counter with each new section, use the AMS
command \numberwithin in the document preamble.
\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}
\begin{document}
\section{First Section}
Note the numbering on these centered equations.
\begin{gather}
z=\rho\cos\phi\\
\rho=\sqrt{xˆ2+yˆ2+zˆ2}
\end{gather}
\section{SecondSection}
Note the numbering on these centered equations.
\begin{gather}
z=\rho\cos\phi\\
\rho=\sqrt{xˆ2+yˆ2+zˆ2}
\end{gather}
\end{document}
Note that the gather environment centers equations
in a display.
Introducing TEX/LATEX: David Arnold 5
Multiple Line Displays
Use the AMSLATEX multline environment for
displays that are too long to fit on one line. Although
the following example is not close to being an identity,
it does an admirable job of explaining the multline
environment.
\documentclass{article}
\usepackage{amsmath}
\numberwithin{equation}{section}
\begin{document}
\section{The Exponential}
Use copy and paste to quickly create the following
display.
\begin{multline}
eˆx=1+x+\frac{xˆ2}{2!}+\frac{xˆ3}{3!}+\dots \\
1+x+\frac{xˆ2}{2!}+\frac{xˆ3}{3!}+\dots \\
1+x+\frac{xˆ2}{2!}+\frac{xˆ3}{3!}+\dots \\
1+x+\frac{xˆ2}{2!}+\frac{xˆ3}{3!}+\dots
\end{multline}
\end{document}
Note that in the resulting display, the first line is left-
justified (with a small indent), the middle lines are
displayed, and the last line is right-justified (also with
a small indent).
Introducing TEX/LATEX: David Arnold 6
Cases and TexT in Math
Piecewise functions are easily handled with the
AMSLATEX cases environment. Also, the AMSLATEX
\text command makes it easy to insert text in
mathematical expressions.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Consider the piecewise function $f$, defined by
\begin{equation}
f(x)=
\begin{cases}
2x-3 & \text{if $x<0$}, \\
3 & \text{if $x\ge 0$}.
\end{cases}
\end{equation}
The functions $f$ and $g$ are inverses of one
another if and only
if
$$
f(g(x))=x \quad\text{and}\quad g(f(x))=x.
$$
\end{document}
Introducing TEX/LATEX: David Arnold 7
Theorems and Such
AMSLATEX provides the \newtheorem command to
aid in the creation of theorem, corollary, definition,
and other such environments. The \newtheorem
command has two mandatory arguments. The first is
the environment name that is used in the source, and
the second is the header that is used in the output.
For example,
\newtheorem{thm}{Theorem}
\begin{thm} Text, text, ...\end{thm}
will produce
Theorem 1. Text, text, ...
The \newtheorem* command produces un-numbered
theorem environments. For example,
\newtheorem*{rol}{Rolle’s Theorem}
\begin{rol} Text, text, ...\end{rol}
will produce
Rolle’s Theorem. Text, text, ...
Introducing TEX/LATEX: David Arnold 8
You have to load the package amsthm in the preamble
in order to use the \newtheorem command.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}
\newtheorem{cor}{Corollary}
\begin{document}
\begin{thm} If $f$ is continuous on $[a,b]$ and
$K$ is some number between $f(a)$ and $f(b)$, then
there exists a number $c$ in $(a,b)$ with $f(c)=K$.
\end{thm}
\begin{cor}
If $f$ is continuous on $[a,b]$ and $f(a)f(b)<0$,
then there exists a $c$ in $(a,b)$ with $f(c)=0$.
\end{cor}
\end{document}
AMSLATEX provides further assistance for different numbering
schemes as well as formatting of the body of theorem
environments.
Introducing TEX/LATEX: David Arnold 9
Matrices in AMSLATEX
The amsmath package provides some environments for matrices
beyond the basic array environment of LATEX. The pmatrix,
bmatrix,
¡¢ £¤ ©ªBmatrix,
¯¯ vmatrix,
°° and Vmatrix have (respectively)
, , , ¯¯, and °° delimiters built in.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Let $A$ be the $m\times n$ matrix
$$
A=
\begin{pmatrix}
a_{11} & a_{12} & \dots & a_{1n}\\
a_{21} & a_{22} & \dots & a_{2n}\\
\vdots & \vdots & \ddots & \vdots\\
a_{m1} & a_{m2} & \dots & a_{mn}
\end{pmatrix}.
$$
\end{document}
Try replacing pmatrix with bmatrix, Bmatrix, vmatrix, or
Vmatrix and preview the result.
Introducing TEX/LATEX: David Arnold 10
WinEdt Article Template
You are now in a position to understand the LATEX article
template provided with WinEdt. Select New Document from the
Project menu, then select LATEX: Article. Scroll to the top of the
source. The first difference you will note is the line
\documentclass{amsart}
which invokes the American Mathematical Society’s article style
(amsart). This is similar, yet quite different from the Standard
LATEX Article style.
Note the new theorem environments and command definitions.
The first difference occurs in the \title command. The form
\title[short title]{long title} allows the author to
provide both a short title (used for headings and table of
contents)and a longer title (used only on the title page). Use
Ctrl+Spacebar to jump to this construct and fill in your long and
short title.
Use Ctrl+Spacebar to jump from bullet to bullet, filling in the
rest of the bullets with appropriate text as you go.
Introducing TEX/LATEX: David Arnold 11
Comment out the \usepackage[active]{srcltx} at the
beginning of the source file.
%\usepackage[active]{srcltx}
Also, comment out the bibliography lines at the end of the
source.
%\bibliographystyle{amsplain}
%\bibliography
Introducing TEX/LATEX: David Arnold 12
Written Homework Assignment
On the template begun on the previous slide, write an article
that contains each of the following constructs:
• An abstract.
• A TOC.
• At least two sections and subsections.
• At least two uses of the provided theorem environments.
• At least two uses of the new commands defined in the
preamble.
• Craft a newcommand with at least one parameter and use it in
the source.
• An enumerated list.
• A bulleted (itemized) list.
• A descriptive list.
• A quotation.
• Some lines of computer code.
• At least two footnotes.
• Several occurrences of in-line mathematics.
• Incorporate each of the different font families, series, and
shapes, where appropriate.
Introducing TEX/LATEX: David Arnold 13
• A numbered equation and a reference to the equation in the
source.
• At least one instance of a numbered align environment.
• A table.
• A bibliography containing at least two entries. Reference
these entries in the source.
Homework assignments will be collected, changed to portable
document format, then posted on our web server. Please let me
know if you have difficulty with this assignment and/or you don’t
wish to participate. It is OK if this assignment takes more than
one week.
Introducing TEX/LATEX: David Arnold 14