/
amsldoc.tex
2777 lines (2411 loc) · 102 KB
/
amsldoc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%
% Copyright (C) 1995, 2000, 2013 American Mathematical Society.
% Copyright (C) 2016-2021 LaTeX Project and American Mathematical Society.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is the LaTeX Project.
%
\documentclass[leqno,titlepage,openany]{amsldoc}[1999/12/13]
\def\MaintainedByLaTeXTeam#1{%
\begin{center}%
\fbox{\fbox{\begin{tabular}{@{}l@{}}%
This file is maintained by the \LaTeX{} Project team.\\%
Bug reports can be opened (category \texttt{#1}) at\\%
\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}}
\ifx\UndEfiNed\url
\ClassError{amsldoc}{%
This version of amsldoc.tex must be processed\MessageBreak
with a newer version of amsldoc.cls (2.02 or later).}{}
\fi
\renewcommand\bibname{References}
% Definitions that should be moved to amsldoc.cls
% when it is next updated
\makeatletter
\let\cleardouble@page\cleardoublepage
\AtBeginDocument{%
\ifx\cleardouble@page\cleardoublepage
\def\cleardoublepage{\clearpage{\pagestyle{empty}\cleardouble@page}}
\fi
}
% #1 is empty or one of class, environment, option, package
% could use different font in each case
\makeatletter
\def\@category@index#1#2{%
\autoindex{%
#2\actualchar\string\index#1font{#2}%
\ifx\@nil#1\@nil\else\space#1\fi
}%
}
\let\indexpackagefont\textsf
\let\indexclassfont\textsf
\let\indexoptionfont\texttt
\let\indexenvironmentfont\texttt
\let\indexfont\texttt
\makeatother
% For a package that won't be indexed, i.e. amsmath
\newcommand{\nipkg}{\textsf}
\def\tikz/{Ti\textit{k}Z}
% End definitions for amsldoc.cls
\title{User's Guide for the \nipkg{amsmath} Package (Version~2.1)}
\author{American Mathematical Society, \LaTeX\ Project}
\date{1999-12-13\\(revised 2002-02-25, 2016-11-14, 2018-04-05, 2019-10-14, 2020-02-18)}
\makeatletter
\def\@thanks{\bigskip\MaintainedByLaTeXTeam{amslatex}}
\makeatother
% Use the amsmath package and amscd package in order to print
% examples.
\usepackage{amsmath}
\usepackage{amscd}
\usepackage{imakeidx}
% Need alternate coding for vertical bar to get it into index.
% Based on \qcbang and \cnbang in amsldoc.cls, refined by David Carlisle.
% Give it a sort field that will be at the end of the symbols;
% must avoid " and | which have special meanings.
\DeclareRobustCommand{\qcvert}{\qc\|\index{{z1}@{\ntt\char'174}}}
\DeclareRobustCommand{\cnvert}{%
\ncn{\|}\index{{z0}@{\ntt\bslchar\char'174}}}
% Need alternate index sort field for bang to allow & to sort first
\DeclareRobustCommand{\altcnbang}{%
\ncn{\!}\index{"!b@{\ntt\bslchar\qcbang}}}
\DeclareRobustCommand{\cnamp}{%
\index{"!a@\texttt{\&}}}
\makeindex[intoc] % generate index data
\providecommand{\see}[2]{\textit{see} #1}
% The amsldoc class includes a number of features useful for
% documentation about TeX, including:
%
% ---Commands \tex/, \amstex/, \latex/, ... for uniform treatment
% of the various logos and easy handling of following spaces.
%
% ---Commands for printing various common elements: \cn for command
% names, \fn for file names (including font-file names), \env for
% environments, \pkg and \cls for packages and classes, etc.
% Many of the command names used here are rather long and will
% contribute to poor linebreaking if we follow the \latex/ practice
% of not hyphenating anything set in tt font; instead we selectively
% allow some hyphenation.
\allowtthyphens % defined in amsldoc.cls
\hyphenation{ac-cent-ed-sym-bol add-to-counter add-to-length align-at
aligned-at allow-dis-play-breaks ams-art ams-cd ams-la-tex amsl-doc
ams-symb ams-tex ams-text ams-xtra bmatrix bold-sym-bol cen-ter-tags
eqn-ar-ray idots-int int-lim-its latex med-space neg-med-space
neg-thick-space neg-thin-space no-int-lim-its no-name-lim-its
over-left-arrow over-left-right-arrow over-right-arrow pmatrix
qed-sym-bol set-length side-set small-er tbinom the-equa-tion
thick-space thin-space un-der-left-arrow un-der-left-right-arrow
un-der-right-arrow use-pack-age var-inj-lim var-proj-lim vmatrix
xalign-at xx-align-at}
% Prepare for illustrating the \vec example
\newcommand{\vect}[1]{\mathbf{#1}}
\newcommand{\booktitle}[1]{\textit{#1}}
\newcommand{\journalname}[1]{\textit{#1}}
\newcommand{\seriesname}[1]{\textit{#1}}
% Command to insert and index a particular phrase. Doesn't work for
% certain kinds of special characters in the argument.
\newcommand{\ii}[1]{#1\index{#1}}
\newcommand{\vstrut}[1]{\vrule width0pt height#1\relax}
% An environment for presenting comprehensive address information:
\newenvironment{infoaddress}{%
\par\topsep\medskipamount
\trivlist\centering
\item[]%
\begin{minipage}{.7\columnwidth}%
\raggedright
}{%
\end{minipage}%
\endtrivlist
}
\newenvironment{eqxample}{%
\par\addvspace\medskipamount
\noindent\begin{minipage}{.5\columnwidth}%
\def\producing{\end{minipage}\begin{minipage}{.5\columnwidth}%
\hbox\bgroup\kern-.2pt\vrule width.2pt%
\vbox\bgroup\parindent0pt\relax
% The 3pt is to cancel the -\lineskip from \displ@y
\abovedisplayskip3pt \abovedisplayshortskip\abovedisplayskip
\belowdisplayskip0pt \belowdisplayshortskip\belowdisplayskip
\noindent}
}{%
\par
% Ensure that a lonely \[\] structure doesn't take up width less than
% \hsize.
\hrule height0pt width\hsize
\egroup\vrule width.2pt\kern-.2pt\egroup
\end{minipage}%
\par\addvspace\medskipamount
}
% Errors in output shouldn't be \texttt, and they may also be longer
% than one line, but they should be identified by the "errorbullet".
% (They were formerly labeled as aubsections.)
\newenvironment{erroro}[1]{%
\par\addvspace\medskipamount
\noindent\hangindent\parindent
\hbox to\parindent{\errorbullet\hfil}\ignorespaces
#1\par\vspace{\smallskipamount}
}{%
\par\addvspace\medskipamount
}
% The chapters are so short, perhaps we shouldn't call them by the
% name `Chapter'. We make \chaptername read an argument in order to
% remove a following \space or "{} " (both possibilities are present
% in book.cls).
\renewcommand{\chaptername}[1]{}
\newcommand{\chapnum}[1]{\mdash #1\mdash }
\makeatletter
\def\@makechapterhead#1{%
\vspace{1.5\baselineskip}%
{\parindent \z@ \raggedright \reset@font
\ifnum \c@secnumdepth >\m@ne
\large\bfseries \chapnum{\thechapter}%
\par\nobreak
\vskip.5\baselineskip\relax
\fi
#1\par\nobreak
\vskip\baselineskip
}}
\makeatother
% A command for ragged-right parbox in a tabular.
\newcommand{\rp}{\let\PBS\\\raggedright\let\\\PBS}
% Non-indexed file name
\newcommand{\nfn}[1]{\texttt{#1}}
% For the examples in the math spacing table.
%%\newcommand{\lspx}{\mbox{\rule{5pt}{.6pt}\rule{.6pt}{6pt}}}
%%\newcommand{\rspx}{\mbox{\rule[-1pt]{.6pt}{7pt}%
%% \rule[-1pt]{5pt}{.6pt}}}
\newcommand{\lspx}{\mathord{\Rightarrow\mkern-1mu}}
\newcommand{\rspx}{\mathord{\mkern-1mu\Leftarrow}}
\newcommand{\spx}[1]{$\lspx #1\rspx$}
% For a list of characters representing document input.
\newcommand{\clist}[1]{%
\mbox{\ntt\spaceskip.2em plus.1em \xspaceskip\spaceskip#1}}
% Fix weird \latex/ definition of rightmark.
\makeatletter
\def\rightmark{\expandafter\@rightmark\botmark{}{}}
% Also turn off section marks.
\let\sectionmark\@gobble
\renewcommand{\chaptermark}[1]{%
\uppercase{\markboth{\rhcn#1}{\rhcn#1}}}
\newcommand{\rhcn}{\thechapter. }
\makeatother
% Include down to \section but not \subsection, in toc:
\setcounter{tocdepth}{1}
% Subheadings for the bibliography
\newif\iffirstbibsubhead \firstbibsubheadtrue
\newcommand{\bibsubhead}[1]{%
\iffirstbibsubhead \firstbibsubheadfalse
\else \addvspace{\medskipamount}
\fi
\item[]\hspace*{-\leftmargin}\textbf{#1}\par
\vspace{\smallskipamount}
}
\DeclareMathOperator{\ix}{ix}
\DeclareMathOperator{\nul}{nul}
\DeclareMathOperator{\End}{End}
\DeclareMathOperator{\xxx}{xxx}
\usepackage{hyperref}
\hypersetup{pdfborder=0 0 0}
\makeatletter
\let\oldcs\cs
\def\cs#1{\texorpdfstring{\oldcs{#1}}{\@backslashchar\@backslashchar#1}}
\let\cn\cs
\makeatother
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frontmatter
\maketitle
\pagestyle{headings}
\tableofcontents
\cleardoublepage % for better page number placement
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mainmatter
\chapter{Introduction}
\index{amsmath@\texttt{amsmath} package|(}
The \nipkg{amsmath} package is a \LaTeX{} package that provides
miscellaneous enhancements for improving the information structure and
printed output of documents that contain mathematical formulas. Readers
unfamiliar with \LaTeX{} should refer to \cite{lamport}. If you have an
up-to-date version of \LaTeX{}, the \nipkg{amsmath} package is normally
provided along with it. Upgrading when a newer version of the
\nipkg{amsmath} package is released can be done via
\url{http://mirror.ctan.org/macros/latex/required/amsmath.zip}.
This documentation describes the features of the \nipkg{amsmath} package
and discusses how they are intended to be used. It also covers some
ancillary packages:
\begin{ctab}{lll}
\pkg{amsbsy}& \pkg{amsopn}& \pkg{amsxtra}\\
\pkg{amscd}& \pkg{amstext}\\
\end{ctab}
These all have something to do with the contents of math formulas. For
information on extra math symbols and math fonts, see \cite{amsfonts}
and \url{https://www.ams.org/tex/amsfonts.html}. For documentation of the
\pkg{amsthm} package or AMS document classes (\cls{amsart},
\cls{amsbook}, etc.\@) see \cite{amsthdoc} or \cite{amshandbk} and
\url{https://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 \nipkg{amsmath} features:
\begin{itemize}
\item A convenient way to define new `operator name' commands analogous
to \cn{sin} and \cn{lim}, including proper side spacing and automatic
selection of the correct font style and size (even when used in
sub- or superscripts).
\item Multiple substitutes for the \env{eqnarray} environment to make
various kinds of equation arrangements easier to write.
\item Equation numbers automatically adjust up or down to avoid
overprinting on the equation contents (unlike \env{eqnarray}).
\item Spacing around equals signs matches the normal spacing in the
\env{equation} environment (unlike \env{eqnarray}).
\item A way to produce multiline subscripts as are often used with
summation or product symbols.
\item An easy way to substitute a variant equation number for a given
equation instead of the automatically supplied number.
\item An easy way to produce subordinate equation numbers of the form
(1.3a) (1.3b) (1.3c) for selected groups of equations.
\end{itemize}
The \nipkg{amsmath} package is distributed together with some small
auxiliary packages:
\begin{description}
\item[\nipkg{amsmath}] Primary package, provides various features for
displayed equations and other mathematical constructs.
\item[\pkg{amstext}] Provides a \cn{text} command for
typesetting a fragment of text inside a display.
\item[\pkg{amsopn}] Provides \cn{DeclareMathOperator} for defining new
`operator names' like \cn{sin} and \cn{lim}.
\item[\pkg{amsbsy}] For backward compatibility this package continues
to exist but use of the newer \pkg{bm} package that comes with \LaTeX{}
is recommended instead.
\item[\pkg{amscd}] Provides a \env{CD} environment for simple
commutative diagrams (no support for diagonal arrows).
\item[\pkg{amsxtra}] Provides certain odds and ends such as
\cn{fracwithdelims} and \cn{accentedsymbol}, for compatibility with
documents created using version 1.1.
\end{description}
The \nipkg{amsmath} package incorporates \pkg{amstext}, \pkg{amsopn}, and
\pkg{amsbsy}. The features of \pkg{amscd} and \pkg{amsxtra}, however,
are available only by invoking those packages separately.
The independent \pkg{mathtools} package \cite{mt} provides some
enhancements to \nipkg{amsmath}; \pkg{mathtools} loads \nipkg{amsmath}
automatically, so there is no need to separately load \nipkg{amsmath}
if \pkg{mathtools} is used. Some \pkg{mathtools} facilities
will be noted below as appropriate.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Options for the \nipkg{amsmath} package}\label{options}
The \nipkg{amsmath} package has the following options:
\index{options!amsmath@\texttt{amsmath} package options|(}
\begin{description}
\item[\opt{centertags}] (default) For an equation containing a
\env{split} environment, place equation
numbers\index{equationn@equation numbers!vertical placement}
vertically centered on the total height of the equation.
\item[\opt{tbtags}] `Top-or-bottom tags': For an equation containing
a \env{split} environment, place equation
numbers\index{equationn@equation numbers!vertical placement} level with the last
(resp.\ first) line, if numbers are on the right (resp.\ left).
\item[\opt{sumlimits}] (default) Place the subscripts and
superscripts\index{subscripts and superscripts!placement}\relax
\index{limits|see{subscripts and superscripts}} of summation symbols
above and below, in displayed equations. This option also affects other
symbols of the same type\mdash $\prod$, $\coprod$, $\bigotimes$,
$\bigoplus$, and so forth\mdash but excluding integrals (see below).
\item[\opt{nosumlimits}] Always place the subscripts and superscripts of
summation-type symbols to the side, even in displayed equations.
\item[\opt{intlimits}] Like \opt{sumlimits}, but for
integral\index{integrals!placement of limits} symbols.
\item[\opt{nointlimits}] (default) Opposite of \opt{intlimits}.
\item[\opt{namelimits}] (default) Like \opt{sumlimits}, but for certain
`operator names' such as $\det$, $\inf$, $\lim$, $\max$, $\min$, that
traditionally have subscripts%
\index{subscripts and superscripts!placement} placed underneath when
they occur in a displayed equation.
\item[\opt{nonamelimits}] Opposite of \opt{namelimits}.
\end{description}
\goodbreak
\begin{description}
\item[\opt{alignedleftspaceyes}]
\item[\opt{alignedleftspaceno}]
\item[\opt{alignedleftspaceyesifneg}]
\end{description}
To use one of these package options, put the option name in the optional
argument of the \cn{usepackage} command\mdash e.g.,
\verb"\usepackage[intlimits]{amsmath}".
For AMS document classes and any other classes that preload \nipkg{amsmath}
desired options must be specified with the \cn{documentclass}\mdash
e.g.,\\
\verb+\documentclass[intlimits,tbtags,reqno]{amsart}+.
The \nipkg{amsmath} package also recognizes the following options which
are normally selected (implicitly or explicitly) through the
\cn{documentclass} command, and thus need not be repeated in the option
list of the \cn{usepackage}|{amsmath}| statement.
\begin{description}
\item[\opt{leqno}] Place equation numbers on the left.%
\index{equationn@equation numbers!left or right placement}
\item[\opt{reqno}] Place equation numbers on the right.
\item[\opt{fleqn}] Position equations at a fixed indent from the left
margin rather than centered in the text column.%
\index{displayed equations!centering}
\end{description}
Three options have been added to control the space to the left of
\env{aligned} and \env{gathered} environments. Prior to the 2017 release
a thin space was added to the left but not the right of these constructs.
This appears to have been an accidental feature of the implementation and
was typically corrected by prefixing the environments with \altcnbang.
The new default behavior is aimed to ensure that the environments do
not have a thin space added in most cases, and that existing documents
using |\!\begin{aligned}| continue to work as before.
\begin{description}
\item[\opt{alignedleftspaceyes}] Always add \cn{\,} to the left of \env{aligned} and \env{gathered}.
\item[\opt{alignedleftspaceno}] Never add \cn{\,} to the left of \env{aligned} and \env{gathered}.
\item[\opt{alignedleftspaceyesifneg}] Only add \cn{\,} if the environment is prefixed by negative space. (New default behavior.)
\end{description}
\index{options!amsmath@\texttt{amsmath} package options|)}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Displayed equations}
\section{Introduction}
The \nipkg{amsmath} package provides a number of additional displayed
equation structures\index{displayed equations}%
\index{equations|see{displayed equations}} beyond the ones
provided in basic \latex/. The augmented set includes:
\begin{verbatim}
equation equation* align align*
gather gather* alignat alignat*
multline multline* flalign flalign*
split
\end{verbatim}
(Although the standard \env{eqnarray} environment remains available,
it is better to use \env{align} or \env{equation}+\env{split} instead.
Within \env{eqnarray}, spacing\index{horizontal spacing} around signs
of relation is not the preferred mathematical spacing, and is
inconsistent with that spacing as it appears in other environments.
Long lines in this environment may result in misplaced or overprinted
equation numbers. This environment also does not support the use of
\cn{qed} or \cn{qedhere} as provided by theorem packages.)
Except for \env{split}, each environment has both starred and unstarred
forms, where the unstarred forms have automatic numbering using
\latex/'s \env{equation} counter. You can suppress the number on any
particular line by putting \cn{notag} before the end of that line;
\cn{notag} should not be used outside a display environment as it will
mess up the numbering. You can also
override\index{equationn@equation numbers!overriding} a number with a tag
of your own using \cn{tag}|{|\<label>|}|, where \<label> means arbitrary
text such as |$*$| or |ii| used to \qq{number} the equation.
A tag can reference a different tagged display by use of
|\tag{\ref{|\<label>|}|\<modifier>|}| where \<modifier> is optional.
If you are using \pkg{hyperref}, use \cn{ref*};
use of the starred form of \cn{ref} prevents a reference to a modified
tag containing a nested link from linking to the original display.
There is also a
\cn{tag*} command that causes the text you supply to be typeset
literally, without adding parentheses around it. \cn{tag} and \cn{tag*}
can also be used within the unnumbered versions of all the \nipkg{amsmath}
alignment structures. Some examples of the use of \cn{tag} may be found
in the sample files \fn{testmath.tex} and \fn{subeqn.tex} provided with
the \nipkg{amsmath} package.
The \env{split} environment is a special subordinate form that is used
only \emph{inside} one of the others. It cannot be used inside
\env{multline}, however. \env{split} supports only one alignment (|&|)
column; if more are needed, \env{aligned} or \env{alignedat} should be
used. The width of a \env{split} structure is the full line width.
In the structures that do alignment (\env{split}, \env{align} and
variants), relation symbols have an |&| before them but not
after\mdash unlike \env{eqnarray}. Putting the |&| after the
relation symbol will interfere with the normal spacing; it has to go
before.
In all multiline environments, lines are divided by \cn{\\}. The \cn{\\}
should \emph{not} be used to end the last line. Using it there will
result in unwanted extra vertical space following the display.
In \emph{all} math environments (inline or display), blank lines
(equivalent to \cn{par}) are not permitted, and will result in an error.
\begin{table}[p]
\caption[]{Comparison of displayed equation environments (vertical lines
indicating nominal margins)}\label{displays}
\renewcommand{\theequation}{\arabic{equation}}
\begin{eqxample}
\begin{verbatim}
\begin{equation*}
a=b
\end{equation*}
\end{verbatim}
\producing
\begin{equation*}
a=b
\end{equation*}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{equation}
a=b
\end{equation}
\end{verbatim}
\producing
\begin{equation}
a=b
\end{equation}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{equation}\label{xx}
\begin{split}
a& =b+c-d\\
& \quad +e-f\\
& =g+h\\
& =i
\end{split}
\end{equation}
\end{verbatim}
\producing
\begin{equation}\label{xx}
\begin{split}
a& =b+c-d\\
& \quad +e-f\\
& =g+h\\
& =i
\end{split}
\end{equation}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{multline}
a+b+c+d+e+f\\
+i+j+k+l+m+n
\end{multline}
\end{verbatim}
\producing
\begin{multline}
a+b+c+d+e+f\\
+i+j+k+l+m+n
\end{multline}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{gather}
a_1=b_1+c_1\\
a_2=b_2+c_2-d_2+e_2
\end{gather}
\end{verbatim}
\producing
\begin{gather}
a_1=b_1+c_1\\
a_2=b_2+c_2-d_2+e_2
\end{gather}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{align}
a_1& =b_1+c_1\\
a_2& =b_2+c_2-d_2+e_2
\end{align}
\end{verbatim}
\producing
\begin{align}
a_1& =b_1+c_1\\
a_2& =b_2+c_2-d_2+e_2
\end{align}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{align}
a_{11}& =b_{11}&
a_{12}& =b_{12}\\
a_{21}& =b_{21}&
a_{22}& =b_{22}+c_{22}
\end{align}
\end{verbatim}
\producing
\begin{align}
a_{11}& =b_{11}&
a_{12}& =b_{12}\\
a_{21}& =b_{21}&
a_{22}& =b_{22}+c_{22}
\end{align}
\end{eqxample}
\begin{eqxample}
\begin{verbatim}
\begin{flalign*}
a_{11} + b_{11}& = c_{11}&
a_{12}& =b_{12}\\
b_{21}& = c_{21}&
a_{22}& =b_{22}+c_{22}
\end{flalign*}
\end{verbatim}
\producing
\begin{flalign*}
a_{11} + b_{11}& = c_{11}&
a_{12}& =b_{12}\\
b_{21}& = c_{21}&
a_{22}& =b_{22}+c_{22}
\end{flalign*}
\end{eqxample}
\end{table}
%% ------------------------------------------------------------------ %%
\enlargethispage{1\baselineskip}
\section{Single equations}
The \env{equation} environment is for a single equation with an
automatically generated number. The \env{equation*} environment is the
same except for omitting the number.%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\footnote{Basic \latex/ doesn't provide an \env{equation*} environment,
but rather a functionally equivalent environment named
\env{displaymath}.}
The wrapper \verb+\[ ... \]+ is equivalent to \env{equation*}.%
\index{[@\verb+\[ ... \]+}
%% ------------------------------------------------------------------ %%
\section{Split equations without alignment}
The \env{multline} environment is a variation of the \env{equation}
environment used for equations that don't fit on a single line. The
first line of a \env{multline} will be at the left margin and the last
line at the right margin, except for an indention on both sides in the
amount of \cn{multlinegap}. Any additional lines in between will be
centered independently within the display width (unless the \opt{fleqn}
option is in effect).%
\index{options!behavior of particular options}
Like \env{equation}, \env{multline} has only a single equation number
(thus, none of the individual lines should be marked with \cn{notag}).
The equation number is placed on the last line (\opt{reqno} option) or
first line (\opt{leqno} option); vertical centering as for \env{split}
is not supported by \env{multline}.%
\index{options!behavior of particular options}
It's possible to force one of the middle lines to the left or right with
commands \cn{shoveleft}, \cn{shoveright}. These commands take the entire
line as an argument, up to but not including the final \cn{\\}; for
example
\begin{multline}
\framebox[.65\columnwidth]{A}\\
\framebox[.5\columnwidth]{B}\\
\shoveright{\framebox[.55\columnwidth]{C}}\\
\framebox[.65\columnwidth]{D}
\end{multline}
\begin{verbatim}
\begin{multline}
\framebox[.65\columnwidth]{A}\\
\framebox[.5\columnwidth]{B}\\
\shoveright{\framebox[.55\columnwidth]{C}}\\
\framebox[.65\columnwidth]{D}
\end{multline}
\end{verbatim}
The value of \cn{multlinegap} can be changed with the usual \latex/
commands \cn{setlength} or \cn{addtolength}.
%% ------------------------------------------------------------------ %%
\section{Split equations with alignment}
Like \env{multline}, the \env{split} environment is for \emph{single}
equations that are too long to fit on one line and hence must be split
into multiple lines. Unlike \env{multline}, however, the \env{split}
environment provides for alignment among the split lines, using |&| to
mark alignment points. Unlike the other \nipkg{amsmath} equation
structures, the \env{split} environment provides no numbering, because
it is intended to be used \emph{only inside some other displayed
equation structure}, usually an \env{equation}, \env{align}, or
\env{gather} environment, which provides the numbering. For example:
\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].
\kern-2em % adjust equation body to the right [mjd,13-Nov-1994]
\end{split}\end{equation}
\begin{verbatim}
\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}
\end{verbatim}
The \env{split} structure should constitute the entire body of the
enclosing structure, apart from commands like \cn{label} that produce no
visible material.
%% ------------------------------------------------------------------ %%
\section{Equation groups without alignment}
The \env{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~\ref{displays}).
Equations inside \env{gather} are separated by a \cn{\\} command.
Any equation in a \env{gather} may consist of a \verb'\begin{split}'
\dots\ \verb'\end{split}' structure\mdash for example:
\begin{verbatim}
\begin{gather}
first equation\\
\begin{split}
second & equation\\
& on two lines
\end{split}
\\
third equation
\end{gather}
\end{verbatim}
%% ------------------------------------------------------------------ %%
\section{Equation groups with mutual alignment}
The \env{align} environment is used for two or more equations when
vertical alignment is desired; usually binary relations such as equal
signs are aligned (see Table~\ref{displays}).
To have several equation columns side-by-side, use extra ampersands
to separate the columns:
\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}
%
\begin{verbatim}
\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}
\end{verbatim}
Line-by-line annotations on an equation can be done by judicious
application of \cn{text} inside an \env{align} environment:
\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}
%
\begin{verbatim}
\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}
\end{verbatim}
A variant environment \env{alignat} allows the horizontal space between
equations to be explicitly specified. This environment takes one argument,
the number of \qq{equation columns} (the number of pairs of right-left
aligned columns; the argument is the number of pairs): count the maximum
number of \verb'&'s in any row, add~1 and divide by~2.
\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}
%
\begin{verbatim}
\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}
\end{verbatim}
The environment \env{flalign} (``full length alignment'') stretches the
space between the equation columns to the maximum possible width, leaving
only enough space at the margin for the equation number, if present.
\begin{flalign}
x&=y & X&=Y\\
x'&=y' & X'&=Y'\\
x+x'&=y+y' & X+X'&=Y+Y'
\end{flalign}
%
\begin{verbatim}
\begin{flalign}
x&=y & X&=Y\\
x'&=y' & X'&=Y'\\
x+x'&=y+y' & X+X'&=Y+Y'
\end{flalign}
\end{verbatim}
%
\begin{flalign*}
x&=y & X&=Y\\
x'&=y' & X'&=Y'\\
x+x'&=y+y' & X+X'&=Y+Y'
\end{flalign*}
%
\begin{verbatim}
\begin{flalign*}
x&=y & X&=Y\\
x'&=y' & X'&=Y'\\
x+x'&=y+y' & X+X'&=Y+Y'
\end{flalign*}
\end{verbatim}
%% ------------------------------------------------------------------ %%
\section{Alignment building blocks}
Like \env{equation}, the multi-equation environments \env{gather},
\env{align}, and \env{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\index{ed env@\texttt{-ed} environments|(}
\env{gathered}, \env{aligned}, and \env{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.,
\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*}
\begin{verbatim}
\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*}
\end{verbatim}
Like the \env{array} environment, these \texttt{-ed} variants also take
an optional\index{options!positioning of \texttt{-ed} environments}
|[t]|\index{t option@\texttt{t} (top) option},
|[b]|\index{b option@\texttt{b} (bottom) option} or the default
|[c]|\index{c option@\texttt{c} (center) option}
argument to specify vertical
positioning. For maximum interoperability, do not insert a
space\index{options!space before \texttt{[}}
or line break\index{line break} before the option. See
also the note on page~\pageref{breaknote} regarding page breaking
within the \texttt{-ed} environments.
\qq{Cases} constructions like the following are common in
mathematics:
\begin{equation}\label{eq:C}
P_{r-j}=
\begin{cases}
0& \text{if $r-j$ is odd},\\
r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}.
\end{cases}
\end{equation}
and in the \nipkg{amsmath} package there is a \env{cases} environment to
make them easy to write:
\begin{verbatim}
P_{r-j}=\begin{cases}
0& \text{if $r-j$ is odd},\\
r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}.
\end{cases}
\end{verbatim}
Notice the use of \cn{text} (cf.~\secref{text}) and the nested math
formulas. \env{cases} is set in \cn{textstyle}. If \cn{displaystyle}
is wanted, it must be requested explicitly; \pkg{mathtools} provides
a \env{dcases} environment for this purpose.
The |-ed|\index{ed env@\texttt{-ed} environments|)} and \env{cases}
environments must appear within an enclosing math environment, which can
be either in text, between |$...$|, or in any of the display environments.
%% ------------------------------------------------------------------ %%
\section{Adjusting tag placement}
Placing equation numbers can be a rather complex problem in multiline
displays. The environments of the \nipkg{amsmath} package try hard to
avoid overprinting an equation number on the equation contents, if
necessary moving the number down or up to a separate line. Difficulties
in accurately calculating the profile of an equation can occasionally
result in number movement that doesn't look right.
A \cn{raisetag} command is provided to adjust the vertical position of the
current equation number, if it has been shifted away from its normal
position. If it is in its normal position the command has no effect whatsoever.
In particular, this means that one can't use it to shift the tag of an \env{equation}
environment.
To move a particular number up by six points, write
|\raisetag{6pt}|. (At the end of a display, this also shifts up the
text following the display.)
This kind of adjustment is fine tuning like line
breaks and page breaks, and should therefore be left undone until your
document is nearly finalized, or you may end up redoing the fine tuning
several times to keep up with changing document contents.
%% ------------------------------------------------------------------ %%
\section{Vertical spacing and page breaks in multiline displays}
You can use the \cn{\\}|[|\<dimension>|]|%
\index{options!extra vertical space after \cn{\\}}
command to get extra vertical
space between lines in all the \nipkg{amsmath} displayed equation
environments, as is usual in \latex/. Do not type a space between the%
\index{options!space before \texttt{[}}
\cn{\\} and the following |[|; \emph{only} for display environments
defined by \nipkg{amsmath} the space is interpreted to mean that the
bracketed material is part of the document content.
When the \nipkg{amsmath} package is
in use \ii{page breaks} between equation lines are normally disallowed;
the philosophy is that page breaks in such material should receive
individual attention from the author. To get an individual page break
inside a particular displayed equation, a \cn{displaybreak} command is
provided. \cn{displaybreak} is best placed immediately before the
\cn{\\} where it is to take effect. Like \latex/'s \cn{pagebreak},
\cn{displaybreak} takes an optional argument%
\index{options!behavior of particular options} between 0 and 4 denoting
the desirability of the pagebreak. |\displaybreak[0]| means \qq{it is
permissible to break here} without encouraging a break;
\cn{displaybreak} with no optional argument is the same as
|\displaybreak[4]| and forces a break.
If you prefer a strategy of letting page breaks fall where they may,
even in the middle of a multiline equation, then you might put
\cn{allowdisplaybreaks}\texttt{[1]} in the preamble of your document. An
optional argument\index{options!behavior of particular options}
1\ndash 4 can be used for finer control: |[1]| means
allow page breaks, but avoid them as much as possible; values of 2,3,4
mean increasing permissiveness. When display breaks are enabled with
\cn{allowdisplaybreaks}, the \cn{\\*} command can be used to prohibit a
pagebreak after a given line, as usual.
\begin{bfseries}
Note:\label{breaknote} Certain equation environments wrap their contents
in an unbreakable box, with the consequence that neither \cn{displaybreak}
nor \cn{allowdisplaybreaks} will have any effect on them. These include
\env{split}, \env{aligned}, \env{gathered}, and \env{alignedat}.
\end{bfseries}
%% ------------------------------------------------------------------ %%
\section{Interrupting a display}
The command \cn{intertext} is used for a short interjection of one or
two lines of text\index{text fragments inside math} in the middle of a
multiple-line display structure (see also the \cn{text} command in
\secref{text}). 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. \cn{intertext} may only appear right after a
\cn{\\} or \cn{\\*} command. Notice the position of the word \qq{and} in
this example.
\begin{align}