Docsity

Documentación sobre el paquete amsmath: características y uso - Prof. Mulet, Apuntes de Matemáticas

Vista previa parcial del texto

¡Descarga Documentación sobre el paquete amsmath: características y uso - Prof. Mulet y más Apuntes en PDF de Matemáticas solo en Docsity!

User’s Guide for the amsmath Package

(Version 2.0)

American Mathematical Society

ii CONTENTS

iv CONTENTS

Introduction

The amsmath package is a LATEX package that provides miscellaneous enhance- ments for improving the information structure and printed output of documents that contain mathematical formulas. Readers unfamiliar with LATEX should refer to [7]. If you have an up-to-date version of LATEX, the amsmath package is nor- mally provided along with it. Upgrading when a newer version of the amsmath package is released can be done via http://www.ams.org/tex/amsmath.html or ftp://ftp.ams.org/pub/tex/. This documentation describes the features of the amsmath package and dis- cusses how they are intended to be used. It also covers some ancillary packages:

amsbsy amstext amscd amsxtra amsopn

These all have something to do with the contents of math formulas. For infor- mation on extra math symbols and math fonts, see [1] and http://www.ams. org/tex/amsfonts.html. For documentation of the amsthm package or AMS document classes (amsart, amsbook, etc.) see [3] or [2] and http://www.ams. org/tex/author-info.html. If you are a long-time LATEX user and have lots of mathematics in what you write, then you may recognize solutions for some familiar problems in this list of amsmath features:

  • A convenient way to define new ‘operator name’ commands analogous to \sin and \lim, including proper side spacing and automatic selection of the correct font style and size (even when used in sub- or superscripts).
  • Multiple substitutes for the eqnarray environment to make various kinds of equation arrangements easier to write.
  • Equation numbers automatically adjust up or down to avoid overprinting on the equation contents (unlike eqnarray).
  • Spacing around equals signs matches the normal spacing in the equation environment (unlike eqnarray).
  • A way to produce multiline subscripts as are often used with summation or product symbols.
  • An easy way to substitute a variant equation number for a given equation instead of the automatically supplied number.
  • An easy way to produce subordinate equation numbers of the form (1.3a) (1.3b) (1.3c) for selected groups of equations. The amsmath package is distributed together with some small auxiliary pack- ages:

amsmath Primary package, provides various features for displayed equations and other mathematical constructs.

3.2. SINGLE EQUATIONS 3

leqno Place equation numbers on the left.

reqno Place equation numbers on the right.

fleqn Position equations at a fixed indent from the left margin rather than centered in the text column.

Displayed equations

3.1 Introduction

The amsmath package provides a number of additional displayed equation struc- tures beyond the ones provided in basic LATEX. The augmented set includes:

equation equation* align align* gather gather* flalign flalign* multline multline* alignat alignat* split

(Although the standard eqnarray environment remains available, it is better to use align or equation+split instead.) Except for split, each environment has both starred and unstarred forms, where the unstarred forms have automatic numbering using LATEX’s equation counter. You can suppress the number on any particular line by putting \notag before the \; you can also override it with a tag of your own using \tag{〈label 〉}, where 〈label 〉 means arbitrary text such as $$ or ii used to “number” the equation. There is also a \tag command that causes the text you supply to be typeset literally, without adding parentheses around it. \tag and \tag* can also be used within the unnumbered versions of all the amsmath alignment structures. Some examples of the use of \tag may be found in the sample files testmath.tex and subeqn.tex provided with the amsmath package.

The split environment is a special subordinate form that is used only inside one of the others. It cannot be used inside multline, however. In the structures that do alignment (split, align and variants), relation symbols have an & before them but not after—unlike eqnarray. Putting the & after the relation symbol will interfere with the normal spacing; it has to go before.

3.2 Single equations

The equation environment is for a single equation with an automatically gen- erated number. The equation* environment is the same except for omitting the number.^1

(^1) Basic LATEX doesn’t provide an equation* environment, but rather a functionally equiv- alent environment named displaymath.

4 3. DISPLAYED EQUATIONS

Table 3.1. Comparison of displayed equation environments (vertical lines in- dicating nominal margins)

\begin{equation} a=b \end{equation}

a = b

\begin{equation} a=b \end{equation}

(1) a = b

\begin{equation}\label{xx} \begin{split} a& =b+c-d\ & \quad +e-f\ & =g+h\ & =i \end{split} \end{equation}

a = b + c − d

  • e − f = g + h = i

\begin{multline} a+b+c+d+e+f\ +i+j+k+l+m+n \end{multline}

(3) a + b + c + d + e + f

  • i + j + k + l + m + n

\begin{gather} a_1=b_1+c_1\ a_2=b_2+c_2-d_2+e_ \end{gather}

(4) a 1 = b 1 + c 1 (5) a 2 = b 2 + c 2 − d 2 + e 2

\begin{align} a_1& =b_1+c_1\ a_2& =b_2+c_2-d_2+e_ \end{align}

(6) a 1 = b 1 + c 1 (7) a 2 = b 2 + c 2 − d 2 + e 2

\begin{align} a_{11}& =b_{11}& a_{12}& =b_{12}\ a_{21}& =b_{21}& a_{22}& =b_{22}+c_{22} \end{align}

(8) a 11 = b 11 a 12 = b 12 (9) a 21 = b 21 a 22 = b 22 + c 22

\begin{flalign} a_{11}& =b_{11}& a_{12}& =b_{12}\ a_{21}& =b_{21}& a_{22}& =b_{22}+c_{22} \end{flalign}

a 11 = b 11 a 12 = b 12 a 21 = b 21 a 22 = b 22 + c 22

6 3. DISPLAYED EQUATIONS

\begin{equation}\label{e:barwq}\begin{split} H_c&=\frac{1}{2n} \sum^n_{l=0}(-1)^{l}(n-{l})^{p-2} \sum_{l _1+\dots+ l p=l}\prod^p{i=1} \binom{n_i}{l _i}\ &\quad\cdot[(n-l )-(n_i-l _i)]^{n_i-l i}\cdot \Bigl[(n-l )^2-\sum^p{j=1}(n_i-l _i)^2\Bigr]. \end{split}\end{equation}

The split structure should constitute the entire body of the enclosing struc- ture, apart from commands like \label that produce no visible material.

3.5 Equation groups without alignment

The gather environment is used for a group of consecutive equations when there is no alignment desired among them; each one is centered separately within the text width (see Table 3.1). Equations inside gather are separated by a \bslash command. Any equation in a gather may consist of a \begin{split}

... \end{split} structure—for example:

\begin{gather} first equation\ \begin{split} second & equation\ & on two lines \end{split} \ third equation \end{gather}

3.6 Equation groups with mutual alignment

The align environment is used for two or more equations when vertical align- ment is desired; usually binary relations such as equal signs are aligned (see Table 3.1). To have several equation columns side-by-side, use extra ampersands to sep- arate the columns:

(3.12) x = y X = Y a = b + c

(3.13) x′^ = y′^ X′^ = Y ′^ a′^ = b

(3.14) x + x′^ = y + y′^ X + X′^ = Y + Y ′^ a′b = c′b

\begin{align} x&=y & X&=Y & a&=b+c\ x’&=y’ & X’&=Y’ & a’&=b\ x+x’&=y+y’ & X+X’&=Y+Y’ & a’b&=c’b \end{align}

Line-by-line annotations on an equation can be done by judicious application of

3.7. ALIGNMENT BUILDING BLOCKS 7

\text inside an align environment:

(3.15) x = y 1 − y 2 + y 3 − y 5 + y 8 −... by (3.21)

(3.16) = y′^ ◦ y∗^ by (4.1)

(3.17) = y(0)y′^ by Axiom 1.

\begin{align} x& = y_1-y_2+y_3-y_5+y_8-\dots && \text{by \eqref{eq:C}}\ & = y’\circ y^* && \text{by \eqref{eq:D}}\ & = y(0) y’ && \text {by Axiom 1.} \end{align}

A variant environment alignat allows the horizontal space between equations to be explicitly specified. This environment takes one argument, the number of “equation columns”: count the maximum number of &s in any row, add 1 and divide by 2.

(3.18) x = y 1 − y 2 + y 3 − y 5 + y 8 −... by (3.21)

(3.19) = y′^ ◦ y∗^ by (4.1)

(3.20) = y(0)y′^ by Axiom 1.

\begin{alignat}{2} x& = y_1-y_2+y_3-y_5+y_8-\dots &\quad& \text{by \eqref{eq:C}}\ & = y’\circ y^* && \text{by \eqref{eq:D}}\ & = y(0) y’ && \text {by Axiom 1.} \end{alignat}

3.7 Alignment building blocks

Like equation, the multi-equation environments gather, align, and alignat are designed to produce a structure whose width is the full line width. This means, for example, that one cannot readily add parentheses around the entire structure. But variants gathered, aligned, and alignedat are provided whose total width is the actual width of the contents; thus they can be used as a component in a containing expression. E.g.,

B′^ = −∂ × E, E′^ = ∂ × B − 4 πj,

Maxwell’s equations

\begin{equation} \left.\begin{aligned} B’&=-\partial\times E,\ E’&=\partial\times B - 4\pi j, \end{aligned} \right} \qquad \text{Maxwell’s equations} \end{equation}

3.11. EQUATION NUMBERING 9

finer control: [1] means allow page breaks, but avoid them as much as possi- ble; values of 2,3,4 mean increasing permissiveness. When display breaks are enabled with \allowdisplaybreaks, the \* command can be used to prohibit a pagebreak after a given line, as usual. Note: Certain equation environments wrap their contents in an unbreakable box, with the consequence that neither \displaybreak nor \allowdisplaybreaks will have any effect on them. These include split, aligned, gathered, and alignedat.

3.10 Interrupting a display

The command \intertext is used for a short interjection of one or two lines of text in the middle of a multiple-line display structure (see also the \text command in §6). Its salient feature is preservation of the alignment, which would not happen if you simply ended the display and then started it up again afterwards. \intertext may only appear right after a \ or \* command. Notice the position of the word “and” in this example.

(3.22) A 1 = N 0 (λ; Ω′) − φ(λ; Ω′^ ),

(3.23) A 2 = φ(λ; Ω′) − φ(λ; Ω),

and

(3.24) A 3 = N (λ; ω).

\begin{align} A_1&=N_0(\lambda;\Omega’)-\phi(\lambda;\Omega’),\ A_2&=\phi(\lambda;\Omega’)-\phi(\lambda;\Omega),\ \intertext{and} A_3&=\mathcal{N}(\lambda;\omega). \end{align}

3.11 Equation numbering

3.11.1 Numbering hierarchy

In LATEX if you wanted to have equations numbered within sections—that is, have equation numbers (1.1), (1.2),... , (2.1), (2.2),... , in sections 1, 2, and so forth—you could redefine \theequation as suggested in the LATEX manual [7, §6.3, §C.8.4]:

\renewcommand{\theequation}{\thesection.\arabic{equation}}

This works pretty well, except that the equation counter won’t be reset to zero at the beginning of a new section or chapter, unless you do it yourself using \setcounter. To make this a little more convenient, the amsmath package pro- vides a command \numberwithin. To have equation numbering tied to section numbering, with automatic reset of the equation counter, write

\numberwithin{equation}{section}

As its name implies, the \numberwithin command can be applied to any counter, not just the equation counter.

10 4. MISCELLANEOUS MATHEMATICAL FEATURES

3.11.2 Cross references to equation numbers

To make cross-references to equations easier, an \eqref command is provided. This automatically supplies the parentheses around the equation number. I.e., if \ref{abc} produces 3.2 then \eqref{abc} produces (3.2).

3.11.3 Subordinate numbering sequences

The amsmath package provides also a subequations environment to make it easy to number equations in a particular group with a subordinate numbering scheme. For example

\begin{subequations} ... \end{subequations}

causes all numbered equations within that part of the document to be numbered (4.9a) (4.9b) (4.9c)... , if the preceding numbered equation was (4.8). A \label command immediately after \begin{subequations} will produce a \ref of the parent number 4.9, not 4.9a. The counters used by the subequations environ- ment are parentequation and equation and \addtocounter, \setcounter, \value, etc., can be applied as usual to those counter names. To get anything other than lowercase letters for the subordinate numbers, use standard LATEX methods for changing numbering style [7, §6.3, §C.8.4]. For example, redefining \theequation as follows will produce roman numerals.

\begin{subequations} \renewcommand{\theequation}{\theparentequation \roman{equation}} ...

Miscellaneous mathematical features

4.1 Matrices

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. For naming consistency there is a matrix environment sans delimiters. This is not entirely redundant with the array environment; the matrix environments all use more economical horizontal spacing than the rather prodigal spacing of the array environment. Also, unlike the array environment, you don’t have to give column specifications for any of the matrix environments; by default you can have up to 10 centered columns.^2 (If you need left or right alignment in a column or other special formats you must resort to array.)

(^2) More precisely: The maximum number of columns in a matrix is determined by the counter MaxMatrixCols (normal value = 10), which you can change if necessary using LATEX’s \setcounter or \addtocounter commands.

12 4. MISCELLANEOUS MATHEMATICAL FEATURES

  • \dotsc for “dots with commas”
  • \dotsb for “dots with binary operators/relations”
  • \dotsm for “multiplication dots”
  • \dotsi for “dots with integrals”
  • \dotso for “other dots” (none of the above)

instead of \ldots and \cdots, you make it possible for your document to be adapted to different conventions on the fly, in case (for example) you have to submit it to a publisher who insists on following house tradition in this respect. The default treatment for the various kinds follows American Mathematical Society conventions:

Then we have the series $A_1, A_2, \dotsc$, the regional sum $A_ +A_2 +\dotsb $, the orthogonal product $A_1 A_2 \dotsm $, and the infinite integral [\int_{A_1}\int_{A_2}\dotsi].

Then we have the series A 1 , A 2 ,... , the regional sum A 1 + A 2 + · · · , the orthogonal product A 1 A 2 · · · , and the infinite integral ∫

A 1

A 2

4.4 Nonbreaking dashes

A command \nobreakdash is provided to suppress the possibility of a linebreak after the following hyphen or dash. For example, if you write ‘pages 1–9’ as pages 1\nobreakdash--9 then a linebreak will never occur between the dash and the 9. You can also use \nobreakdash to prevent undesirable hyphen- ations in combinations like $p$-adic. For frequent use, it’s advisable to make abbreviations, e.g.,

\newcommand{\p}{$p$\nobreakdash}% for "\p-adic" \newcommand{\Ndash}{\nobreakdash--}% for "pages 1\Ndash 9" % For "\n dimensional" ("n-dimensional"): \newcommand{\n}[1]{$n$\nobreakdash-\hspace{0pt}}

The last example shows how to prohibit a linebreak after the hyphen but allow normal hyphenation in the following word. (It suffices to add a zero-width space after the hyphen.)

4.5 Accents in math

In ordinary LATEX the placement of the second accent in doubled math accents is often poor. With the amsmath package you will get improved placement of

the second accent: Aˆˆ (\hat{\hat{A}}). The commands \dddot and \ddddot are available to produce triple and quadruple dot accents in addition to the \dot and \ddot accents already avail- able in LATEX. To get a superscripted hat or tilde character, load the amsxtra package and use \sphat or \sptilde. Usage is A\sphat (note the absence of the ^ character). To place an arbitrary symbol in math accent position, or to get under accents, see the accents package by Javier Bezos.

4.10. AFFIXING SYMBOLS TO OTHER SYMBOLS 13

4.6 Roots

In ordinary LATEX the placement of root indices is sometimes not so good: β

k (\sqrt[\beta]{k}). In the amsmath package \leftroot and \uproot allow you to adjust the position of the root:

\sqrt[\leftroot{-2}\uproot{2}\beta]{k}

will move the beta up and to the right:

√β k. The negative argument used with \leftroot moves the β to the right. The units are a small amount that is a useful size for such adjustments.

4.7 Boxed formulas

The command \boxed puts a box around its argument, like \fbox except that the contents are in math mode:

(4.2) η ≤ C(δ(η) + ΛM (0, δ))

\boxed{\eta \leq C(\delta(\eta) +\Lambda_M(0,\delta))}

4.8 Over and under arrows

Basic LATEX provides \overrightarrow and \overleftarrow commands. Some additional over and under arrow commands are provided by the amsmath package to extend the set:

\overleftarrow \underleftarrow \overrightarrow \underrightarrow \overleftrightarrow \underleftrightarrow

4.9 Extensible arrows

\xleftarrow and \xrightarrow produce arrows that extend automatically to accommodate unusually wide subscripts or superscripts. These commands take one optional argument (the subscript) and one mandatory argument (the su- perscript, possibly empty):

(4.3) A

n+μ− 1 ←−−−−− B n±i− 1 −−−−→ T

C

\xleftarrow{n+\mu-1}\quad \xrightarrow[T]{n\pm i-1}

4.10 Affixing symbols to other symbols

LATEX provides \stackrel for placing a superscript above a binary relation. In the amsmath package there are somewhat more general commands, \overset and \underset, that can be used to place one symbol above or below another symbol, whether it’s a relation or something else. The input \overset{*}{X}

will place a superscript-size ∗ above the X:

∗ X; \underset is the analog for adding a symbol underneath. See also the description of \sideset in §7.2.

4.14. DELIMITERS 15

4.12 Continued fractions

The continued fraction

can be obtained by typing

\cfrac{1}{\sqrt{2}+ \cfrac{1}{\sqrt{2}+ \cfrac{1}{\sqrt{2}+\dotsb }}}

This produces better-looking results than straightforward use of \frac. Left or right placement of any of the numerators is accomplished by using \cfrac[l] or \cfrac[r] instead of \cfrac.

4.13 Smash options

The command \smash is used to typeset a subformula with an effective height and depth of zero, which is sometimes useful in adjusting the subformula’s position with respect to adjacent symbols. With the amsmath package \smash has optional arguments t and b, because occasionally it is advantageous to be able to “smash” only the top or only the bottom of something while retaining the natural depth or height. For example, when adjacent radical symbols are unevenly sized or positioned because of differences in the height and depth of their contents,√ \smash can be employed to make them more consistent. Compare x +

y +

z and

x +

y +

z, where the latter was produced by $\sqrt{x}

  • \sqrt{\smash[b]{y}} + \sqrt{z}$.

4.14 Delimiters

4.14.1 Delimiter sizes

The automatic delimiter sizing done by \left and \right has two limitations: First, it is applied mechanically to produce delimiters large enough to encompass the largest contained item, and second, the range of sizes is not even approxi- mately continuous but has fairly large quantum jumps. This means that a math fragment that is infinitesimally too large for a given delimiter size will get the next larger size, a jump of 3pt or so in normal-sized text. There are two or three situations where the delimiter size is commonly adjusted, using a set of commands that have ‘big’ in their names.

Delimiter text \left \bigl \Bigl \biggl \Biggl size size \right \bigr \Bigr \biggr \Biggr

Result (b)( c d

) (b)

( (^) c d

b

)( (^) c d

b

)( (^) c d

b

c d

b

c d

16 4. MISCELLANEOUS MATHEMATICAL FEATURES

The first kind of situation is a cumulative operator with limits above and below. With \left and \right the delimiters usually turn out larger than necessary, and using the Big or bigg sizes instead gives better results:

 

i

ai

j

xij

p 

1 /p

versus

[∑

i

ai

j

xij

p]^1 /p

\biggl[\sum_i a_i\Bigl\lvert\sum_j x_{ij}\Bigr\rvert^p\biggr]^{1/p}

The second kind of situation is clustered pairs of delimiters where \left and \right make them all the same size (because that is adequate to cover the en- compassed material) but what you really want is to make some of the delimiters slightly larger to make the nesting easier to see.

((a 1 b 1 ) − (a 2 b 2 )) ((a 2 b 1 ) + (a 1 b 2 )) versus

(a 1 b 1 ) − (a 2 b 2 )

(a 2 b 1 ) + (a 1 b 2 )

\left((a_1 b_1) - (a_2 b_2)\right) \left((a_2 b_1) + (a_1 b_2)\right) \quad\text{versus}\quad \bigl((a_1 b_1) - (a_2 b_2)\bigr) \bigl((a_2 b_1) + (a_1 b_2)\bigr)

The third kind of situation is a slightly oversize object in running text, such as∣ ∣ ∣ b

′ d′

∣ where the delimiters produced by^ \left^ and^ \right^ cause too much line

spreading. In that case \bigl and \bigr can be used to produce delimiters that are slightly larger than the base size but still able to fit within the normal line spacing:

∣ b′ d′

In ordinary LATEX \big, \bigg, \Big, and \Bigg delimiters aren’t scaled properly over the full range of LATEX font sizes. With the amsmath package they are.

4.14.2 Vertical bar notations

The amsmath package provides commands \lvert, \rvert, \lVert, \rVert (compare \langle, \rangle) to address the problem of overloading for the vert bar character |. This character is currently used in LATEX documents to represent a wide variety of mathematical objects: the ‘divides’ relation in a number-theory expression like p|q, or the absolute-value operation |z|, or the ‘such that’ condition in set notation, or the ‘evaluated at’ notation fζ (t)

t=0. The multiplicity of uses in itself is not so bad; what is bad, however, is that fact that not all of the uses take the same typographical treatment, and that the complex discriminatory powers of a knowledgeable reader cannot be replicated in computer processing of mathematical documents. It is recommended there- fore that there should be a one-to-one correspondence in any given document between the vert bar character | and a selected mathematical notation, and similarly for the double-bar command |. This immediately rules out the use of | and | for delimiters, because left and right delimiters are distinct usages