summaryrefslogtreecommitdiff
path: root/macros/lamstex/inputs/alignat.tex
blob: 4e23304c68533604f57eb3888da06f06f1939ff9 (plain)
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
\catcode`\@=11
\def\alignedat#1{\null\,\vcenter\bgroup\doat@{#1}\vspace@\Let@
 \ifinany@\else\openup\jot\fi\ialign\bgroup\span\preamble@@\crcr}
\def\doat@#1{\toks@{\hfil\strut@$\m@th
 \displaystyle{\the\hashtoks@}$&$\m@th\displaystyle
 {{}\the\hashtoks@}$\hfil}%
 \atcount@#1\relax\advance\atcount@\m@ne
 \loop\ifnum\atcount@>\z@\toks@=\expandafter{\the\toks@&\hfil$\m@th
 \displaystyle{\the\hashtoks@}$&$\m@th
 \displaystyle{{}\the\hashtoks@}$\hfil}\advance\atcount@\m@ne\repeat
 \edef\preamble@{\the\toks@}\edef\preamble@@{\preamble@}}
\let\endalignedat\endaligned
\def\alignat{\RIfMIfI@\DN@{\onlydmatherr@\alignat}\else
 \DN@{\csname alignat \endcsname}\fi\else
 \DN@{\onlydmatherr@\alignat}\fi\next@}
\expandafter\def\csname alignat \endcsname#1#2\endalignat
 {\inany@true\xat@false
 \def\tag{\global\tag@true
  \count@#1\relax\multiply\count@\tw@\advance\count@\m@ne
  \gdef\tag@{&}%
  \loop\ifnum\count@>\and@\xdef\tag@{&\omit\tag@}%
  \advance\count@\m@ne\repeat
  \tag@\relax}%
 \vspace@\allowdisplaybreak@\displaybreak@\intertext@
 \displ@y@\measuring@true\tag@CC\tag@C
 \setbox\savealignat@\hbox{\noset@\unlabel@$\m@th\displaystyle\Let@
  \attag@{#1}\vbox{\halign{\span\preamble@@\crcr#2\crcr}}$}%
 \measuring@false
 \Let@\attag@{#1}\tag@C\tag@CC
 \tabskip\centering@\halign to\displaywidth
  {\span\preamble@@\crcr#2\crcr\black@{\wd\savealignat@}}}
\Invalid@\endalignat
\def\xalignat{\RIfMIfI@
 \DN@{\onlydmatherr@\xalignat}\else
 \DN@{\csname xalignat \endcsname}\fi\else
 \DN@{\onlydmatherr@\xalignat}\fi\next@}
\expandafter\def\csname xalignat \endcsname#1#2\endxalignat
 {\inany@true\xat@true
 \def\tag{\global\tag@true
  \count@#1\relax\multiply\count@\tw@\advance\count@\m@ne
  \gdef\tag@{&}%
  \loop\ifnum\count@>\and@\xdef\tag@{&\omit\tag@}%
  \advance\count@\m@ne\repeat
  \tag@\relax}%
 \vspace@\allowdisplaybreak@\displaybreak@\intertext@
 \displ@y@\measuring@true\tag@CC\tag@C
 \setbox\savealignat@\hbox{\noset@\unlabel@$\m@th\displaystyle\Let@
  \attag@{#1}\vbox{\halign{\span\preamble@@\crcr#2\crcr}}$}%
 \measuring@false\Let@\attag@{#1}\tag@C\tag@CC
 \tabskip\centering@\halign to\displaywidth
 {\span\preamble@@\crcr#2\crcr\black@{\wd\savealignat@}}}
\def\attag@#1{\let\Maketag@\maketag@\let\TAG@\Tag@
 \let\Prepost@\prepost@\let\Reprepost@\reprepost@
 \let\Tag@\relax\let\maketag@\relax
 \let\prepost@\relax\let\reprepost@\relax
 \ifmeasuring@
  \def\llap@##1{\setboxz@h{##1}\hbox to\tw@\wdz@{}}%
  \def\rlap@##1{\setboxz@h{##1}\hbox to\tw@\wdz@{}}%
 \else\let\llap@\llap\let\rlap@\rlap\fi
 \toks@{\hfil\strut@
  $\m@th\displaystyle{\@lign\the\hashtoks@\prepost@}$%
  \tabskip\z@skip\global\advance\and@\@ne&
  $\m@th\displaystyle{{}\@lign\the\hashtoks@\prepost@}$\hfil
  \ifxat@\tabskip\centering@\fi\global\advance\and@\@ne}%
 \iftagsleft@
  \toks@@{\tabskip\centering@&\Tag@\kern-\displaywidth
   \rlap@{\@lign\reprepost@\maketag@\the\hashtoks@\maketag@}%
   \global\advance\and@\@ne\tabskip\displaywidth}\else
  \toks@@{\tabskip\centering@&\Tag@\llap@{\@lign\reprepost@\maketag@
   \the\hashtoks@\maketag@}\global\advance\and@\@ne\tabskip\z@skip}\fi
 \atcount@#1\relax\advance\atcount@\m@ne
 \loop\ifnum\atcount@>\z@
  \toks@\expandafter{\the\toks@&\hfil$\m@th\displaystyle{\@lign
  \the\hashtoks@\prepost@}$\global\advance\and@\@ne
  \tabskip\z@skip
  &$\m@th\displaystyle{{}\@lign\the\hashtoks@\prepost@}$\hfil\ifxat@
  \tabskip\centering@\fi\global\advance\and@\@ne}\advance\atcount@\m@ne
 \repeat
 \edef\preamble@{\the\toks@\the\toks@@}%
 \edef\preamble@@{\preamble@}%
 \let\maketag@\Maketag@\let\Tag@\TAG@
 \let\prepost@\Prepost@\let\reprepost@\Reprepost@}
\Invalid@\endxalignat
\def\xxalignat{\RIfMIfI@
 \DN@{\onlydmatherr@\xxalignat}\else\DN@{\csname xxalignat
  \endcsname}\fi\else
 \DN@{\onlydmatherr@\xxalignat}\fi\next@}
\expandafter\def\csname xxalignat \endcsname#1#2\endxxalignat{\inany@true
 \vspace@\allowdisplaybreak@\displaybreak@\intertext@
 \displ@y\setbox\savealignat@\hbox{$\m@th\displaystyle\Let@
 \xxattag@{#1}\vbox{\halign{\span\preamble@@\crcr#2\crcr}}$}%
 \Let@\xxattag@{#1}\tabskip\z@skip\halign to\displaywidth
 {\span\preamble@@\crcr#2\crcr\black@{\wd\savealignat@}}}
\def\xxattag@#1{\toks@{\tabskip\z@skip\hfil\strut@
 $\m@th\displaystyle{\the\hashtoks@}$&%
 $\m@th\displaystyle{{}\the\hashtoks@}$\hfil\tabskip\centering@&}%
 \atcount@#1\relax\advance\atcount@\m@ne\loop\ifnum\atcount@>\z@
 \toks@=\expandafter{\the\toks@&\hfil$\m@th\displaystyle{\the\hashtoks@}$%
  \tabskip\z@skip&$\m@th\displaystyle{{}\the\hashtoks@}$\hfil
  \tabskip\centering@}\advance\atcount@\m@ne\repeat
 \edef\preamble@{\the\toks@\tabskip\z@skip}\edef\preamble@@{\preamble@}}
\Invalid@\endxxalignat
\catcode`\@=\active