Debian Codegraph @

texmf-dist/source/latex/eqnlines/eqnlines.dtx

raw
1 %
2 % \iffalse meta-comment
3 %
4 % eqnlines.dtx Copyright (C) 2024-2026 Niklas Beisert
5 %
6 % Based on the latex package amsmath:
7 % Copyright (C) 1995, 2000, 2013 American Mathematical Society.
8 % Copyright (C) 2016-2024 LaTeX Project and American Mathematical Society.
9 %
10 % This work may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This work has the LPPL maintenance status `maintained'.
19 %
20 % The Current Maintainer of this work is Niklas Beisert.
21 %
22 % This work consists of the files eqnlines.dtx and eqnlines.ins
23 % and the derived files eqnlines.sty,
24 % eqnlines.tex, eqnlines.pdf, eqnlines-src.tex, eqnlines-src.pdf.
25 %
26 %<package>\NeedsTeXFormat{LaTeX2e}[2020-10-01]
27 %<package>\ProvidesPackage{eqnlines}[2026-03-23 v1.0.1 Single- and multi-line equations]
28 %<source>\ProvidesFile{eqnlines-src.tex}[2026-03-23 v1.0.1 eqnlines source code documentation]
29 %<manual>\ProvidesFile{eqnlines.tex}[2026-03-23 v1.0.1 eqnlines reference manual]
30 %<*main|manual|source>
31 \def\thepkg/{eqnlines}\def\thedate/{2026-03-23}\def\theversion/{v1.0.1}
32 \def\thecopyright/{2024\texorpdfstring{--}{-}2026 Niklas Beisert}
33 %<*main>
34 \ProvidesFile{\thepkg/.dtx}[\thedate/ \theversion/ \thepkg/ package main file]
35 %</main>
36 \PassOptionsToClass{10pt,a4paper}{article}
37 \documentclass{ltxdoc}
38
39 \usepackage[margin=35mm]{geometry}
40 \usepackage[hyperindex=false]{hyperref}
41 \usepackage{hyperxmp}
42 \usepackage[usenames]{color}
43 \usepackage{longtable}
44
45 %<*main>
46 \title{The \markpkg{\thepkg/} Package}
47 \hypersetup{pdftitle={The \thepkg/ Package}}
48 \hypersetup{pdfsubject={Documentation for the LaTeX2e Package \thepkg/}}
49 %</main>
50 %<manual>\title{The \markpkg{\thepkg/} Package\\Reference Manual}
51 %<manual>\hypersetup{pdftitle={The \thepkg/ Package -- Reference Manual}}
52 %<manual>\hypersetup{pdfsubject={Reference Manual for the LaTeX2e Package \thepkg/}}
53 %<source>\title{The \markpkg{\thepkg/} Package\\Source Code Documentation}
54 %<source>\hypersetup{pdftitle={The \thepkg/ Package -- Source Code Documentation}}
55 %<source>\hypersetup{pdfsubject={Documented Source for the LaTeX2e Package \thepkg/}}
56 \author{Niklas Beisert\\[2ex]
57 Institut f\"ur Theoretische Physik\\
58 Eidgen\"ossische Technische Hochschule Z\"urich\\
59 Wolfgang-Pauli-Strasse 27, 8093 Z\"urich, Switzerland\\[1ex]
60 \href{mailto:[email protected]}
61 {\texttt{[email protected]}}}
62 \hypersetup{pdfauthor={Niklas Beisert}}
63 \date{\theversion/: \markdate{\thedate/}\\[1ex]
64 \url{https://ctan.org/pkg/\thepkg/}\\[0.5ex]
65 \url{https://github.com/nbeisert/latex-pkg-nb}}
66
67 \hypersetup{pdflang={en-UK}}
68 \hypersetup{pdfurl={https://ctan.org/pkg/\thepkg/}}
69 \hypersetup{pdfcopyright={Copyright \thecopyright/.
70 This work may be distributed and/or modified under the
71 conditions of the LaTeX Project Public License, either version 1.3
72 of this license or (at your option) any later version.}}
73 \hypersetup{pdflicenseurl={https://www.latex-project.org/lppl.txt}}
74 \hypersetup{pdfcontactaddress={ETH Zurich, ITP, HIT K,
75 Wolfgang-Pauli-Strasse 27}}
76 \hypersetup{pdfcontactpostcode={8093}}
77 \hypersetup{pdfcontactcity={Zurich}}
78 \hypersetup{pdfcontactcountry={Switzerland}}
79 \hypersetup{pdfcontactemail={[email protected]}}
80 \hypersetup{pdfcontacturl={https://people.phys.ethz.ch/\xmptilde nbeisert/}}
81
82 \hypersetup{keeppdfinfo=true}
83 \hypersetup{pdfsource={}}
84 \AddToHook{begindocument/before}{\hypersetup{colorlinks=false}}
85 \hypersetup{urlbordercolor={.5 1 1}}
86 \hypersetup{linkbordercolor={1 .7 .7}}
87 \AddToHook{begindocument/before}{\hypersetup{pdfstartview=FitH}}
88
89 \parskip1ex
90 \parindent0pt
91 \edef\itemize{\unexpanded\expandafter{\itemize}\parskip0pt}
92
93 \newcommand{\markpkg}[1]{\textsf{#1}}
94 \newcommand{\markdate}[1]{\textsf{#1}}
95 \newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}}
96 \newcommand{\ctanref}[2]{\href{https://ctan.org/#1}{#2}}
97 \newcommand{\ctanpkg}[1]{\ctanref{pkg/#1}{\markpkg{#1}}}
98
99 \def\verbbar{\texttt{\char"7C}}
100 \def\verbpkg{\texttt{\thepkg/}}
101 \def\thepkgctan/{\ctanpkg{\thepkg/}}
102
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104
105 \RenewDocElement[macrolike = true ,
106 toplevel = false,
107 idxtype = ,
108 idxgroup = LaTeX commands\actualchar\latex/ commands ,
109 printtype =
110 ]{Macro}{macro}
111 \RenewDocElement[macrolike = false ,
112 toplevel = false,
113 idxtype = env. ,
114 idxgroup = Package environments,
115 printtype = \textit{env.}
116 ]{Env}{environment}
117 \NewDocElement[macrolike = true ,
118 toplevel = false,
119 idxtype = ,
120 idxgroup = Package commands,
121 printtype =
122 ]{InterfaceMacro}{imacro}
123 \NewDocElement[macrolike = true ,
124 toplevel = false,
125 idxtype = ,
126 idxgroup = Package commands (obsolete),
127 printtype =
128 ]{ObsoleteInterfaceMacro}{omacro}
129 \NewDocElement[macrolike = false ,
130 toplevel = false,
131 idxtype = key ,
132 idxgroup = Package keys ,
133 printtype = \textit{key}
134 ]{Key}{key}
135 \NewDocElement[macrolike = false ,
136 toplevel = false,
137 idxtype = mod ,
138 idxgroup = Command modifiers ,
139 printtype = \textit{mod.}
140 ]{Mod}{modifier}
141 \NewDocElement[macrolike = false ,
142 toplevel = false,
143 idxtype = ctrl ,
144 idxgroup = Control key ,
145 printtype = \textit{ctrl.}
146 ]{Control}{controlkey}
147 \NewDocElement[macrolike = false ,
148 toplevel = false,
149 idxtype = setup ,
150 idxgroup = Setup key ,
151 printtype = \textit{setup}
152 ]{Setup}{setupkey}
153 \NewDocElement[macrolike = false ,
154 toplevel = false,
155 idxtype = opt ,
156 idxgroup = Option key ,
157 printtype = \textit{opt.}
158 ]{Option}{optionkey}
159 \NewDocElement[macrolike = true ,
160 toplevel = false,
161 idxtype = counter ,
162 idxgroup = TeX counters\actualchar \protect\tex/ counters ,
163 printtype = \textit{counter}
164 ]{TeXCounter}{tcounter}
165 \NewDocElement[macrolike = false ,
166 toplevel = false,
167 idxtype = counter ,
168 idxgroup = LaTeX counters\actualchar \latex/ counters ,
169 printtype = \textit{counter}
170 ]{LaTeXCounter}{lcounter}
171 \NewDocElement[macrolike = true ,
172 toplevel = false,
173 idxtype = skip ,
174 idxgroup = LaTeX length\actualchar \latex/ length (skip) ,
175 printtype = \textit{skip}
176 ]{LaTeXSkip}{lskip}
177 \NewDocElement[macrolike = true ,
178 toplevel = false,
179 idxtype = dimen ,
180 idxgroup = LaTeX length\actualchar \latex/ length (dimen) ,
181 printtype = \textit{dimen}
182 ]{LaTeXDimen}{ldimen}
183 \NewDocElement[macrolike = true ,
184 toplevel = false,
185 idxtype = box ,
186 idxgroup = LaTeX box\actualchar \latex/ box ,
187 printtype = \textit{box}
188 ]{LaTeXBox}{lbox}
189 \NewDocElement[macrolike = true ,
190 toplevel = false,
191 idxtype = bool ,
192 idxgroup = eqnlines bool\actualchar eqnlines bool ,
193 printtype = \textit{bool}
194 ]{eqnlinesBool}{ebool}
195 \NewDocElement[macrolike = true ,
196 toplevel = false,
197 idxtype = bool ,
198 idxgroup = LaTeX conditional\actualchar \latex/ conditional ,
199 printtype = \textit{bool}
200 ]{LaTeXConditional}{lcond}
201
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203
204 \usepackage{verbatim}
205 \makeatletter
206 \def\example@addline#1{%
207 \g@addto@macro\example@dbuf{#1 }%
208 \g@addto@macro\example@pbuf{\item|#1|}}
209 \def\scanexample{%
210 \gdef\example@dbuf{}%
211 \gdef\example@pbuf{}%
212 \begingroup
213 \@bsphack
214 \let\do\@makeother\dospecials
215 \catcode`\^^M\active
216 \def\verbatim@processline{\expandafter\example@addline\expandafter%
217 {\the\verbatim@line}}%
218 \verbatim@start}
219 \def\endscanexample{\@esphack\endgroup\ignorespacesafterend}
220 \def\printexample{\begingroup
221 \topsep\z@skip\parsep\z@skip\itemsep\z@skip\partopsep\z@skip\parskip\z@skip
222 \trivlist
223 \expandafter\scantokens\expandafter{\example@pbuf}%
224 \endtrivlist
225 \endgroup}
226 \def\doexample{\expandafter\scantokens\expandafter{\example@dbuf}}
227 \newcommand{\showexampleh}[1][0.5]{\par%
228 \parbox{\dimexpr#1\textwidth\relax}{\printexample}%
229 \parbox{\dimexpr\textwidth-#1\textwidth\relax}{\doexample}%
230 \par\medskip\ignorespaces}
231 \newcommand{\showexamplev}{%
232 \printexample
233 \par\medskip
234 \parbox{\textwidth}{\doexample}%
235 \par\medskip\ignorespaces}
236 \newenvironment{example}
237 {\parskip\z@skip\par\medskip\hrule\medskip}
238 {\par\hrule\par\medskip}
239 \makeatother
240
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242
243 \newcommand{\TODO}{\textbf{\textcolor{red}{TODO:}} }
244
245 \def\tex/{\TeX}
246 \def\latex/{\LaTeX}
247 \def\amsmath/{\ctanpkg{amsmath}}
248
249 \usepackage{eqnlines}
250 \eqnlinesset{belowtopmode=top,belowtopskip=0pt}
251 \def\pstrut{\vphantom{(}}
252 \def\bstrut{\vphantom{b}}
253
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 \begin{document}
258
259 \maketitle
260
261 \begin{abstract}\noindent
262 \markpkg{eqnlines} is a \LaTeXe{} package providing
263 a framework for typesetting single- and multi-line equations
264 which extends the established equation environments
265 of \latex/ and the \markpkg{amsmath} package
266 with many options for convenient adjustment of the intended layout.
267 In particular, the package adds flexible schemes for numbering,
268 horizontal alignment and semi-automatic punctuation, and it improves
269 upon the horizontal and vertical spacing options. The extensions can
270 be used and adjusted through optional arguments and modifiers to the
271 equation environments as well as global settings.
272 \end{abstract}
273
274 \begingroup
275 \parskip0ex
276 \tableofcontents
277 \endgroup
278
279
280 %<*main|manual>
281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
283 \section{Introduction}
284
285 Typesetting mathematical equations is an undisputed strength of \tex/.
286 \latex/ improved the overall management of display equations,
287 for instance by providing optional numbering.
288 It also added elementary functionality for multi-line equations
289 with alignment. Some of its deficiencies were addressed by
290 the multi-line equation environments of the package \amsmath/
291 which have become an established standard for these purposes.
292
293 The package \ctanpkg{eqnlines} builds upon and extends
294 the functionality of the \latex/ and \amsmath/
295 equation environments with some new features
296 as well as convenient options to adjust the layout where needed.
297 The main additions are as follows:
298 %
299 \begin{itemize}
300 \item
301 Equation numbers can be assigned to individual lines
302 (as for |align| and |gather|)
303 or once for the multi-line equation block
304 (as for |multline|).
305 In the former case,
306 a sub-numbering scheme can be applied (as through |subequations|).
307 In the latter case, the position can be assigned to a specific line
308 (first/middle/last/chosen).
309 Moreover, equation numbers can be turned on and off by commands,
310 and they can be triggered by setting a label.
311 \item
312 The vertical spacing above and below single- and multi-line equations
313 of \latex/ and \amsmath/ can be somewhat variable,
314 hard to control and even resistive in certain situations.
315 The package implements clearer structures controlling the vertical spacing,
316 including proper dependency on the text line above
317 and ways to adjust the spacing.
318 \item
319 The framework introduces a scheme which semi-automatically inserts punctuation,
320 e.g.\ `.' or `,', at the end of the following (or every) equation environment.
321 Punctuation can also be inserted at every alignment column or equation line
322 including the possibility to prepend a certain spacing.
323 \item
324 Next to |\[|\,\ldots|\]| as an alias for the single-line |equation| environment,
325 the package uses |\<|\,\ldots|\>| as an alias multi-line equations.
326 \item
327 The horizontal alignment and indentation of equation lines
328 can be adjusted via a scheme or on a line-by-line basis.
329 \item
330 The alignment marker can be placed
331 before or after the equation signs while maintaining proper spacing
332 to symbols before and after it.
333 This simplifies the construction of continuing equations
334 in an aligned context.
335 \item
336 Equation lines are subject to shrinking of space
337 if the available space does not suffice
338 (analogously to single-line equations).
339 \item
340 Most settings can be controlled via optional arguments and modifiers to the
341 equation environment or via global settings.
342 This includes switching between different types of equation environments,
343 enabling or disabling numbering, adjusting vertical spacing, etc.
344 This feature simplifies the adjustment and fine-tuning of equations
345 towards the intended layout.
346 \item
347 Last but not least, the underlying \amsmath/ code,
348 originating from the \tex/ era and early \latex/ years,
349 has been redesigned with emphasis
350 on clarity, readability, adjustability and maintainability
351 (but at the cost of moderately higher resource consumption
352 and moderately lower efficiency).
353 Nevertheless, it remains original \LaTeXe{} code
354 without using the \markpkg{expl3} layer.
355 \end{itemize}
356
357 The package represents a stand-alone implementation
358 of an equations environment
359 which is largely compatible with the established \latex/ and \amsmath/
360 environments |equation|, |multline|, |gather|, |align|
361 and their variants.
362 Hence, the package can be used instead of \amsmath/
363 with no or minor modifications to the \latex/ sources for
364 single- and multi-line equations.
365 It can also be used alongside \amsmath/
366 including the \ctanpkg{mathtools} extensions
367 to make use of the additional maths typesetting features
368 provided by these packages.
369 In the latter case,
370 the equation environments of \latex/ and \amsmath/
371 are either replaced or left in place while the \ctanpkg{eqnlines}
372 environments can be accessed using the alternate name |equations|.
373
374
375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377 \section{Usage}
378 \label{sec:usage}
379
380 To use the \ctanpkg{eqnlines} package add the command
381 %
382 \begin{center}
383 |\usepackage{eqnlines}|
384 \end{center}
385 %
386 to the preamble of the \latex/ document.
387 To use unrelated features of the \amsmath/ package
388 or of the \ctanpkg{mathtools} extension,
389 it makes sense to load these packages \emph{before} \ctanpkg{eqnlines}.
390
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392 \subsection{Equations Environment}
393 \label{sec:equations}
394
395 The package provides the principal environment |equations|:
396 %
397 \begin{center}
398 \begin{tabular}{l}
399 |\begin{equations}[|\textit{opts}|]|
400 \\
401 \textit{math content}
402 \\
403 |\end{equations}|
404 \end{tabular}
405 \end{center}
406 %
407 It combines and generalises the \latex/ environments
408 |displaymath| and |equation|
409 with the \amsmath/ environments |multline|, |gather| and |align|
410 to display \textit{math content} consisting of single or multiple
411 equation lines and/or columns.
412
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
414 \paragraph{Options.}
415
416 \DescribeEnv{equations}
417 The environment |equations|
418 accepts a comma-separated list of optional parameters \textit{opts}
419 to adjust the math content display in various ways
420 or to invoke special features.
421 Note that the combination `|[|\textit{opts}|]|'
422 must follow |{equations}| immediately without whitespaces.
423
424 \DescribeInterfaceMacro{\eqnlinesset}
425 Most options, but not all, can be set permanently by the macro:
426 %
427 \begin{center}
428 |\eqnlinesset{|\textit{opts}|}|
429 \end{center}
430 %
431 \DescribeInterfaceMacro{\eqnaddopt}
432 Options for the following equations block only are set by the macro:
433 %
434 \begin{center}
435 |\eqnaddopt{|\textit{opts}|}|
436 \end{center}
437 %
438 \DescribeInterfaceMacro{\eqncontrol}
439 Some options can be controlled
440 for individual lines or cells within the equations block by the macro:
441 %
442 \begin{center}
443 |\eqncontrol{|\textit{ctrls}|}|
444 \end{center}
445 %
446 The |\eqncontrol| interface also provides several features
447 for which no other macro definitions exist.
448
449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450 \paragraph{Modes of Operation.}
451
452 The main maths environment |equations|
453 has three principal modes of operation.
454 It can display a single-line equation
455 just as the \latex/ environments |equation| or |displaymath|:
456 %
457 \[*
458 \framebox[8cm]{\pstrut single line}
459 \]
460 %
461 It can display a stack of equations
462 analogous to the \amsmath/ environments |gather| and |multline|:
463 \unskip\footnote{Arguably, a single-line equation is
464 just a stack of equations of height 1.
465 Nevertheless, there is a single-line mode
466 which prohibits line breaks and which works slightly more efficiently:
467 For example, the multi-line modes will process the input
468 twice which is not needed for the single-line mode.
469 Apart from that, the package takes care that the layout and spacing
470 of single-line equations and multi-line equations consisting of a single line
471 is the same.}
472 %
473 \<=*[pad]
474 \framebox[4cm]{\pstrut stacked line 1}
475 \\
476 \framebox[7cm]{\pstrut stacked line 2}
477 \\
478 \framebox[5cm]{\pstrut stacked line 3}
479 \\
480 \shoveright\framebox[5cm]{\pstrut stacked line 4}
481 \>
482 %
483 It can also display one or several columns of aligned equations
484 analogous to the \amsmath/ environment family |align|:
485 %
486 \<*
487 \framebox[1.0cm]{\pstrut 1a-L}\hskip-0.5pt&\framebox[3.0cm]{\pstrut 1a-R}
488 &
489 \framebox[1.5cm]{\pstrut 1b-L}\hskip-0.5pt&\framebox[3.5cm]{\pstrut 1b-R}
490 \\
491 \framebox[2.5cm]{\pstrut 2a-L}\hskip-0.5pt&\framebox[4.5cm]{\pstrut 2a-R}
492 &
493 &\framebox[2cm]{\pstrut 2b-R}
494 \\
495 &\framebox[4cm]{\pstrut 3a-R}
496 \>
497 %
498
499 \DescribeOption{single}
500 \DescribeOption{lines}
501 \DescribeOption{columns}
502 The three modes of operation
503 are selected by setting an optional argument as follows:
504 %
505 \begin{center}
506 \begin{tabular}{llll}
507 purpose & single-line equation & stacked equation(s) & aligned equations \\
508 \hline
509 name & |single| & |lines| & |columns| \\
510 alt.\ names & |equation|, |eq|, |1|
511 & |gather|, |ga|, |ln|
512 & |align|, |al|, |col| \\
513 symbolic & |\[|\textvisiblespace\,\ldots|\]|\textvisiblespace
514 & |\<=|\textvisiblespace\,\ldots|\>|\textvisiblespace
515 & |\<|\textvisiblespace\,\ldots|\>|\textvisiblespace \\
516 \amsmath/ env. & |equation| & |gather|, |multline| & |align| \\
517 \hline
518 columns & --- & single & multiple, aligned \\
519 alignment & adjustable & adjustable & alternating right/left \\
520 parsing & single, direct & two passes & two passes \\
521 numbering & on/off & off/single/multiple & off/single/multiple \\
522 \end{tabular}
523 \end{center}
524 %
525 The aligned mode more or less encompasses all three modes,
526 and the stacked mode with only a single line
527 is more or less just a single equation.
528 However, the more complex forms also come along with some restrictions,
529 hence, it makes sense to use the appropriate mode
530 for the intended equation content.
531 For instance, a single equation simply reads the equation input once,
532 while the multi-line equation environments parse the environment body twice
533 which can potentially disrupt some other functionality
534 that is included in the body.
535 Furthermore, the horizontal adjustment options are very restricted
536 in aligned mode, and therefore the aligned form can automatically reduce
537 to the stacked form (with right alignment) if only a single column is provided
538 (no `|&|'s).
539
540 \begin{example}
541 \begin{scanexample}
542 \begin{equations}[single]
543 x=\cos\phi
544 \end{equations}
545 \end{scanexample}
546 \showexampleh
547 \begin{scanexample}
548 \begin{equations}[lines]
549 x=\cos\phi \\ \phi=\arccos x
550 \end{equations}
551 \end{scanexample}
552 \showexampleh
553 \begin{scanexample}
554 \begin{equations}[columns]
555 x&=\cos\phi & \phi&=\arccos x \\
556 &=(z+z^{-1})/2 & &=-i\log z
557 \end{equations}
558 \end{scanexample}
559 \showexampleh
560 \end{example}
561
562 \DescribeInterfaceMacro{\\}
563 \DescribeInterfaceMacro{&}
564 As usual, lines are separated by `|\\|[|*|]|[|\textit{skip}|]|'
565 and columns by `|&|'.
566 The optional argument |[|\textit{skip}|]| to `|\\|' introduces
567 additional glue between the lines;
568 the modifier `|*|' inhibits a page break.
569 \DescribeInterfaceMacro{\&}
570 Furthermore, the package overloads the combination `|\&|'
571 to describe a column break
572 It may be used to distinguish
573 the beginning of a new column (second of a pair of `|&|')
574 from the alignment within a column (first of a pair of `|&|').
575 In particular, it will always skip to the left cell of the next column,
576 even if no alignment has been specified;
577 for example, a sequence of `|\&|'
578 can be used to describe some blank columns
579 (with half as many `|&|' required).
580 The syntax of the line and column breaks `|\\|' and `|\&|'
581 is expanded in the symbolic notation described below
582 to conveniently describe equation relations
583 and adjustments to numbering and punctuation.
584
585 \DescribeInterfaceMacro{\&/}
586 \DescribeSetup{amp}
587 Note that the original \latex/ definition `|\&|' for the
588 ampersand character `\&' must be escaped as `|\&/|'
589 within the \ctanpkg{eqnlines} equations blocks.
590 The overloading of `|\&|' can be inhibited by the
591 global option |amp=off|.
592
593 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
594 \paragraph{Abbreviated Symbolic Notation.}
595
596 \DescribeInterfaceMacro{\[...\string\]}
597 \DescribeInterfaceMacro{\<...\string\>}
598 The package offers an abbreviated symbolic notation
599 extending the \latex/ display equation structure |\[|\,\ldots|\]|
600 as well as a variant |\<|\,\ldots|\>| dedicated to multi-line equations:
601 %
602 \begin{center}
603 \begin{tabular}[c]{l}
604 |\[|\textit{mod}\texttt{\textvisiblespace}
605 \\
606 \textit{math line}
607 \\
608 |\]|\textit{mod}\texttt{\textvisiblespace}
609 \end{tabular}
610 \qquad\qquad
611 \begin{tabular}[c]{l}
612 |\<|\textit{mod}\texttt{\textvisiblespace}
613 \\
614 \textit{math line}\ |\\|\textit{mod}\texttt{\textvisiblespace}
615 \\
616 \textit{math line}\ |\\|\textit{mod}\texttt{\textvisiblespace}
617 \\
618 \ldots
619 \\
620 \textit{math line}
621 \\
622 |\>|\textit{mod}\texttt{\textvisiblespace}
623 \end{tabular}
624 \end{center}
625 %
626 This symbolic notation accepts a sequence of modifiers \textit{mod}
627 (analogous to the star modifier `|*|' for many other \latex/ macros)
628 acting as shortcuts for particular options.
629 There can be any number of modifiers and they can be specified in any order.
630 \DescribeMod{[...]}
631 In most cases, a square bracket construct `|[|\ldots|]|'
632 can act as a modifier to specify optional arguments or some dimension.
633 Modifiers can be applied to the opening statements and closing statements
634 (|\[|, |\]|, |\<|, |\>|) as well as the line and column breaks (|\\|, |\&|).
635 Each symbolic command has an associated set of applicable modifiers
636 depending on its context.
637
638 Note that modifiers \textit{mod} must immediately follow
639 the symbolic macros without intermediary whitespaces (space, tab, new line).
640 The sequence of modifiers (even if empty)
641 should be terminated by a whitespace character
642 (`\texttt{\textvisiblespace}' in the above syntax)
643 which marks a clear separation from following math content.
644 Any character or token without a proper meaning in the respective context
645 will also terminate the modifier scanning
646 (while producing a warning message).
647 Future versions of the package may extend the syntax of modifiers,
648 and thus a separation by whitespace is strongly advertised.
649
650 \DescribeMod{[...]}
651 \DescribeMod{-}
652 \DescribeMod{=}
653 \DescribeMod{\verbbar}
654 The opening statements admit a large collection of modifiers
655 which are introduced in their proper context.
656 All optional arguments \textit{opts}
657 can be specified directly using square brackets `|[|\textit{opts}|]|',
658 and the three modes have dedicated selectors `|-|', `|=|' and `\verbbar':
659 %
660 \begin{center}
661 \begin{tabular}{cccc}
662 \textit{mod} & corresponding option & description
663 \\\hline
664 |[|\textit{opts}|]| & \textit{opts} & specify options \\
665 |-| & |single| & single-line mode \\
666 |=| & |lines| & lines mode \\
667 \verbbar & |columns| & columns mode \\
668 \end{tabular}
669 \end{center}
670 %
671 When a mode is selected explicitly,
672 the choice of |\[|\,\ldots|\]| vs.\ |\<|\,\ldots|\>| does not matter.
673 Hence it is easy to switch between the modes,
674 but it makes good sense to distinguish
675 between the single-line and multi-line modes
676 via the symbolic form.
677
678 \DescribeMod{[...]}
679 \DescribeMod{*}
680 The modifiers for line breaks and closing statements will be discussed later.
681 For example,
682 the modifier `|*|' for the line break `|\\|' inhibits a page break
683 and `|[|\textit{skip}|]|' introduces additional glue between the lines.
684
685 \begin{example}
686 \begin{scanexample}
687 \[
688 x=\cos\phi
689 \]
690 \end{scanexample}
691 \showexampleh
692 \begin{scanexample}
693 \<=
694 x=\cos\phi \\[0.5ex] \phi=\arccos x
695 \>
696 \end{scanexample}
697 \showexampleh
698 \begin{scanexample}
699 \<
700 x&=\cos\phi & \phi&=\arccos x \\
701 &=(z+z^{-1})/2 & &=-i\log z
702 \>
703 \end{scanexample}
704 \showexampleh
705 \begin{scanexample}
706 \eqnlinesset{sqropt={nonumber}}
707 \[ x=\cos\phi \]
708 \end{scanexample}
709 \showexampleh
710 \end{example}
711
712 \DescribeKey{modifier...}
713 Note that modifiers are disabled by default
714 for the |equations| environment (and its derivatives).
715 They can be enabled by the global setting |modifiereqnenv|.
716 Similar global settings to control the scanning of modifiers
717 exist for the symbolic forms as well as for breaks and ends.
718
719 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
720 \paragraph{Alternative and Custom Environments.}
721
722 \DescribeEnv{displaymath}
723 \DescribeEnv{equation}
724 \DescribeEnv{gather}
725 \DescribeEnv{multline}
726 \DescribeEnv{align}
727 The package also supplies or overwrites the \amsmath/
728 environments |equation|, |gather|, |multline|, |align| and |flalign|
729 including their |x|-, -|at| and starred variants
730 (but not the |split| construction).
731 Hence, documents designed for the \amsmath/ framework
732 can be translated to the \ctanpkg{eqnlines} framework
733 with little or no adjustments.
734 \DescribeKey{defaults}
735 Some layout choices may turn out slightly different in
736 the default package settings (|defaults=eqnlines|).
737 For a closer imitation of the classic \latex//\amsmath/ layout,
738 one may specify the global option |defaults=classic|;
739 this also disables most of the advanced notation
740 involving `|\\|', `|\&|' and modifiers.
741
742 It is possible to define further equation environments \textit{env}
743 with a predefined set of options \textit{opts} using:
744 %
745 \begin{center}
746 |\|[|re|]|newenvironment{|\textit{env}|}|%
747 |{\eqnaddopt{|\textit{opts}|}\equations}{\endequations}|
748 \end{center}
749 %
750 Shortcuts to frequently used control features could be installed by
751 user definitions such as:
752 %
753 \begin{center}
754 |\newcommand{\|\textit{shortcut}|}[1]{\eqncontrol{|\textit{key}|={#1}}}|
755 \end{center}
756 %
757 \DescribeSetup{sqropt}
758 \DescribeSetup{angopt}
759 The two short forms |\[|\,\ldots|\]| and |\<|\,\ldots|\>| can be customised
760 by setting default arguments via the global options
761 |sqropt={|\textit{opts}|}| and |angopt={|\textit{opts}|}|.
762
763 \begin{example}
764 \begin{scanexample}
765 \begin{equation}
766 x=\cos\phi
767 \end{equation}
768 \end{scanexample}
769 \showexampleh
770 \begin{scanexample}
771 \begin{gather}
772 x=\cos\phi \\ \phi=\arccos x
773 \end{gather}
774 \end{scanexample}
775 \showexampleh
776 \begin{scanexample}
777 \begin{align}
778 x&=\cos\phi & \phi&=\arccos x \\
779 &=(z+z^{-1})/2 & &=-i\log z
780 \end{align}
781 \end{scanexample}
782 \showexampleh
783 \begin{scanexample}
784 \newenvironment{eqnlist}
785 {\eqnaddopt{lines,shape=left}\equations}
786 {\endequations}
787 \begin{eqnlist}[nonumber]
788 x=\cos\phi \\ \phi=\arccos x
789 \end{eqnlist}
790 \end{scanexample}
791 \showexampleh[0.65]
792 \end{example}
793
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
795 \subsection{Numbering}
796 \label{sec:numbering}
797
798 The package extends the established interface of \latex/
799 and the \amsmath/ package for labelling equations
800 with numbers or with manually assigned tags.
801 The mode of numbering can be set globally via |\eqnlinesset|
802 or locally via the options of an equation block.
803 By default, numbering is turned off for |equations|
804 as well as for the symbolic notation |\[|\,\ldots|\]| and |\<|\,\ldots|\>|.
805
806 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807 \paragraph{Numbering Schemes.}
808
809 \DescribeKey{numberline}
810 \DescribeKey{n}
811 For multi-line equations, there are two distinct modes of operations:
812 individual labelling of the equation lines or
813 one overall number/tag for the whole block of equations.
814 The modes are selected by an optional argument
815 |numberline=|\textit{mode} (alternatively |nline| or just |n|)
816 as follows:
817 %
818 \begin{longtable}{llll}
819 name & alt. & description & preset \\
820 \hline
821 |all| & |a| & individual & all lines \\
822 |sub| & |s| & lines & subequations (a,\,b,\,c,\,\ldots) \\
823 \hline
824 |first| & |f| & & first line \\
825 |last| & |l| & & last line \\
826 |out| & |o| & & last/first line for right/left tags \\
827 |in| & |i| & single line & first/last line for right/left tags \\
828 |middle| & |m*| & & middle line (rounded down/up for right/left tags) \\
829 |here| & |h| & & line indicated by |\numberhere| \\
830 |best| & |+| & & line with most available space \\
831 \hline
832 |top| & |t| & & at top \\
833 |bottom| & |b| & & at bottom \\
834 |center| & |c| & between & at vertical centre (single line at baseline) \\
835 |center!| & |c!| & lines & at vertical centre (also single line) \\
836 |median| & |m| & & middle line (at baseline or between lines) \\
837 |center*| & |c*| & & tag baseline centred between outer baselines \\
838 \hline
839 |multi| & |@| & & individual lines, numbering on \\
840 |none| & |-| & mode switch & individual lines, numbering off \\
841 |single| & |1| & & previous single-line mode, numbering on \\
842 \hline
843 |on| & |!| & activation & turn numbering on \\
844 |off| & |*| & & turn numbering off \\
845 \end{longtable}
846
847 \begin{example}
848 \eqnlinesset{number=on}
849 \eqnlinesset{evadetag=false}
850 \begin{scanexample}
851 \eqnlinesset{number=on}
852 \begin{equations}[numberline=...]
853 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
854 \phi &= \arccos x \\ &= -i\log z
855 \end{equations}
856 \end{scanexample}
857 \qquad\parbox{0.8\textwidth}{\printexample}
858 \par\bigskip
859 \makebox[0.33\textwidth]{|all|:}\hfil
860 \makebox[0.33\textwidth]{|sub|:}\hfil
861 \makebox[0.33\textwidth]{|best|:}\par\nobreak\smallskip
862 \begin{minipage}{0.33\textwidth}
863 \begin{equations}[numberline=all]
864 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
865 \phi &= \arccos x \\ &= -i\log z
866 \end{equations}
867 \end{minipage}\vrule\hfil
868 \begin{minipage}{0.33\textwidth}
869 \begin{equations}[numberline=sub]
870 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
871 \phi &= \arccos x \\ &= -i\log z
872 \end{equations}
873 \end{minipage}\vrule\hfil
874 \begin{minipage}{0.33\textwidth}
875 \begin{equations}[numberline=best]
876 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
877 \phi &= \arccos x \\ &= -i\log z
878 \end{equations}
879 \end{minipage}
880 \par\bigskip
881 \makebox[0.33\textwidth]{|first|:}\hfil
882 \makebox[0.33\textwidth]{|last|:}\hfil
883 \makebox[0.33\textwidth]{|middle|:}\par\nobreak\smallskip
884 \begin{minipage}{0.33\textwidth}
885 \begin{equations}[numberline=first]
886 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
887 \phi &= \arccos x \\ &= -i\log z
888 \end{equations}
889 \end{minipage}\vrule\hfil
890 \begin{minipage}{0.33\textwidth}
891 \begin{equations}[numberline=last]
892 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
893 \phi &= \arccos x \\ &= -i\log z
894 \end{equations}
895 \end{minipage}\vrule\hfil
896 \begin{minipage}{0.33\textwidth}
897 \begin{equations}[numberline=middle]
898 x &= \cos\phi \\ &= (z+z^{-1})/2 \\
899 \phi &= \arccos x \\ &= -i\log z
900 \end{equations}
901 \end{minipage}
902 \par\bigskip
903 \makebox[0.33\textwidth]{|top|:}\hfil
904 \makebox[0.33\textwidth]{|bottom|:}\hfil
905 \makebox[0.33\textwidth]{|center!|:}\par\nobreak\smallskip
906 \begin{minipage}{0.33\textwidth}
907 \begin{equations}[1,numberline=top]
908 1+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 1+\ldots}}
909 \end{equations}
910 \end{minipage}\vrule\hfil
911 \begin{minipage}{0.33\textwidth}
912 \begin{equations}[1,numberline=bottom]
913 1+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 1+\ldots}}
914 \end{equations}
915 \end{minipage}\vrule\hfil
916 \begin{minipage}{0.33\textwidth}
917 \begin{equations}[1,numberline=center!]
918 1+\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 1+\ldots}}
919 \end{equations}
920 \end{minipage}
921 \par\bigskip
922 \makebox[0.33\textwidth]{|median|:}\hfil
923 \makebox[0.33\textwidth]{|center*|:}\hfil
924 \makebox[0.33\textwidth]{|center|:}\par\nobreak\smallskip
925 \begin{minipage}{0.33\textwidth}
926 \begin{equations}[numberline=median]
927 x &= -\int \sin\phi\,\mathrm{d}\phi \\
928 &= \cos\phi
929 \end{equations}
930 \end{minipage}\vrule\hfil
931 \begin{minipage}{0.33\textwidth}
932 \begin{equations}[numberline=center*]
933 x &= -\int \sin\phi\,\mathrm{d}\phi \\
934 &= \cos\phi
935 \end{equations}
936 \end{minipage}\vrule\hfil
937 \begin{minipage}{0.33\textwidth}
938 \begin{equations}[numberline=center]
939 x &= -\int \sin\phi\,\mathrm{d}\phi \\
940 &= \cos\phi
941 \end{equations}
942 \end{minipage}
943 \end{example}
944
945 \DescribeKey{evadetag}
946 Note that the mode |best| (line with most available space)
947 is activated automatically if the (single) tagged line
948 does not have sufficient space to hold the tag.
949 This feature can be controlled by the setting
950 |evadetag=|\textit{bool}.
951
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953 \paragraph{Activation and Selection.}
954
955 \DescribeKey{number}
956 \DescribeKey{nonumber}
957 \DescribeKey{donumber}
958 The default numbering of equation blocks (initially off) is controlled by:
959 %
960 \begin{center}
961 |\eqnlinesset{number=|\textit{bool}|}|
962 \qquad or\qquad
963 |\eqnlinesset{donumber|\textbar|nonumber}|
964 \end{center}
965 %
966 with \textit{bool} either |on| or |off| (among several alternative forms).
967 This applies equally to the environment |equations|
968 and to the symbolic forms |\[|\,\ldots|\]| and |\<|\,\ldots|\>|.
969 If numbering is to be used for |equations| only,
970 but not for the symbolic forms,
971 one can suppress it for the latter by
972 declaring |nonumber| as their default option:
973 %
974 \begin{center}
975 |\eqnlinesset{sqropt=nonumber,angopt=nonumber}|
976 \end{center}
977
978 \DescribeInterfaceMacro{\nonumber}
979 \DescribeInterfaceMacro{\donumber}
980 Numbering can be turned on and off
981 (for individual lines or for the block as a whole depending on the mode)
982 by means of:
983 %
984 \begin{center}
985 |\nonumber|
986 \qquad and \qquad
987 |\donumber|
988 \end{center}
989 %
990 \DescribeKey{nonumber}
991 \DescribeKey{donumber}
992 \DescribeKey{number}
993 \DescribeKey{nn,*}
994 \DescribeKey{dn,!}
995 \DescribeMod{*}
996 \DescribeMod{!}
997 The numbering can be disabled or enabled for the block
998 by the keys |nonumber| or |donumber| (`|nn|'=`|*|' or `|dn|'=`|!|' for short)
999 or by |number=|\textit{bool}.
1000 In the symbolic notation, the number can be switched by using modifiers:
1001 %
1002 \begin{center}
1003 |\[*|\textvisiblespace\,\ldots|\]|
1004 \qquad and \qquad
1005 |\[!|\textvisiblespace\,\ldots|\]|
1006 \end{center}
1007 %
1008 Altogether, this allows to define a default behaviour
1009 and specify exceptions where they may occur.
1010 The optional argument `|[*]|'
1011 or the star modifier `|*|' following directly the symbolic opening statement
1012 replaces the starred form of environments (|equation*|, etc.)
1013 and there is no need to adjust the closing statement.
1014 If numbering is disabled by default,
1015 the optional argument `|[!]|' or the modifier `|!|'
1016 can be used to enable numbering for the block.
1017
1018 \DescribeInterfaceMacro{\numberhere}
1019 \DescribeInterfaceMacro{\numbernext}
1020 The placement of a single number for an equation block can be adjusted by:
1021 %
1022 \begin{center}
1023 |\numberhere|
1024 \qquad and \qquad
1025 |\numbernext|
1026 \end{center}
1027 %
1028 The former macro overrides the position to the present line,
1029 the latter macro defers the number to the next line.
1030 For example, if an equation is broken into several lines
1031 one may use the combination |\numbernext \\|
1032 to assign the number to the last line within the set.
1033 \DescribeMod{/}
1034 Note that the modified newline `|\\/|' combines
1035 |\numbernext| and |\\|
1036 %
1037 \begin{center}
1038 |\\/|\quad\textrightarrow\quad|\numbernext \\|\quad(or |\nonumber \\|)
1039 \end{center}
1040
1041 \begin{example}
1042 \eqnlinesset{number=on}
1043 \begin{scanexample}
1044 \begin{equations}
1045 x &= \cos\phi \nonumber \\
1046 &= (z+z^{-1})/2 \\
1047 \phi &= \arccos x \nonumber \\
1048 &= -i\log z
1049 \end{equations}
1050 \end{scanexample}
1051 \showexampleh
1052 \begin{scanexample}
1053 \begin{equations}[nonumber]
1054 x &= \cos\phi \donumber \\
1055 &= (z+z^{-1})/2 \\
1056 \phi &= \arccos x \donumber \\
1057 &= -i\log z
1058 \end{equations}
1059 \end{scanexample}
1060 \showexampleh
1061 \begin{scanexample}
1062 \eqnlinesset{numberline=last}
1063 \< x &= \cos\phi \\
1064 \phi &= \arccos x \>
1065 \end{scanexample}
1066 \showexampleh
1067 \begin{scanexample}
1068 \eqnlinesset{angopt=nonumber}
1069 \<! x &= \cos\phi \\
1070 \phi &= \arccos x \>
1071 \end{scanexample}
1072 \showexampleh
1073 \begin{scanexample}
1074 \< x &= \cos\phi \\/
1075 &= (z+z^{-1})/2 \\
1076 \phi &= \arccos x \\/
1077 &= -i\log z \>
1078 \end{scanexample}
1079 \showexampleh
1080 \begin{scanexample}
1081 \eqnlinesset{numberline=here}
1082 \< x &= \cos\phi \\
1083 &= (z+z^{-1})/2 \\
1084 \phi &= \arccos x \numberhere \\
1085 &= -i\log z \>
1086 \end{scanexample}
1087 \showexampleh
1088 \begin{scanexample}
1089 \eqnlinesset{numberline=first}
1090 \< x &= \cos\phi \\/
1091 &= (z+z^{-1})/2 \\
1092 \phi &= \arccos x \\/
1093 &= -i\log z \>
1094 \end{scanexample}
1095 \showexampleh
1096 \end{example}
1097
1098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1099 \paragraph{Labels and Tags.}
1100
1101 \DescribeInterfaceMacro{\label}
1102 \DescribeInterfaceMacro{\tag}
1103 Equation numbers can be equipped with \latex/ labels as usual,
1104 and they can be turned into manually assigned tags
1105 using the established macros:
1106 %
1107 \begin{center}
1108 |\label[|\textit{name}|]{|\textit{label}|}|
1109 \qquad and \qquad
1110 |\tag|[|*|]|[|\textit{ref}|]{|\textit{tag}|}|
1111 \end{center}
1112 %
1113 The optional parameter \textit{name} for |\label| assigns
1114 a name to the label which can be referenced by |\nameref|.
1115 A |\tag| replaces the equation number,
1116 |\tag*| will drop the decoration by parentheses.
1117 The optional parameter \textit{ref} for |\tag|
1118 defines the representation of references by |\ref|.
1119
1120 Note that a label and a tag will always apply to the
1121 next number that will be printed, and only a single label
1122 and/or tag may be specified for it. For example, if the present line
1123 has no numbering, but the following line does,
1124 |\label| or |\tag| will apply to the following line.
1125
1126 The macros |\label| and |\tag|
1127 can also be instructed to automatically enable numbering/tagging
1128 for the present line or block via |\donumber|, see below.
1129 By default, numbering/tagging is triggered for |\tag|,
1130 but not for |\label| reflecting the behaviour set forth by \amsmath/.
1131 By enabling triggering for |\label|, numbers will be produced
1132 only if they have a chance of being referenced.
1133
1134 \DescribeOption{label}
1135 \DescribeOption{tag}
1136 \DescribeKey{labelname}
1137 \DescribeKey{taglabel}
1138 The |equations| environment provides an alternative means
1139 to specify labels and tags within the optional arguments |[|\textit{opts}|]|
1140 %
1141 \begin{center}
1142 |label={|\textit{label}|}|,
1143 \qquad
1144 |tag|[|*|]|={|\textit{tag}|}|,
1145 \qquad
1146 |labelname={|\textit{name}|}|,
1147 \qquad
1148 |taglabel={|\textit{ref}|}|,
1149 \end{center}
1150 %
1151 \DescribeMod{@}
1152 or via the modifier |@{|\textit{label}|}|:
1153 %
1154 \begin{center}
1155 |\[@{|\textit{label}|}|\,\ldots|\]|
1156 \end{center}
1157 %
1158 In particular, in subequations mode (|sub|),
1159 the optional argument |label| can be used to assign
1160 a label to the parent number addressing the whole equation block.
1161
1162 The above macros may also be used via the keys
1163 |label|, |labelname|, |tag| and |taglabel|
1164 of the interface |\eqncontrol|.
1165
1166 \DescribeInterfaceMacro{\eqref}
1167 The macro |\eqref| is the standard method for referring
1168 to equation numbers via their label.
1169 This method also uses the layout defined below.
1170 %
1171 \begin{center}
1172 |\eqref{|\textit{label}|}|.
1173 \end{center}
1174 %
1175 \DescribeInterfaceMacro{\tagform}
1176 \DescribeInterfaceMacro{\tagbox}
1177 \DescribeInterfaceMacro{\tagboxed}
1178 For custom typesetting of numbers and tags,
1179 |\tagform| encloses a number/tag with some decoration,
1180 |\tagbox| puts the decorated number in a box
1181 and |\tagboxed| combines the two for use in a single macro call.
1182
1183 \DescribeSetup{tagbox}
1184 \DescribeSetup{tagform}
1185 \DescribeSetup{tagform*}
1186 The typesetting of equation numbers and tags passes through two macros
1187 (which are exposed by |\tagbox| and |\tagform|),
1188 one which defines the layout
1189 and another one which adds a decoration by parentheses.
1190 These two methods can be adjusted via the options:
1191 %
1192 \begin{center}
1193 |tagbox|[|*|]|={|\textit{code}|}|
1194 \quad and\quad
1195 |tagform={|\textit{l}|{|\textit{code}|}|\textit{r}|}|
1196 \quad or\quad
1197 |tagform*={|\textit{code}|}|
1198 \end{center}
1199 %
1200 Here, \textit{code} is some macro code
1201 that references the argument `|#1|' containing the
1202 number or tag, and \textit{l} and \textit{r}
1203 can be opening and closing parentheses for the tag presentation.
1204
1205 The above setting may also be changed for individual lines
1206 by the corresponding keys of the interface |\eqncontrol|.
1207
1208 \begin{example}
1209 \eqnlinesset{number=on}
1210 \begin{scanexample}
1211 \eqnlinesset{tagform=[{#1}]}
1212 \eqnlinesset{tagbox={\textcolor{blue}{#1}}}
1213 \<[numberline=last]
1214 x &= \cos\phi \\
1215 &= (z+z^{-1})/2 \\
1216 \phi &= \arccos x \\
1217 &= -i\log z
1218 \>
1219 \end{scanexample}
1220 \showexampleh[0.6]
1221 \end{example}
1222
1223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1224 \subsection{Horizontal Placement}
1225 \label{sec:adjustment}
1226
1227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1228 \paragraph{Overall Layout.}
1229
1230 \DescribeKey{layout}
1231 \DescribeKey{center}
1232 \DescribeKey{left}
1233 First of all, the overall layout can be adjusted
1234 between central and left alignment
1235 via |layout=center|, |layout=left| or |center|, |left| for short.
1236
1237 \begin{example}
1238 \begin{scanexample}
1239 \<[layout=center]
1240 x &= \cos\phi \\
1241 &= (z+z^{-1})/2 \\
1242 \phi &= \arccos x \\
1243 &= -i\log z
1244 \>
1245 \end{scanexample}
1246 \showexampleh[0.35]
1247 \begin{scanexample}
1248 \<[layout=left]
1249 x &= \cos\phi \\
1250 &= (z+z^{-1})/2 \\
1251 \phi &= \arccos x \\
1252 &= -i\log z
1253 \>
1254 \end{scanexample}
1255 \showexampleh[0.35]
1256 \end{example}
1257
1258 \DescribeKey{tags}
1259 \DescribeKey{tagsright}
1260 \DescribeKey{tagsleft}
1261 Furthermore, numbers and/or tags may be placed
1262 on the right or left margin
1263 via |tags=right|, |tags=left| or |tagsright|, |tagsleft| for short.
1264
1265 \begin{example}
1266 \eqnlinesset{number=on}
1267 \begin{scanexample}
1268 \<[tags=right]
1269 x &= \cos\phi \\
1270 &= (z+z^{-1})/2 \\
1271 \phi &= \arccos x \\
1272 &= -i\log z
1273 \>
1274 \end{scanexample}
1275 \showexampleh[0.35]
1276 \begin{scanexample}
1277 \<[tags=left]
1278 x &= \cos\phi \\
1279 &= (z+z^{-1})/2 \\
1280 \phi &= \arccos x \\
1281 &= -i\log z
1282 \>
1283 \end{scanexample}
1284 \showexampleh[0.35]
1285 \end{example}
1286
1287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1288 \paragraph{Margins.}
1289
1290 \DescribeKey{margin}
1291 \DescribeKey{marginleft}
1292 \DescribeKey{marginright}
1293 \DescribeKey{linewidth}
1294 For both layout choices,
1295 the margins and line width of an equation block can be adjusted
1296 by |margin|, |marginleft|, |marginright| or |linewidth|.
1297 The equations and corresponding numbers or tags will be fit
1298 within these bounds. This feature can be used within
1299 lists or enumerations to undo an indentation.
1300
1301 \begin{example}
1302 \def\indicate#1{%
1303 \framebox[\dimexpr\displaywidth-2\fboxsep-2\fboxrule\relax]{\mbox{#1}}}
1304 \begin{scanexample}
1305 \[ \indicate{line width} \]
1306 \end{scanexample}
1307 \showexampleh[0.5]
1308 \begin{scanexample}
1309 \[[margin=2em] \indicate{reduced} \]
1310 \end{scanexample}
1311 \showexampleh[0.5]
1312 \begin{scanexample}
1313 \begin{itemize}
1314 \item first level
1315 \[ \indicate{default width} \]
1316 \[[marginleft=0pt]
1317 \indicate{full width} \]
1318 \end{itemize}
1319 \end{scanexample}
1320 \showexampleh[0.5]
1321 \end{example}
1322
1323 \DescribeKey{tagmargin}
1324 \DescribeKey{tagmargin*}
1325 \DescribeKey{tagmarginratio}
1326 In central alignment layout, one can impose a tag margin
1327 |tagmargin={|\textit{dimen}|}|
1328 which allocates some space to the tag
1329 such that equation content is centred in the remaining horizontal space.
1330 The margin can also be set to the width of some text by
1331 |tagmargin*={|\textit{text}|}| or it can be calculated
1332 as the maximum width of tags by |tagmargin| without parameter (default).
1333 The option |tagmarginratio={|\textit{ratio}|}|
1334 uses the tag margin only for equation blocks
1335 with a ratio of tags to rows above the given (decimal) ratio
1336 (a value above 1 uses the tag margin only for single equations with tags;
1337 default is |0.334|).
1338 The option |tagmarginthreshold={|\textit{threshold}|}|
1339 uses the tag margin only if the ratio of spacings would be below
1340 the given (decimal) threshold (very much off balance;
1341 default is |0.5|).
1342 The latter two options together with some tag margin
1343 can produce a more appealing layout for equation blocks of mixed filling.
1344 In the following example, the former two equations are centred
1345 on all horizontal space
1346 while the latter two equations are centred on the space left of the tag
1347 (the ratio of spacings without tag margin would be very small here):
1348
1349 \begin{example}
1350 \eqnlinesset{number=on}
1351 \begin{scanexample}
1352 \eqnlinesset{tagmarginthreshold=0.7}
1353 \[ \framebox[4em]{} \]
1354 \[ \framebox[8em]{} \]
1355 \[ \framebox[12em]{} \]
1356 \[ \framebox[16em]{} \]
1357 \end{scanexample}
1358 \showexampleh
1359 \end{example}
1360
1361 \DescribeKey{leftmargin}
1362 \DescribeKey{leftmargin*}
1363 \DescribeKey{minleftmargin}
1364 \DescribeKey{maxleftmargin}
1365 In left alignment layout, all equations are left aligned to a left margin
1366 (|leftmargin| is initialised
1367 to the first level of enumerations and itemisations).
1368 It can be set to the width of some text by |leftmargin*={|\textit{text}|}|.
1369 Depending on the situation, the left margin may be
1370 reduced or extended to |minleftmargin| or |maxleftmargin|, respectively.
1371
1372 \begin{example}
1373 \eqnlinesset{number=on}
1374 \eqnlinesset{layout=left}
1375 \begin{scanexample}
1376 \eqnlinesset{layout=left}
1377 \<*
1378 x &= \cos\phi \\
1379 &= (z+z^{-1})/2 \\
1380 \phi &= \arccos x \\
1381 &= -i\log z
1382 \>
1383 \end{scanexample}
1384 \showexampleh[0.35]
1385 \begin{scanexample}
1386 \<[tags=left]
1387 x &= \cos\phi \\
1388 &= (z+z^{-1})/2 \\
1389 \phi &= \arccos x \\
1390 &= -i\log z
1391 \>
1392 \end{scanexample}
1393 \showexampleh[0.35]
1394 \end{example}
1395
1396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1397 \paragraph{Column Separation.}
1398
1399 \DescribeKey{fulllength}
1400 \DescribeKey{mincolsep}
1401 \DescribeKey{maxcolsep}
1402 The horizontal alignment of columns is fixed for aligned multi-line equations:
1403 Each pair of subsequent columns forms a unit which is aligned at the
1404 intermediate alignment marker `|&|'.
1405 These columns are distributed evenly over the available horizontal space.
1406 Here, the outer space left and right of the set of columns
1407 is treated on equal footing to the space between the columns
1408 (option |fulllength=off|; default),
1409 but it can be eliminated so that the outer columns
1410 are pushed right to the margin (option |fulllength=on|).
1411 A minimum and maximum column separation can be specified
1412 via |mincolsep=|\textit{dimen} and |maxcolsep=|\textit{dimen}
1413 (defaults are |2em| and |1em|)
1414 or the maximum column separation can be disabled by |maxcolsep=off|
1415 (which is implied by |fulllength=on|).
1416
1417 \begin{example}
1418 \begin{scanexample}
1419 \<[maxcolsep=2em]
1420 x &= \cos\phi & \phi &= \arccos x \\
1421 &= (z+z^{-1})/2 & &= -i\log z \>
1422 \end{scanexample}
1423 \showexamplev
1424 \begin{scanexample}
1425 \<[maxcolsep=off]
1426 x &= \cos\phi & \phi &= \arccos x \\
1427 &= (z+z^{-1})/2 & &= -i\log z \>
1428 \end{scanexample}
1429 \showexamplev
1430 \begin{scanexample}
1431 \<[fulllength]
1432 x &= \cos\phi & \phi &= \arccos x \\
1433 &= (z+z^{-1})/2 & &= -i\log z \>
1434 \end{scanexample}
1435 \showexamplev
1436 \end{example}
1437
1438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1439 \paragraph{Alignment Schemes and Control.}
1440
1441 For stacks of equations including single equations,
1442 there is just a single alignment column
1443 whose horizontal alignment can be adjusted via a shape scheme or
1444 by manually adjusting individual lines.
1445 A shape scheme determines the horizontal alignment for each line
1446 and it is specified by the optional argument
1447 |shape=|\textit{mode} as follows:
1448 %
1449 \begin{center}
1450 \begin{tabular}{llll}
1451 name & alt. & shape & alignment \\
1452 \hline
1453 |default| & |def| & uniform & default\\
1454 \hline
1455 |left| & |l| & & left\\
1456 |center| & |c| & uniform & central \\
1457 |right| & |r| & & right \\
1458 \hline
1459 |first| & |indent|, |rc| & first/rest & first line indented \\
1460 |hanging| & |outdent|, |lc| & first/rest & first line hanging \\
1461 |steps| & |lcr| & first/intermediate/last & left/centre\ldots centre/right\\
1462 \end{tabular}
1463 \end{center}
1464 %
1465 Note that the |steps| shape comes to use in the replacement \amsmath/
1466 environment |multline|.
1467
1468 \begin{example}
1469 \eqnlinesset{pad=2em}
1470 \begin{scanexample}
1471 \eqnlinesset{pad=2em}
1472 \<=[shape=...] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1473 \phi = \arccos x \\ \phi = -i\log z \>
1474 \end{scanexample}
1475 \qquad\parbox{0.8\textwidth}{\printexample}
1476 \par\bigskip
1477 \makebox[0.33\textwidth]{|left|:}\hfil
1478 \makebox[0.33\textwidth]{|center|:}\hfil
1479 \makebox[0.33\textwidth]{|right|:}\par\nobreak\smallskip
1480 \begin{minipage}{0.33\textwidth}
1481 \<=[shape=left] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1482 \phi = \arccos x \\ \phi = -i\log z \>
1483 \end{minipage}\vrule\hfill
1484 \begin{minipage}{0.33\textwidth}
1485 \<=[shape=center] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1486 \phi = \arccos x \\ \phi = -i\log z \>
1487 \end{minipage}\vrule\hfill
1488 \begin{minipage}{0.33\textwidth}
1489 \<=[shape=right] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1490 \phi = \arccos x \\ \phi = -i\log z \>
1491 \end{minipage}
1492 \par\bigskip
1493 \makebox[0.33\textwidth]{|first|:}\hfil
1494 \makebox[0.33\textwidth]{|hanging|:}\hfil
1495 \makebox[0.33\textwidth]{|steps|:}\par\nobreak\smallskip
1496 \begin{minipage}{0.33\textwidth}
1497 \<=[shape=first] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1498 \phi = \arccos x \\ \phi = -i\log z \>
1499 \end{minipage}\vrule
1500 \begin{minipage}{0.33\textwidth}
1501 \<=[shape=hanging] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1502 \phi = \arccos x \\ \phi = -i\log z \>
1503 \end{minipage}\vrule
1504 \begin{minipage}{0.33\textwidth}
1505 \<=[shape=steps] x = \cos\phi \\ x = (z+z^{-1})/2 \\
1506 \phi = \arccos x \\ \phi = -i\log z \>
1507 \end{minipage}
1508 \end{example}
1509
1510 \DescribeControl{align}
1511 \DescribeControl{shiftto}
1512 \DescribeControl{shiftby}
1513 The alignment preset can be adjusted for individual lines by the controls:
1514 %
1515 \begin{center}
1516 \begin{tabular}{l}
1517 |\eqncontrol{align=left|\textbar|center|\textbar|right}|\\
1518 |\eqncontrol{shiftto|\textbar|shiftby=|\textit{dimen}|}|
1519 \end{tabular}
1520 \end{center}
1521 %
1522 \DescribeInterfaceMacro{\shoveleft}
1523 \DescribeInterfaceMacro{\shovecenter}
1524 \DescribeInterfaceMacro{\shoveright}
1525 or by the macros:
1526 %
1527 \begin{center}
1528 |\shoveleft|\textbar|\shovecenter|\textbar|\shoveright|%
1529 [|*|\textbar|!|\textbar|[|\textit{dimen}|]|],
1530 \end{center}
1531 %
1532 In contradistinction to \amsmath/,
1533 these macros can be placed anywhere within the cell
1534 and they do not take the cell contents as their argument
1535 (doing this here will disallow shrinking of glue towards reducing width).
1536 The macros accept an optional argument |[|\textit{dimen}|]|
1537 specifying a variable amount of shift.
1538 \DescribeKey{indent}
1539 They also accept the modifiers
1540 `|*|' or `|!|' for indentation or hanging indentation by
1541 the standard indentation amount (|indent|=|2em|).
1542 \DescribeInterfaceMacro{\shoveby}
1543 Furthermore, |\shoveby|[|*|]|{|\textit{dimen}|}|
1544 shifts the line by the additional amount \textit{dimen}
1545 (the star variant shifts to an absolute position
1546 relative to the reference position).
1547
1548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1549 \paragraph{Reference Positions.}
1550
1551 \DescribeKey{padding}
1552 \DescribeKey{padleft}
1553 \DescribeKey{padright}
1554 The reference positions for left, right and central alignment
1555 are determined as follows:
1556 The central reference position marks the centre of
1557 the available horizontal space.
1558 The left and right reference positions are given
1559 by the ends of the widest line placed centrally.
1560 The latter can be adjusted by adding
1561 some padding around the widest line via the optional argument
1562 |padding|\textbar|padleft|\textbar|padright|[|={|\textit{dimen}|}|]
1563 while preserving the central default position.
1564 The value `|indent|' sets the padding to the default indentation amount
1565 and `|max|' extends the padding to all available space.
1566 Note that |indent*={|\textit{dimen}|}| sets the default indentation amount
1567 and the left padding at the same time.
1568
1569 \begin{example}
1570 \begin{scanexample}
1571 \eqnlinesset{indent=2em,pad=5em}
1572 \<=
1573 \shoveleft \framebox[5em]{left} \\
1574 \shoveleft* \framebox[5em]{indent} \\
1575 \shovecenter \framebox[5em]{center} \\
1576 \shoveright \framebox[5em]{right}
1577 \>
1578 \end{scanexample}
1579 \showexampleh[0.55]
1580 \begin{scanexample}
1581 \eqnlinesset{layout=left}
1582 \eqnlinesset{leftmargin=2em}
1583 \eqnlinesset{indent=2em}
1584 \<=
1585 \shoveleft! \framebox[5em]{outdent} \\
1586 \shoveleft \framebox[5em]{left} \\
1587 \shoveleft* \framebox[5em]{indent} \\
1588 \shoveright \framebox[5em]{right}
1589 \>
1590 \end{scanexample}
1591 \showexampleh[0.55]
1592 \end{example}
1593
1594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1595 \paragraph{Fitting.}
1596
1597 Finally, note that the package will make attempts
1598 at fitting the equation components into the horizontal space
1599 by adjusting some dimensions
1600 with the priority of avoiding overlong lines.
1601 The adjustments will first concern the intercolumn and margin spacing.
1602 Secondly, \tex/ will attempt to shrink the glue between symbols
1603 for very wide single and stacked equations (but not aligned equations).
1604 Finally, equation tags may be shifted out of the way vertically
1605 in order to free up horizontal space.
1606 If all attempts fail, overlong lines will be indicated.
1607
1608 \DescribeKey{alignshrink}
1609 \DescribeKey{tagshrink}
1610 \DescribeKey{alignbadness}
1611 \DescribeKey{tagbadness}
1612 The threshold for shrinking of glue can be controlled by the two parameters
1613 |alignshrink| and |tagshrink| accepting values ranging
1614 between |0| (no shrink) and |4| (full allowable shrink).
1615 They are used towards determining
1616 whether to shift away from the intended alignment position
1617 or whether to raise or lower the equation tag, respectively.
1618 Small values prevent shrinking and higher values allow for more compression.
1619 The corresponding parameters |alignbadness| and |tagbadness|
1620 accept integer values setting the
1621 native threshold in \tex/'s native units of |\badness|.
1622
1623 \begin{example}
1624 \eqnlinesset{number=on}
1625 \begin{scanexample}
1626 \<=
1627 x+x \\
1628 x+x+x+x \\
1629 x+x+x+x+x+x \\
1630 x+x+x+x+x+x+x+x \\
1631 x+x+x+x+x+x+x+x+x+x \\
1632 x+x+x+x+x+x+x+x+x+x+x+x \\
1633 \>
1634 \end{scanexample}
1635 \showexampleh[0.6]
1636 \end{example}
1637
1638 \DescribeKey{mintagsep}
1639 If the available space on a line does not suffice to place
1640 both the equation and its tag
1641 (with a minimum separation of |mintagsep|; default is |0.5em|),
1642 a tag will automatically be shifted
1643 (lowered or raised depending on whether it is placed on the right or left)
1644 to an otherwise empty line.
1645 \DescribeControl{shifttag}
1646 \DescribeInterfaceMacro{\raisetag*}
1647 The |\eqncontrol| control |shifttag=|\textit{dimen}
1648 (alternatively |\raisetag*|) may be used to shift a tag up
1649 (or down with negative arguments).
1650 \DescribeControl{smashtag}
1651 \DescribeInterfaceMacro{\raisetag}
1652 The control |smashtag=|\textit{dimen} (alternatively |\raisetag|)
1653 may be used to fine-tune the vertical placement
1654 when the tag requires extra vertical space
1655 but some space above or below the tag is unoccupied.
1656 It smashes some of the tag's height (or depth with negative arguments)
1657 and thus reduces the vertical gap created by the tag.
1658 Note that this feature can be used successively
1659 with positive and negative arguments
1660 to reduce the space in both directions if available.
1661 \DescribeKey{pushtag}
1662 \DescribeInterfaceMacro{\raisetag!}
1663 Where needed, the control |pushtag| (or |\raisetag!|)
1664 force-pushes the tag to a separate line
1665 and frees up the horizontal space occupied by the tag.
1666 The numbering modes |top|, |bottom|,
1667 |center|, |median|, |center!| and |center*|
1668 are special in that they allow for a continuous vertical placement
1669 of the tag between two lines.
1670 \DescribeKey{tagbetween}
1671 The more flexible placement of tags may
1672 also be enabled for the single-lines modes
1673 by the option |tagbetween|.
1674 Here, both lines must have sufficiently much space available for the tag.
1675 If not, the tag is shifted up or down or it is places on separate line
1676 between the two.
1677 \DescribeKey{tagsnap}
1678 The option |tagsnap| defines a range
1679 within which the tag baseline snaps to a nearby math baseline.
1680
1681 \begin{example}
1682 \eqnlinesset{number=on}
1683 \begin{scanexample}
1684 \[ \phi = -\int \frac{\mathrm{d}x}{\sqrt{1+x^2}} \]
1685 \end{scanexample}
1686 \showexampleh[0.8]
1687 \begin{scanexample}
1688 \[ x = \frac{\partial}{\partial \phi}\sin\phi
1689 \raisetag{0.45\baselineskip} \]
1690 \end{scanexample}
1691 \showexampleh[0.85]
1692 \begin{scanexample}
1693 \<=[numberline=center] \raisetag*{2pt}
1694 x+x+x+x+x+x+x+x \\
1695 x+x+x+x+x+x+x+x \\
1696 x+x+x+x+x+x+x+x \\
1697 x+x+x+x+x+x+x+x
1698 \>
1699 \end{scanexample}
1700 \showexampleh[0.6]
1701 \end{example}
1702
1703 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1704 \subsection{Punctuation}
1705 \label{sec:punctuation}
1706
1707 Extending proper punctuation across equations is a delicate matter,
1708 and maintaining it while redacting the text
1709 certainly takes more attention to detail
1710 than many authors are willing to afford.
1711 A contributing factor is that punctuation marks are harder
1712 to spot alongside equation context and somewhat out of place anyway.
1713
1714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1715 \paragraph{Scheme.}
1716
1717 \DescribeInterfaceMacro{\eqnpunct}
1718 \DescribeKey{punct}
1719 The package supplies a semi-automatic scheme by which
1720 equations are terminated by a specific punctuation mark.
1721 Punctuation marks are set by:
1722 %
1723 \begin{center}
1724 |\eqnlinesset{punct={|\textit{punct}|}}|
1725 \qquad
1726 |\eqnpunct{|\textit{punct}|}|
1727 \qquad
1728 |\[[punct={|\textit{punct}|}]|\,\ldots|\]|
1729 \end{center}
1730 %
1731 The first form sets and enables a default punctuation mark;
1732 the middle form sets the punctuation mark for the
1733 following equation environment;
1734 the final form applies to the given equation environment only.
1735 For example, one might globally declare `|punct={.}|'
1736 to terminate all equations by default with a period `|.|'.
1737 The default behaviour can be adjusted to a comma `|,|'
1738 for an individual equation by declaring `|\eqnpunct,|' before the equation
1739 (i.e.\ at the end of the textual phrase to which the punctuation mark belongs)
1740 or by using the optional argument |[punct={,}]|.
1741 Likewise, |\eqnpunct{}|, |[punct=~]| or |[punct={}]|
1742 eliminates a preset punctuation.
1743
1744 \begin{example}
1745 \eqnlinesset{skip=6pt}
1746 \begin{scanexample}
1747 \eqnlinesset{punct=.}
1748 The equation
1749 \[ x = \cos\phi \eqnpunct{} \]
1750 can also be written as
1751 \eqnpunct,
1752 \[ x = (z+z^{-1})/2 \]
1753 where we assume
1754 \[ z = \exp(i\phi) \]
1755 \end{scanexample}
1756 \showexampleh
1757 \end{example}
1758
1759 Arguably, the implementation of the scheme
1760 will take higher efforts than direct coding of punctuation.
1761 Hence, the scheme can be useful in situations
1762 where equations typically terminate phrases or
1763 where punctuation is otherwise expected in regular patterns.
1764 The use of the scheme will be most efficient
1765 in the symbolic shortcut form to be explained below.
1766
1767 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1768 \paragraph{Levels and Adjustments.}
1769
1770 \DescribeKey{punctcol}
1771 \DescribeKey{punctline}
1772 \DescribeKey{punctall}
1773 \DescribeMod{`}
1774 For multi-line equations, there are two further levels of default punctuation
1775 for terminating columns and lines
1776 which are specified via the option |punctcol| and |punctline|.
1777 A punctuation item may also be handed on to the next lower level
1778 of punctuation via the starred forms |punct*| and |punctline*|.
1779 Several levels of punctuation can be specified simultaneously by |punctall|
1780 or via the modifier `|`|':
1781 %
1782 \begin{center}
1783 |punctall={|[[\textit{col}]\textit{line}]\textit{main}|}|
1784 \qquad
1785 |\[`{|[[\textit{col}]\textit{line}]\textit{main}|}|\,\ldots|\]|
1786 \end{center}
1787 %
1788 The special value `|~|' represents no punctuation
1789 and |\relax| hands down.
1790 An empty argument for |punctall| or `|`|' removes all levels of punctuation.
1791
1792 \begin{example}
1793 \begin{scanexample}
1794 \<`{,;.}
1795 x &= \cos\phi &
1796 \phi &= \arccos x \\
1797 x &= (z+z^{-1})/2 &
1798 \phi &= -i\log z \>
1799 \end{scanexample}
1800 \showexampleh[0.4]
1801 \end{example}
1802
1803 \DescribeInterfaceMacro{\eqnpunctapply}
1804 \DescribeControl{punct}
1805 In situations, where the punctuation must appear before the end
1806 of the block, e.g.\ before a ``QED'',
1807 it can be invoked manually by |\eqnpunctapply|
1808 or by the control |punct|[|={|\textit{punct}|}|].
1809 Further automatic punctuation is suppressed within the current display.
1810 \DescribeControl{punctcol}
1811 \DescribeControl{punctline}
1812 The line and column punctuation can also be accessed by
1813 the controls |punctline| and |punctcol|.
1814
1815 \DescribeKey{punctsep}
1816 \DescribeKey{punctclass}
1817 For convenience, one may also specify a desired space
1818 (or any other code sequence) preceding the punctuation
1819 by |[punctsep={|\textit{sep}|}]|,
1820 e.g.\ \textit{sep}=|\,| or \textit{sep}=|\|\texttt{\textvisiblespace}.
1821 It makes sense to also set the math class preceding punctuation
1822 by |[punctclass={|\textit{class}|}]|,
1823 e.g.\ \textit{class}=|\mathclose{}|,
1824 to avoid additional space in some situations.
1825
1826
1827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1828 \paragraph{Symbolic Notation.}
1829
1830 The full power of the punctuation scheme comes alive in symbolic notation.
1831 Adjustments to punctuation can be done by adding
1832 modifiers to the opening and closing statements
1833 of equation blocks as well as for line and column breaks:
1834 %
1835 \begin{center}
1836 \begin{tabular}{c}
1837 |\[|\textit{mod}\texttt{\textvisiblespace} \\
1838 |\<|\textit{mod}\texttt{\textvisiblespace}
1839 \end{tabular}
1840 \qquad
1841 \begin{tabular}{c}
1842 |\\|\textit{mod}\texttt{\textvisiblespace} \\
1843 |\&|\textit{mod}\texttt{\textvisiblespace}
1844 \end{tabular}
1845 \qquad
1846 \begin{tabular}{c}
1847 |\]|\textit{mod}\texttt{\textvisiblespace} \\
1848 |\>|\textit{mod}\texttt{\textvisiblespace}
1849 \end{tabular}
1850 \end{center}
1851 %
1852 The opening statement is somewhat out of place
1853 for punctuation adjustments which take effect only later;
1854 it is most useful for general adjustments to punctuation
1855 for the equation block.
1856 Conversely, the closing statement, line and column breaks
1857 display the adjusted punctuation right where it is declared.
1858
1859 \DescribeMod{.}
1860 \DescribeMod{,}
1861 \DescribeMod{\string~}
1862 \DescribeMod{`}
1863 The modifiers dot `|.|', comma `|,|' and tilde `|~|'
1864 are short forms for using a dot, a comma or disabling punctuation.
1865 A custom punctuation can be set by the modifier `|`{|\textit{punct}|}|'.
1866 %
1867 \begin{center}
1868 \begin{tabular}{rccccc}
1869 \textit{mod}: & |~| & |.| & |,| & |`{|\textit{punct}|}| & |!|
1870 \\\hline
1871 punctuation: & none & dot & comma & \textit{punct} & |\eqnpunctapply|
1872 \end{tabular}
1873 \end{center}
1874 %
1875 \DescribeMod{!}
1876 The line and column break `|\\|', `|\&|'
1877 allow for the additional modifier `|!|'
1878 which applies the main punctuation level of the block
1879 (or an explicit local adjustment) by issuing |\eqnpunctapply|.
1880 \DescribeMod{/}
1881 Note that the continued equation marker `|\\/|' also
1882 suppresses the punctuation at the line break.
1883
1884 \begin{example}
1885 \eqnlinesset{number=on}
1886 \begin{scanexample}
1887 \<`{,.}
1888 x &= \cos\phi \\/
1889 &= (z+z^{-1})/2 \\
1890 \phi &= \arccos x \\/
1891 &= -i\log z \\`;
1892 z &= \exp(i \phi) \\~
1893 &= x+i\sqrt{1-x^2} \>`{?!}
1894 \end{scanexample}
1895 \showexampleh
1896 \end{example}
1897
1898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1899 \subsection{Equation Alignment}
1900 \label{sec:alignment}
1901
1902 The columns mode of a multi-line equation block
1903 produces (several columns of) equations to be aligned
1904 at some position within each line.
1905 This is used to collect several equations into an array,
1906 but it also facilitates the breaking of a long equation
1907 or a chain of equations into the available horizontal space, e.g.
1908 %
1909 \<* \&: a \\= b+c \\= d-e \\; +f \>
1910 %
1911 Here, the first two lines represent a chain of equations
1912 and the third line continues the right-hand side begun in the second line.
1913 The alignment puts all equality relations within a vertical tower
1914 and the right-hand sides strictly to the right of the equality sign.
1915
1916 Technically, each equation component within a line
1917 is to be aligned at one specific position.
1918 In the above example, the alignment is chosen to be at the equality relation,
1919 Such an alignment splits the equation component
1920 into two separate maths blocks which interferes with
1921 \latex/'s math kerning mechanism:
1922 \latex/ will determine the kerning between all math symbols,
1923 but only within their math block.
1924 Unfortunately, \latex/ cannot determine the appropriate kerning
1925 between the two blocks;
1926 this has to be determined by some other means or assumption.
1927 Consistency of the kerning requires consistency of the assumptions.
1928 A natural assumption is to put the alignment at an equality relation;
1929 here, the kerning will depend on whether the alignment is just before
1930 or just after the equality sign
1931 (and whether it is to the left or to the right of the kerning
1932 between the equality sign and the surrounding symbols).
1933
1934 The principal assumption for the \amsmath/ environment |align|
1935 is that the left part of the column ends with an ordinary character.
1936 This leads to the correct spacing when an equation $a=b+c$
1937 is broken before the equals relation as |a&=b+c|,
1938 and also if an equation sequence continues on the next line as |\\&=d-e|.
1939 It naturally places the alignment left of the equality relation
1940 (and left of the leading kerning).
1941 However, it is difficult to achieve the right spacing
1942 if the right-hand side is to be broken into several lines:
1943 For instance, |\\&+f|
1944 aligns the subordinate binary operation with the equals sign
1945 (which may be undesirable).
1946 Instead placing a phantom equals sign is an effort
1947 that somewhat disrupts source readability.
1948
1949 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1950 \paragraph{Math Classes at Alignments.}
1951
1952 \DescribeKey{class}
1953 \DescribeKey{ampeq}
1954 \DescribeKey{eqamp}
1955 \DescribeMod{<}
1956 \DescribeMod{>}
1957 The package implements a more flexible assignment of math classes
1958 at the alignment. The above default behaviour is invoked by
1959 the optional argument |class=ampeq| (|ampeq| for short or `|<|' as modifier).
1960 The optional argument |class=eqamp| (|eqamp| for short or `|>|' as modifier)
1961 imposes math classes at the alignment
1962 such that an equation sign should be placed just before the alignment.
1963 Concretely, it inserts a |\mathrel{}| class just after
1964 the alignment marker. Furthermore, in case of an empty left alignment cell,
1965 the leading math class is changed to |\mathord{}|
1966 so that a following binary operator is not interpreted as a unary one.
1967 For example, the following two expressions produce identical output:
1968
1969 \begin{example}
1970 \begin{scanexample}
1971 \<< &\mathrel{\phantom{=}} a \\
1972 &= b+c \\
1973 &= d-e \\
1974 &\mathrel{\phantom{=}}\mathclose{} +f \>
1975 \end{scanexample}
1976 \showexampleh[0.7]
1977 \begin{scanexample}
1978 \<> \,& a \\
1979 =& b+c \\
1980 =& d-e \\
1981 & +f \>
1982 \end{scanexample}
1983 \showexampleh[0.7]
1984 \end{example}
1985
1986 \DescribeKey{classout}
1987 \DescribeKey{classin}
1988 \DescribeKey{classlead}
1989 Math classes just before and after alignment can be adjusted freely
1990 by the optional arguments:
1991 %
1992 \begin{center}
1993 |classout={|\textit{class}|}|,
1994 \qquad
1995 |classin={|\textit{class}|}|,
1996 \qquad
1997 |classlead={|\textit{class}|}|.
1998 \end{center}
1999 %
2000 The parameter |classlead|
2001 determines the math class just after the alignment
2002 if the cell before alignment is empty (has zero width).
2003 The spacing at the alignment is determined by the pairing
2004 of the last/first character and the selected math class at the alignment:
2005 %
2006 \<[classin={},classout={},classlead={},*]
2007 \framebox[1em]{\bstrut}\ \framebox[1em]{\bstrut}\
2008 \framebox[1em]{\bstrut a}\ \underline{\makebox[3em]{\itshape a-out}}
2009 \ \vrule&
2010 \ \underline{\makebox[3em]{\itshape in-b}}\ \framebox[1em]{\bstrut b}
2011 \ \framebox[1em]{\bstrut}\ \framebox[1em]{\bstrut}
2012 \\
2013 \vrule&
2014 \ \underline{\makebox[3em]{\itshape lead-c}}\ \framebox[1em]{\bstrut c}
2015 \ \framebox[1em]{\bstrut}\ \framebox[1em]{\bstrut}
2016 \>
2017
2018 \DescribeControl{rel}
2019 \DescribeControl{rel;}
2020 \DescribeControl{rel*}
2021 The package provides a control to encode an aligned relation
2022 that issues the alignment tab `|&|' in the appropriate location
2023 for both the |ampeq| and |eqamp| modes:
2024 %
2025 \begin{center}
2026 |\eqncontrol{rel|[|={|\textit{rel}|}|]\textbar|;|\textbar|*}|
2027 \end{center}
2028 %
2029 The form |rel| will use the default equality relation (preset to `|=|')
2030 whereas |rel={|\textit{rel}|}| uses the relation \textit{rel} instead.
2031 The special form |rel;| indicates the continuation of an equation term
2032 by replacing the equality relation with space.
2033 Conversely |rel*| indicates the start of an equation
2034 when a left-hand side fits better on the right-hand side of the alignment;
2035 this is very similar to |rel;| but uses a slightly different spacing.
2036
2037 \DescribeKey{rel}
2038 \DescribeKey{classstart}
2039 \DescribeKey{classbreak}
2040 The default relation symbol can be adjusted
2041 by the option |rel={|\textit{rel}|}|.
2042 The space for the start of an equation is defined by the option
2043 |classstart={|\textit{code}|}|, where \textit{code} is some \latex/ code
2044 that accepts the default relation symbol as argument `|#1|'
2045 (for use in |\phantom|).
2046 Similarly, |classbreak={|\textit{code}|}| defines the space
2047 for a continued equation term.
2048 Note that the latter two settings apply only to |ampeq| mode;
2049 whereas the space is canonically generated in |eqamp| mode.
2050
2051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2052 \paragraph{Symbolic Notation.}
2053
2054 The placement or omission of aligned equality relations
2055 is most conveniently achieved in the symbolic notation
2056 using modifiers to the line break `|\\|' and the column break `|\&|'.
2057 \DescribeMod{=}
2058 \DescribeMod{?}
2059 \DescribeMod{;}
2060 \DescribeMod{:}
2061 \DescribeMod{\verbbar}
2062 The modifiers `|=|', `|?|', `|;|', `|:|' and `\verbbar' indicate
2063 typical situations encountered for a set of aligned equations as follows:
2064 %
2065 \begin{center}
2066 \begin{tabular}{cl}
2067 \textit{mod}: & meaning
2068 \\\hline
2069 none & start new equation in left cell \\
2070 |=| & continue equation with default relation (`|=|') \\
2071 |?{|\textit{rel}|}| & relation with symbol \textit{rel} \\
2072 |;| & continue equation term in right cell \\
2073 |:| & start new equation in right cell \\
2074 \verbbar & alignment within term (following a |\mathord|) \\
2075 \end{tabular}
2076 \end{center}
2077 %
2078 If no relation modifier is specified, `|\\|' will break the line
2079 and start in the leftmost cell whereas `|\&|'
2080 will terminate the current column and continue
2081 in the left cell of the next column.
2082 When a relation modifier is present, `|\\|' will break the line
2083 and fill the leftmost cell
2084 (and potentially the start of the following right cell)
2085 with the desired relation;
2086 it will always leave at the beginning of the right cell.
2087 Similarly, `|\&|' will fill the next left cell with the aligned relation
2088 and leave at the beginning of the following right cell.
2089 \DescribeKey{crrelnext}
2090 Note that `|\\|' with a relation modifier
2091 `|=|', `|?|', `|;|' or `\verbbar' (but not `|:|')
2092 describe the interior of an equation;
2093 consequently, it will always suppress punctuation
2094 and it will also issue a |\numbernext|
2095 (if the option |crrelnext| is active).
2096
2097 The following two examples show
2098 a symbolic notation for the above continued equation
2099 and two columns of continued equations:
2100 %
2101 \begin{example}
2102 \eqnlinesset{number=on}
2103 \begin{scanexample}
2104 \< \&: a \\= b+c \\?\simeq d-e \\; +f \>
2105 \end{scanexample}
2106 \showexampleh[0.6]
2107 \begin{scanexample}
2108 \<`{,;.}
2109 a \&= b+c \&~ \& A \&= B+C \\/
2110 \&= d-e \& \&/ \& \&= D-E \\/
2111 \& \& \&; +F \>
2112 \end{scanexample}
2113 \showexampleh[0.6]
2114 \end{example}
2115
2116 In the first example,
2117 `|\&:|' starts the equation on the right of the alignment,
2118 `|\\=|' continues the equation on the next line with an equality
2119 and `|\\;|' continues the equation term on the next line without equality;
2120 furthermore, the main equality symbol is set to $\equiv$.
2121
2122 In the second example, aligned equality relations are denoted by `|\&=|'
2123 and continued terms by `|\&;|'.
2124 The three columns are separated by `|\&|' and `|\&~|'
2125 with and without punctuation, respectively;
2126 however, a `|\&|' also suppresses punctuation if there is no content
2127 to the right of the alignment.
2128 Numbering is delayed and line punctuation by `;' is suppressed
2129 by `|\\/|' to account for the continued equations.
2130 Finally the middle column just contains a `|\&/|' to produce the
2131 ampersand character.
2132
2133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2134 \subsection{Vertical Spacing}
2135 \label{sec:vspace}
2136
2137 Display equations in \tex/ are considered to be part
2138 of the surrounding paragraph of text.
2139 Hence, the vertical spacing depends on the surrounding text,
2140 in particular on the width and depth of the line of text
2141 directly preceding the equation.
2142 Due to this influence it can be difficult to manually adjust
2143 the spacing accurately.
2144 The package adds several options to control the vertical spacing,
2145 and it also implements a uniform behaviour for all types of equations.
2146
2147 The spacing is determined by combination of several aspects:
2148
2149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2150 \paragraph{Baselines.}
2151
2152 First, \tex/ inserts some glue between lines of text
2153 to make them appear as regular as possible.
2154 The amount of inserted glue is determined by \tex/'s rules
2155 which depend on height, depth and intended baseline separation.
2156 This interline spacing also applies to the lines of displayed equations
2157 as well as the interfaces between text and displayed equations.
2158
2159 \DescribeKey{spread}
2160 The spacing between the lines of a multi-line equation environment
2161 can be adjusted via |spread={|\textit{dimen}|}|
2162 which defaults to |\jot|$\equiv$|3pt| above the normal baseline skip.
2163 \DescribeKey{strut}
2164 \DescribeKey{strutdepth}
2165 In addition, all equation lines and tags
2166 are supplied with struts to ensure a minimum height and depth.
2167 The latter behaviour is controlled by the switch |strut|
2168 which takes the values `|on|' (default), `|cells|', `|tags|' or `|off|'.
2169 The relative depth of such a strut is determined by |strutdepth|
2170 (default |0.3|).
2171
2172 While the height/depth of text typically takes rather uniform values,
2173 the height/depth of math content can range wildly with the context
2174 (plain equations vs.\ fractions and matrices).
2175 As displayed equations are normally surrounded by
2176 a relatively large amount of glue,
2177 it makes sense to reduce the dependency on the height/depth of math content.
2178 Therefore, the package makes equation environments
2179 appear to the surrounding text
2180 as a line with a fixed height and depth,
2181 and thus interline glue merely fills some potential gaps of the
2182 surrounding text.
2183 \DescribeKey{displayheight}
2184 \DescribeKey{displaydepth}
2185 The apparent height and depth are defined by
2186 |displayheight| and |displaydepth|
2187 which default to the dimensions of a strut.
2188
2189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2190 \paragraph{Vertical Situation.}
2191
2192 Second, the spacing of display equations depends on the width
2193 of the previous line of text.
2194 If the math content fits well into the available horizontal space,
2195 the display equation is called short
2196 and less glue is needed above the equation.
2197 The package implements this basic \tex/ feature
2198 for all single- and multi-line equation environments.
2199
2200 \begin{example}
2201 \begin{scanexample}
2202 example of a long text line:
2203 \[ \mbox{long mode} \]
2204 vs.\ short:
2205 \[ \mbox{short mode} \]
2206 following line
2207 \end{scanexample}
2208 \showexampleh
2209 \end{example}
2210
2211 \tex/ also reduces the amount of glue below short equations
2212 (potentially to make their spacing appear more uniform).
2213 \DescribeKey{shortmode}
2214 The package allows to adjust the spacing for short equations
2215 via the global option |shortmode=|\textit{mode}
2216 where \textit{mode} takes the values:
2217 %
2218 \begin{center}
2219 \begin{tabular}{lll}
2220 \textit{mode} & reduced glue \\
2221 \hline
2222 |off| & disabled \\
2223 |above| & above short equations (package default) \\
2224 |belowone| & also below short single-line equations \\
2225 |belowall| & also below all short multi-line equations \\
2226 \end{tabular}
2227 \end{center}
2228 %
2229 \DescribeKey{short}
2230 \DescribeKey{long}
2231 Short and long amounts of glue can also be enforced for
2232 individual equation environments
2233 via the optional arguments |short| and |long|
2234 taking the values |above|, |below| or |both|.
2235
2236 \begin{example}
2237 \begin{scanexample}
2238 example of a long text line:
2239 \[[short] \mbox{forced short} \]
2240 and short:
2241 \[[long] \mbox{forced long} \]
2242 following line
2243 \end{scanexample}
2244 \showexampleh
2245 \end{example}
2246
2247 There are three special situations |cont|, |par| and |top|
2248 which trigger different spacings:
2249 |cont| describes the situation
2250 at the start of an empty horizontal list
2251 (invoked by |\noindent|)
2252 or when an equation block directly follows another one;
2253 here, the space above the equation should be minimal
2254 (or even negative to remove the space below the previous equation block).
2255 |par| describes the situation at the beginning of a paragraph
2256 (invoked by |\par|);
2257 here, the space above the equation adds to the space between paragraphs.
2258 |top| describes the situation at the top of a vertical list
2259 (invoked by |\nointerlineskip|);
2260 here, one would typically want no space.
2261
2262 \begin{example}
2263 \eqnlinesset{belowtopmode=long}
2264 \begin{scanexample}
2265 \hrule\begin{minipage}{\linewidth}
2266 \[ \mbox{top} \]
2267 some text\par
2268 \[ \mbox{par} \]
2269 \[ \mbox{cont} \]
2270 \end{minipage}\hrule
2271 \end{scanexample}
2272 \showexampleh
2273 \end{example}
2274
2275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2276 \paragraph{Explicit Spacing.}
2277
2278 Third, the package provides several means to adjust the
2279 glue around equations:
2280
2281 \DescribeKey{noskip}
2282 \DescribeKey{medskip}
2283 Next to |short| and |long| the spacing above and below
2284 equation environments can be reduced
2285 to some other fixed smaller amount via |medskip|
2286 or removed altogether via |noskip|.
2287 These keys also take the values |above|, |below| or |both|.
2288
2289 \begin{example}
2290 \begin{scanexample}
2291 \hrule
2292 \[[long] \mbox{long default} \]
2293 \hrule
2294 \[[medskip] \mbox{medium space} \]
2295 \hrule
2296 \[[noskip] \mbox{no space} \]
2297 \hrule
2298 \end{scanexample}
2299 \showexampleh
2300 \end{example}
2301
2302 \DescribeKey{par}
2303 By default, equation environments end in horizontal mode without indentation.
2304 The key |par| controls whether
2305 the equation environments end in horizontal mode as usual (value |cont|)
2306 or in vertical mode (value |par|, default)
2307 with a dedicated amount of glue |belowparskip|.
2308 An environment can also be made to end in vertical mode
2309 without interline skip (value |top|)
2310 using the glue |belowtopskip|.
2311 The key |par| can be used for situations when vertical mode is preferred,
2312 e.g.\ for lists following equations
2313 where the vertical space above the list is excessive.
2314 In the following example,
2315 |\hrule| will leave an empty line when not in vertical mode.
2316
2317 \begin{example}
2318 \begin{scanexample}
2319 \hrule some text
2320 \[ \mbox{cont} \]
2321 \hrule some text
2322 \[[par] \mbox{par} \]
2323 \hrule
2324 \end{scanexample}
2325 \showexampleh
2326 \end{example}
2327
2328 \DescribeKey{...skip}
2329 \DescribeInterfaceMacro{\vspace}
2330 \DescribeKey{...space}
2331 Variable amounts of skip can be set via
2332 |aboveskip| and |belowskip| or |skip| for both simultaneously.
2333 In addition, the package extends the \latex/ |\vspace| mechanism
2334 to equation bodies where it adds vertical space
2335 below the next equation line or below the equation environment.
2336 Additional glue can be added above or below equation environments
2337 by means of the options |abovespace| and |belowspace|.
2338
2339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2340 \paragraph{Glue Dimensions.}
2341
2342 The package also maintains several global vertical space settings
2343 |above|\textit{pos}|skip| and |below|\textit{pos}|skip|
2344 (sometimes \textit{pos}|skip| for both):
2345 %
2346 \DescribeKey{...skip}
2347 \begin{center}
2348 \begin{tabular}{lll}
2349 \ldots\textit{pos}|skip| & both & description \\
2350 \hline
2351 |...long...| & |longskip| & regular amount of glue \\
2352 |...short...| & -- & reduced glue for short equations \\
2353 |...cont...| & -- & glue when issued from an empty |\noindent| paragraph \\
2354 |...par...| & -- & glue when starting a paragraph (in vertical mode)\\
2355 |...top...| & -- & glue when issued at the top of vertical list \\
2356 |...med...| & |medskip| & medium amount of glue \\\hline
2357 |...tag...| & |tagskip| & minimum glue for outer raised/lowered tags \\
2358 \end{tabular}
2359 \end{center}
2360 %
2361 \DescribeKey{...mode}
2362 The situations \textit{pos}=|cont|, |par| and |top|
2363 use the respective amount of glue |above|\textit{pos}|skip|
2364 above the equations and the regular amount of glue |belowlongskip| below.
2365 These behaviours may be adjusted by the global options
2366 |above|\textit{pos}|mode| and |below|\textit{pos}|mode|
2367 with the values:
2368 %
2369 \begin{center}
2370 \begin{tabular}{lll}
2371 value & reduced glue \\
2372 \hline
2373 |long| & regular amount of glue \\
2374 |short| & reduced glue for short equations \\
2375 |cont| & amount for empty paragraph \\
2376 |par| & amount for paragraph (and end the paragraph) \\
2377 |top| & amount for top (and end the paragraph without interline skip) \\
2378 |noskip| & no glue \\
2379 |medskip| & medium amount of glue \\
2380 \end{tabular}
2381 \end{center}
2382
2383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2384 \paragraph{Page Breaks.}
2385
2386 \DescribeKey{prebreak}
2387 \DescribeKey{postbreak}
2388 \DescribeKey{allowbreaks}
2389 \DescribeKey{prepenalty}
2390 \DescribeKey{postpenalty}
2391 \DescribeKey{interpenalty}
2392 \DescribeInterfaceMacro{\displaybreak}
2393 Finally, the breaking of multi-line equations across pages
2394 can be controlled as follows:
2395 The setting |allowbreaks| (or |allowdisplaybreaks|)
2396 taking values |0| (never) through |4| (permissive)
2397 controls the permittivity of page breaks within multi-line equations.
2398 The optional arguments |prebreak| and |postbreak|
2399 taking values |0| (do not) through |4| (enforce)
2400 suggest a break just above or below the equation environment.
2401 The command |\displaybreak[|\textit{val}|]|
2402 with values |0| through |4| (default)
2403 suggests a break below the current line or below the equation environment.
2404
2405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2406 \subsection{Further Environments and Features}
2407 \label{sec:further}
2408
2409 The package supplies some additional environments and features:
2410
2411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2412 \paragraph{Equation Boxes.}
2413
2414 \DescribeEnv{equationsbox}
2415 The package provides a boxed equation environment |equationsbox|
2416 which can be used within arbitrary math content.
2417 It works analogously to |equations| including optional arguments
2418 and modifiers, but it offers a reduced range of functionality
2419 such as (evidently) no numbering
2420 (yet, the |lines| mode accepts multiple columns here).
2421
2422 \DescribeKey{top,t}
2423 \DescribeKey{center,c}
2424 \DescribeKey{bottom,b}
2425 The equations box accepts several arguments:
2426 |top|, |center|, |bottom| (or |t|, |c|, |b|)
2427 specify the vertical alignment of the box.
2428 \DescribeKey{margin}
2429 \DescribeKey{marginleft}
2430 \DescribeKey{marginright}
2431 |margin|, |marginleft|, |marginright|
2432 specify additional margin space around the equations box.
2433 \DescribeKey{colsep}
2434 |colsep| specifies the amount of separation between the columns.
2435 \DescribeKey{frame}
2436 \DescribeKey{wrap}
2437 |frame|[|=|\textit{cmd}] encloses the equations box
2438 by a \textit{cmd} such as |\fbox| which accepts one argument
2439 (or a command sequence which ends with a macro accepting one argument).
2440 |wrap={{|\textit{cmdl}|}{|\textit{cmdr}|}}|
2441 surrounds the equations box by the two commands
2442 \textit{cmdl} and \textit{cmdr}.
2443
2444 \begin{example}
2445 \begin{scanexample}
2446 \[ \begin{equationsbox}[margin=1em,
2447 wrap={\left\{}{\right\}}]
2448 x &= \cos\phi \\
2449 \phi &= \arccos x
2450 \end{equationsbox} \]
2451 \end{scanexample}
2452 \showexampleh
2453 \end{example}
2454
2455 \DescribeInterfaceMacro{\<...\string\>}
2456 The equations box can also be invoked
2457 by the symbolic short form |\<|\,\ldots|\>|
2458 when called within math mode.
2459 The symbolic form accepts modifiers
2460 to adjust punctuation and equality relations.
2461 \DescribeMod{!}
2462 Note that |equationsbox| uses the current line and column punctuation settings,
2463 but it does not inherit the top punctuation from the containing block.
2464 To this end, the modifier `|!|' invokes |\eqnpunctapply|
2465 to terminate punctuation with the top punctuation for the block.
2466
2467 \begin{example}
2468 \eqnlinesset{number=on}
2469 \begin{scanexample}
2470 \[`{,;.} \Longrightarrow
2471 \<=[shape=l,frame]
2472 x = \cos\phi &
2473 \phi = \arccos x \\
2474 x = (z+z^{-1})/2 &
2475 \phi = -i\log z
2476 \>! \Longleftarrow \]
2477 \end{scanexample}
2478 \showexampleh[0.45]
2479 \end{example}
2480
2481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2482 \paragraph{Cases and Matrix Environments.}
2483
2484 \DescribeEnv{cases}
2485 \DescribeKey{cases}
2486 \DescribeKey{condsep}
2487 The |cases| environment is reimplemented
2488 using the special mode |cases| of |equationsbox|
2489 with two left-aligned cells
2490 whose separation may be adjusted by the option |condsep|.
2491 \DescribeKey{braces}
2492 The equations box is wrapped by a left brace by default;
2493 this behaviour may be adjusted by the option |braces|
2494 taking the values |off|, |l|, |r|, |lr|.
2495 \DescribeKey{intro}
2496 \DescribeKey{introtext}
2497 Furthermore, a common intro \textit{text} for all conditions
2498 may be added by the option |intro={|\textit{text}|}|;
2499 |introtext| sets \textit{text} in text mode with a trailing space.
2500 \DescribeKey{textcond}
2501 Finally, the option |textcond| determines that right cells are given in mode.
2502 \DescribeKey{punctcases}
2503 All features of |equationsbox|, such as punctuation,
2504 are equally available for |cases|.
2505 The global setting |punctcases| and the local setting |punctcol|
2506 set the punctuation for the left column
2507 whereas the right column uses |punctline|.
2508
2509 \begin{example}
2510 \begin{scanexample}
2511 \[ x =
2512 \begin{cases}[introtext={if},braces=lr]
2513 1 & \phi = 0 \\
2514 0 & \phi = \pi/2
2515 \end{cases} \]
2516 \end{scanexample}
2517 \showexampleh[0.7]
2518 \begin{scanexample}
2519 \[`{,.} x = \<[cases,textcond]
2520 \cos\phi & one way \\
2521 (z+z^{-1})/2 & or the other \>! \]
2522 \end{scanexample}
2523 \showexampleh[0.6]
2524 \end{example}
2525
2526 \DescribeEnv{?matrix}
2527 The set of |matrix| environments is reimplemented
2528 using particular combinations of options for |equationsbox|:
2529 The matrix is arranged in |lines| mode
2530 with centred cells |shape=center|.
2531 \DescribeKey{spread*}
2532 The line spread is reset by |spread*|.
2533 Punctuation is turned off by |punctall={}|.
2534 \DescribeKey{style}
2535 The cells are rendered in |\textstyle|
2536 using the option |style=text|.
2537 \DescribeKey{colsep*}
2538 A small column separation |colsep*|
2539 is selected by |colsep=short|.
2540 \DescribeKey{delim}
2541 Finally, the equations box is wrapped by a pair of delimiters
2542 \textit{l} and \textit{r}
2543 using the option |delim={|\textit{l}\textit{r}|}|.
2544 Again, all features of |equationsbox|
2545 are equally available for the |matrix| environments.
2546 \DescribeKey{matrix}
2547 Altogether, the combination is achieved by the shortcut option
2548 |matrix={|\textit{l}\textit{r}|}|,
2549 where \textit{l}\textit{r} may take the following abbreviations:
2550 %
2551 \begin{center}
2552 \begin{tabular}{cccccccc}
2553 \textit{lr} & `|.|' & |r| & |s| & |a| & |c| & |v| & |d|
2554 \\\hline
2555 brackets & none & round & square & angle & curly & bars & double bars
2556 \\
2557 result & $\ldots$ & $(\ldots)$ & $[\ldots]$ & $\langle\ldots\rangle$
2558 & $\lbrace\ldots\rbrace$ & $\vert\ldots\vert$ & $\Vert\ldots\Vert$
2559 \end{tabular}
2560 \end{center}
2561
2562 \begin{example}
2563 \begin{scanexample}
2564 \[ \begin{pmatrix}
2565 \cos\phi & -\sin\phi \\
2566 \sin\phi & \cos\phi
2567 \end{pmatrix} \]
2568 \end{scanexample}
2569 \showexampleh
2570 \begin{scanexample}
2571 \[ \<[matrix=v,shape=r]
2572 \cos\phi & -\sin\phi & 0 \\
2573 \sin\phi & \cos\phi & 0 \\
2574 0 & 0 & -1
2575 \> \]
2576 \end{scanexample}
2577 \showexampleh
2578 \end{example}
2579
2580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2581 \paragraph{Collective Numbering.}
2582
2583 \DescribeEnv{subequations}
2584 \DescribeKey{subeqtemplate}
2585 The environment |subequations| groups equations contained in the body
2586 with a common primary equation number and an extra level
2587 of numbering (typically: a,\,b,\,c,\,\ldots).
2588 The numbering layout can be controlled via |subeqtemplate|.
2589 For instance, the default behaviour of adding lowercase latin letters
2590 to the parent equation number (|#1|)
2591 is achieved by:
2592 %
2593 \begin{center}
2594 |subeqtemplate={#1\alph{#2}}|
2595 \end{center}
2596
2597 \begin{example}
2598 \eqnlinesset{number=on}
2599 \begin{scanexample}
2600 \eqnlinesset
2601 {subeqtemplate={#1-\roman{#2}}}
2602 \begin{subequations}
2603 \[ x = \cos\phi \]
2604 and
2605 \[ \phi = \arccos x \]
2606 \end{subequations}
2607 \end{scanexample}
2608 \showexampleh[0.55]
2609 \end{example}
2610
2611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2612 \paragraph{Text Intermissions.}
2613
2614 \DescribeEnv{intertext}
2615 \DescribeInterfaceMacro{\intertext}
2616 The environment |intertext| (equivalently the macro |\intertext|)
2617 injects a (short) line of text
2618 into a multi-line equation while preserving the equation alignment
2619 across the text.
2620 The |intertext| environment must replace the
2621 end-of-line marker `|\\|' between two lines of the equation
2622 (to avoid blank lines).
2623 The environment accepts several of the vertical spacing adjustments
2624 as an optional argument.
2625
2626 \begin{example}
2627 \begin{scanexample}
2628 \< x &= \cos\phi
2629 \intertext[medskip]{and}
2630 \phi &= \arccos x \>
2631 \end{scanexample}
2632 \showexampleh
2633 \end{example}
2634
2635 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2636 \paragraph{Injection.}
2637
2638 \DescribeControl{inject}
2639 \DescribeControl{inject*}
2640 At a lower level, the control |\eqncontrol{inject={|\textit{cmd}|}}|
2641 injects some command sequence \textit{cmd} after the present equation line
2642 but before interline spacing.
2643 The control |\eqncontrol{inject*={|\textit{cmd}|}}|
2644 injects after interline spacing instead.
2645
2646 \begin{example}
2647 \begin{scanexample}
2648 \< x &= \cos\phi
2649 \eqncontrol{inject=\hrule} \\
2650 \phi &= \arccos x \>
2651 \end{scanexample}
2652 \showexampleh
2653 \end{example}
2654
2655 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2656 \paragraph{Line Marks.}
2657
2658 \DescribeControl{markline}
2659 \DescribeControl{qed}
2660 The package provides a mechanism to mark an equation line
2661 at the end of the present line or just below.
2662 This mechanism can be used to display a QED mark:
2663 %
2664 \begin{center}
2665 \begin{tabular}{l}
2666 |\eqncontrol{markline={symbol=|\textit{sym}|,|\textit{opts}|}|
2667 \\
2668 |\eqncontrol{qed|[|={|\textit{opts}|}|]|}|
2669 \end{tabular}
2670 \end{center}
2671 %
2672 The QED symbol may as well be invoked
2673 by |\qedhere[|\textit{opts}|]| of \ctanpkg{amsthm}.
2674 The starred variants |markline*|, |qed*| and |\qedhere*|
2675 should be used for long lines
2676 where the mark would otherwise smash equation content
2677 (equation numbers are avoided automatically).
2678
2679 \begin{example}
2680 \eqnlinesset{number=on}
2681 \begin{scanexample}
2682 \<[n=l] x &= \cos\phi
2683 \eqncontrol{markline={symbol=$\sqrt{}$}} \\
2684 \phi &= \arccos x
2685 \eqncontrol{qed={shift=.5ex}} \>
2686 \end{scanexample}
2687 \showexampleh[0.6]
2688 \end{example}
2689
2690 The options \textit{opts} can be used
2691 to adjust the placement
2692 by |below| (placed on a separate line below the present line),
2693 |baseline| (smashed at the current baseline),
2694 |bottom| (smashed at the bottom of the present line),
2695 to fine-tune the vertical position by |shift=|\textit{dimen}
2696 or to adjust the symbol by |symbol=|\textit{sym}.
2697 The default position and symbol can be adjusted by
2698 the global settings |markpos|, |marksymbol| and |qedsymbol|.
2699
2700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2701 \paragraph{Frames.}
2702
2703 \DescribeInterfaceMacro{\framecell}
2704 \DescribeControl{framecell}
2705 The package allows to frame cells of an equation block
2706 via issuing a simple command within the cell:
2707 %
2708 \begin{center}
2709 |\framecell[|\textit{cmd}|]|
2710 \qquad or\qquad
2711 |\eqncontrol{framecell|[|={|\textit{cmd}|}|]|}|
2712 \end{center}
2713 %
2714 This command corresponds to |\Aboxed| of \ctanpkg{mathtools}.
2715 In particular, when used within columns or aligned mode,
2716 the frame will extend over both right and left alignment components
2717 of a cell; in order to allocate the right amount of space,
2718 it should be issued within the first cell of the pair.
2719 The layout of the frame can be adjusted
2720 by the optional argument \textit{cmd} which defaults to |\fbox|:
2721 it must be a macro which accepts one argument
2722 (or a command sequence which ends with a macro accepting one argument).
2723 Note:
2724 Any semi-automatic punctuation is included within the frame,
2725 see \secref{sec:punctuation}.
2726 Parts of a cell can be framed by the \amsmath/ macro |\boxed|,
2727 which will not include semi-automatic punctuation.
2728 Furthermore, the height and depth of the box are bounded from below
2729 by a strut, see \secref{sec:vspace}.
2730
2731 \DescribeControl{frametag}
2732 Similarly, the package allows to frame tags:
2733 %
2734 \begin{center}
2735 |\eqncontrol{frametag|[|={|\textit{cmd}|}|]|}|
2736 \end{center}
2737 %
2738
2739 \begin{example}
2740 \eqnlinesset{number=on}
2741 \begin{scanexample}
2742 \<* x &= \cos\phi \\
2743 \framecell \phi &= \arccos x \>
2744 \end{scanexample}
2745 \showexampleh[0.55]
2746 \begin{scanexample}
2747 \[* \framecell[\fboxrule2pt\fbox]
2748 \mbox{important} \eqnpunct! \]
2749 \end{scanexample}
2750 \showexampleh[0.55]
2751 \begin{scanexample}
2752 \[ \framecell[\fcolorbox{white}{yellow}]
2753 \eqncontrol{frametag=\fboxsep2pt\fbox}
2754 \mbox{highlight}\]
2755 \end{scanexample}
2756 \showexampleh[0.55]
2757 \end{example}
2758
2759 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2760 \paragraph{Single-Line Composition.}
2761
2762 \DescribeInterfaceMacro{\eqnbreak}
2763 \DescribeInterfaceMacro{\eqnsep}
2764 \DescribeInterfaceMacro{\eqnjoin}
2765 Several short pieces of math content
2766 may well fit within a single equation line,
2767 typically separated by some amount of space like |\qquad| or |\qquad|.
2768 The package provides several context-aware commands for this purpose:
2769 the commands |\eqnsep| and |\eqnbreak| insert some horizontal glue,
2770 whereas |\eqnjoin| joins two parts of an equation with some conjunction.
2771 The glue typically includes some amount of shrink
2772 in order to accommodate the content when space is sparse.
2773 Furthermore, |\eqnsep| and |\eqnbreak| also automatically insert
2774 the punctuation for columns and lines, respectively.
2775 \DescribeInterfaceMacro{\\}
2776 \DescribeInterfaceMacro{\&}
2777 For convenience, the line and column break commands `|\\|' and `|\&|'
2778 map to |\eqnbreak| and |\eqnsep|
2779 in single-equation mode where they serves no other purpose;
2780 In stacked multi-line mode `|\&|' maps to |\eqnsep|.
2781 The commands have several optional arguments:
2782 %
2783 \begin{center}
2784 |\eqnsep|\textbar|\eqnbreak|\textbar|\\|\,%
2785 \textit{mod}|[|\textit{skip}|]|\textvisiblespace
2786 \qquad
2787 |\eqnjoin|[|*|\textbar|[|\textit{skip}|]|]|{|\textit{conjunction}|}|
2788 \end{center}
2789 %
2790 The modifiers `|.|', `|,|', `|~|', `|`{|\textit{punct}|}|',
2791 `|!|' adjust punctuation and `|*|' chooses a shorter glue,
2792 whereas the optional argument \textit{skip}
2793 specifies the amount of glue explicitly.
2794 \DescribeKey{linesep}
2795 \DescribeKey{colsep}
2796 The default amounts of glue for |\eqnbreak| or `|\\|' and |\eqnsep|
2797 are determined by the settings |linesep| and |colsep|, respectively.
2798 The starred variants |linesep*| and |colsep*|
2799 determine the short amount of glue.
2800
2801 \begin{example}
2802 \begin{scanexample}
2803 \[ x = \cos\phi \\[4em]
2804 \phi = \arccos x \]
2805 \end{scanexample}
2806 \showexampleh
2807 \begin{scanexample}
2808 \[`{,.} x = (z+z^{-1})/2 \\
2809 \phi = -i \log z \]
2810 \end{scanexample}
2811 \showexampleh
2812 \begin{scanexample}
2813 \[ x = \cos\phi \eqnjoin*{\iff}
2814 \phi = \arccos x \]
2815 \end{scanexample}
2816 \showexampleh
2817 \end{example}
2818
2819 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2820 \paragraph{Transposition.}
2821
2822 \DescribeKey{transpose}
2823 \DescribeMod{/}
2824 When the aligned mode is used to produce more than one column of equations,
2825 the default line-by-line ordering of the content may be inconvenient.
2826 The package offers a transposition mode |transpose=plain| in which the content
2827 is specified on a column-by-column basis. Columns are separated by `|\&|'
2828 (the character `\&' must be escaped as `|{\&}|' in this mode)
2829 and the lines within each column are broken by `|\\|' as usual.
2830 The continued transposition mode |transpose=cont|
2831 (abbreviated by the modifier `|/|')
2832 furthermore reduces the input by assuming that all secondary
2833 alignment markers `|&|' indicate a continued equation
2834 and imply a line break with an empty left equation cell.
2835 Note that the transposition is implemented by reprocessing the input,
2836 which imposes some restrictions:
2837 all line and column breaks `|\\|', `|\&|' must be explicit
2838 (must not be produced by macro expansion),
2839 line breaks should not use optional arguments
2840 (they only work on the first column),
2841 and each section separated by `|\&|'
2842 should describe only a single column
2843 with one alignment marker per line (unless in continued transposition mode).
2844 Furthermore, the continued mode processes the alignment marker `|&|',
2845 which may cause issues when nesting aligned content.
2846
2847 \begin{example}
2848 \begin{scanexample}
2849 \<[transpose=plain]
2850 x &= \cos\phi \\ &= (z+z^{-1})/2
2851 \&
2852 \phi &= \arccos x \\ &= -i\log z
2853 \>
2854 \end{scanexample}
2855 \showexampleh
2856
2857 \begin{scanexample}
2858 \<[transpose=cont]
2859 x &= \cos\phi &= (z+z^{-1})/2
2860 \&
2861 \phi &= \arccos x &= -i\log z
2862 \>
2863 \end{scanexample}
2864 \showexampleh
2865 \end{example}
2866
2867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2868 \paragraph{Alternative Content Description.}
2869
2870 \DescribeKey{alt}
2871 \DescribeInterfaceMacro{\eqnalt}
2872 The package provides a basic interface to describe the equation content
2873 in an alternative form for the purposes of accessibility or documentation
2874 (corresponding to the |alt| tag in HTML):
2875 %
2876 \begin{center}
2877 |alt={|\textit{alt text}|}|
2878 \qquad or \qquad
2879 |\eqnalt[|\textit{opt}|]{|\textit{alt}|}|
2880 \end{center}
2881 %
2882 At the moment the alternative text \textit{alt} is not processed further,
2883 but an accessibility extension may implement the feature in tagged PDFs
2884 or HTML conversion. The comma-separated optional arguments \textit{opt}
2885 may specify the content further:
2886 |line| and |cell| restrict the applicability
2887 to the current equation line or cell, respectively.
2888 Other keys might specify the content format and language.
2889
2890 \begin{example}
2891 \begin{scanexample}
2892 \<[alt={example equations}]
2893 x &= \cos\phi \\
2894 \eqnalt[line]{reverse relationship}
2895 \phi &= \arccos x \>
2896 \end{scanexample}
2897 \showexampleh
2898 \end{example}
2899
2900 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2901 \subsection{General Options}
2902 \label{sec:auxiliary}
2903
2904 \DescribeInterfaceMacro{\eqnlinesset}
2905 Options of general nature can be selected by the commands:
2906 %
2907 \begin{center}
2908 \begin{tabular}{rl}
2909 &|\usepackage[|\textit{opts}|]{eqnlines}|
2910 \\
2911 or&|\PassOptionsToPackage{|\textit{opts}|}{eqnlines}|
2912 \\
2913 or&|\eqnlinesset{|\textit{opts}|}|
2914 \end{tabular}
2915 \end{center}
2916 %
2917 |\PassOptionsToPackage| must be used before |\usepackage|;
2918 |\eqnlinesset| must be used afterwards.
2919 \textit{opts} is a comma-separated list of options.
2920
2921 The package supplies the following general settings:
2922 \begin{longtable}{ll}
2923 option & description \\
2924 \hline
2925 |defaults=classic|
2926 & mimic classic \latex//\amsmath/ (layout and dimensions) \\
2927 |defaults=eqnlines|
2928 & \ctanpkg{eqnlines} layout with fontsize-relative dimensions \\
2929 |linesfallback| & single column in align mode reverts to lines mode \\
2930 & value |reuse| avoids third measuring pass \\
2931 |equationcr| & determine overloading of `|\\|' for single equations \\
2932 & |off|: native \latex/ error; |error|: package error; \\
2933 & |break|: insert horizontal glue (see \secref{sec:further}) \\
2934 |amp| & overload `|\&|' encoding column breaks and equality relations \\
2935 |scanequation| & scan single-line environments |equation|
2936 and |\[|\,\ldots|\]| \\
2937 |scanbox| & scan box environments |equationsbox|
2938 and |\<|\,\ldots|\>| \\
2939 |scanpar| & allow scanning of |\par| within equation body \\
2940 & (e.g., for use in nested |\parbox| or |minipage|) \\
2941 |rescan| & rescan environment body for special commands (e.g.\ |\verb|) \\
2942 |modifiereqn| & switch modifiers for equation blocks \\
2943 |modifierbox| & switch modifiers for equation boxes \\
2944 |modifiercr| & switch modifiers for `|\\|' \\
2945 |modifieramp| & switch modifiers for `|\&|' \\
2946 |modifierend| & switch trailing modifiers \\
2947 |modifierwarning| & invoke a warning for unknown environment modifiers \\
2948 |verbose| & track code location in log file for debugging purposes \\
2949 |ampproof| & equip optional argument parsing with protection for `|&|' \\
2950 |nativeequation| & native processing of single-line equations
2951 (reduced functionality) \\
2952 \end{longtable}
2953
2954 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2955 \subsection{Feature Selection and Package Options}
2956 \label{sec:features}
2957
2958 The following few settings can only be specified when loading the package,
2959 not via |\eqnlinesset|:
2960 %
2961 \begin{longtable}{ll}
2962 option & description \\
2963 \hline
2964 |env=none| & provide only |equations| and |equationsbox| environments \\
2965 |env=equation| & provide/overwrite |equation|,
2966 |displaymath| and |\[|\,\ldots|\]| \\
2967 |env=amsmath| & provide/overwrite \amsmath/ environments
2968 (including |equation|) \\
2969 |amsmathends|=\textit{bool} & patch \amsmath/ environments
2970 with individual endings \\
2971 |backup|=\textit{bool} & backup original \amsmath/ environments
2972 as |ams...| \\
2973 |ang|=\textit{bool} & provide |\<|\,\ldots|\>| \\
2974 |eqref|=\textit{bool} & provide |\eqref| \\
2975 |matrix|=\textit{bool} & provide \amsmath/ |?matrix|
2976 and |cases| environments \\
2977 \end{longtable}
2978
2979 If the above settings are explicitly disabled, the package will only supply
2980 the general purpose environment |equations|
2981 and its boxed cousin |equationsbox|.
2982 In that case, the specific equation environments and other features
2983 can be activated by the command:
2984 %
2985 \begin{center}
2986 |\eqnlinesprovide{|\textit{features}|}|
2987 \end{center}
2988 %
2989 \textit{features} is a comma-separated list of features:
2990 %
2991 \begin{longtable}{ll}
2992 feature & description \\
2993 \hline
2994 \textit{env} & provide/overwrite environment \textit{env}:\\
2995 & |equation|, |equation*|, |displaymath|, |subequations| \\
2996 & |gather|, |multline|, |align|, |flalign|, |xalign|, |xxalign| \\
2997 & |gather*|, |multline*|, |align*|, |flalign*|, |xalign*| \\
2998 & |multlined|, |gathered|, |aligned| \\
2999 \textit{env}|=|\textit{name} &
3000 provide environment \textit{env} as \textit{name} \\
3001 |sqr| & provide |\[|\,\ldots|\]| \\
3002 |ang| & provide |\<|\,\ldots|\>| \\
3003 |eqref| & provide/overwrite macro |eqref| \\
3004 |tagform| & provide/overwrite macro |\tagform@|\\
3005 |maketag| & provide/overwrite macro |\maketag@@@|\\
3006 \end{longtable}
3007
3008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3010 \iffalse
3011 \TODO
3012 \section{List of Options}
3013 \label{sec:lists}
3014
3015 \fi
3016
3017
3018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3020 \section{Information}
3021
3022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3023 \subsection{Copyright}
3024 \label{sec:copyright}
3025
3026 Copyright \copyright{} \thecopyright/
3027
3028 Based on the \latex/ package \amsmath/:
3029 Copyright \copyright{}
3030 1995, 2000, 2013 American Mathematical Society;
3031 2016--2024 \latex/ Project and American Mathematical Society.
3032
3033 This work may be distributed and/or modified under the
3034 conditions of the \latex/ Project Public License, either version 1.3
3035 of this license or (at your option) any later version.
3036 The latest version of this license is in
3037 \url{https://www.latex-project.org/lppl.txt}
3038 and version 1.3c or later is part of all distributions of \latex/
3039 version 2008 or later.
3040
3041 This work has the LPPL maintenance status `maintained'.
3042
3043 The Current Maintainer of this work is Niklas Beisert.
3044
3045 This work consists of the files
3046 |README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|
3047 as well as the derived files listed in \secref{sec:installation}.
3048
3049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3050 \subsection{Credits}
3051 \label{sec:credits}
3052
3053 This package is based on the \latex/ package \amsmath/
3054 (initially named \markpkg{amstex})
3055 which in turn is based on the \tex/ macro system \ctanpkg{amstex}
3056 written by Michael Spivak.
3057 The initial work of porting \ctanpkg{amstex} to \latex/
3058 was done in 1988--1989 by Frank Mittelbach and Rainer Sch\"opf.
3059 In 1994 David M.\ Jones added the support for flush-left layout
3060 and did extensive improvements to the align family of environments
3061 and to the equation number handling in general.
3062 Michael Downes at the AMS served as coordinator
3063 for the efforts of Mittelbach, Sch\"opf, and Jones,
3064 and has contributed various bug fixes and additional refinements over time.
3065 Since 2016, the package has been maintained by the \latex/ Project
3066 with contributions by the above and David Carlisle.
3067
3068 This package has been forked from \amsmath/
3069 in accordance with the LPPL, particularly paragraph 6.
3070 The original package \amsmath/ is available
3071 at CTAN within \ctanpkg{latex-amsmath}.
3072 It uses the basic mechanisms for processing
3073 numbered multi-line equations as developed in \amsmath/
3074 (environments |equation|, |align|, |gather|, |multline|, |gathered|, |aligned|
3075 and related), as well as code implementing these mechanisms.
3076 It differs from \amsmath/ in the following aspects:
3077 %
3078 \begin{itemize}
3079 \item
3080 The implementations of |split| and methods unrelated to multi-line equations
3081 and equation numbering have been dropped.
3082 \item
3083 Code has been restructured, macros have been renamed and extended.
3084 \item
3085 Numbering and horizontal adjustment schemes have been unified and extended.
3086 \item
3087 Options for math classes surrounding the alignment have been added.
3088 \item
3089 A punctuation scheme has been added.
3090 \item
3091 Vertical spacing has been redesigned.
3092 \item
3093 Optional parameters have been added to environments.
3094 \item
3095 Various configuration options and layout settings have been added.
3096 \item
3097 Cooperation with \ctanpkg{hyperref}, \ctanpkg{showkeys}
3098 and \amsmath/ has been included into the package.
3099 \end{itemize}
3100
3101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3102 \subsection{Files and Installation}
3103 \label{sec:installation}
3104
3105 The package consists of the files:
3106 %
3107 \begin{longtable}{ll}
3108 |README.txt| & readme file \\
3109 \verbpkg|.ins| & installation file \\
3110 \verbpkg|.dtx| & source file \\
3111 \verbpkg|.sty| & package file \\
3112 \verbpkg|.tex| & reference manual file \\
3113 \verbpkg|.pdf| & reference manual \\
3114 \verbpkg|-src.tex| & source code documentation file \\
3115 \verbpkg|-src.pdf| & source code documentation \\
3116 \end{longtable}
3117 %
3118 The distribution consists of the files
3119 |README.txt|, \verbpkg|.ins| and \verbpkg|.dtx|.
3120 %
3121 \begin{itemize}
3122 \item
3123 Run \latex/ on \verbpkg|.ins| to create the package \verbpkg|.sty|
3124 and further documentation files.
3125 \item
3126 Copy the file \verbpkg|.sty| to an appropriate directory of your \latex/
3127 distribution, e.g.\ \textit{texmf-root}|/tex/latex/|\verbpkg.
3128 \item
3129 Alternatively, you may copy \verbpkg|.sty| to your project directory.
3130 \item
3131 Run (pdf)\latex/ on \verbpkg|.tex|
3132 to compile the manual \verbpkg|.pdf| (this file).
3133 \item
3134 Run (pdf)\latex/ on \verbpkg|-src.tex|
3135 to compile the source code documentation \verbpkg|-src.pdf|.
3136 \end{itemize}
3137
3138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3139 \subsection{Related CTAN Packages}
3140
3141 The package is related to other packages available at CTAN:
3142 %
3143 \begin{itemize}
3144 \item
3145 This package uses the package \ctanpkg{keyval}
3146 to process the options for the package, environments and macros.
3147 Compatibility with the \ctanpkg{keyval} package
3148 has been tested with v1.15 (\markdate{2022-05-29}).
3149 \item
3150 This package reproduces the math environments functionality
3151 of the package \amsmath/.
3152 The present code is based on \amsmath/ v2.17t (\markdate{2024-11-05}).
3153 Compatibility with the \amsmath/ package is maintained
3154 whether \ctanpkg{eqnlines} is loaded before or after \amsmath/.
3155 By default, \ctanpkg{eqnlines} overwrites
3156 most math environments of \amsmath/ with its own implementations.
3157 It can also preserve them as |ams...| if needed.
3158 Alternatively, \ctanpkg{eqnlines} may assign individual names
3159 to the maths environments and preserve the ones of \amsmath/.
3160 The other features provided by \amsmath/
3161 can be used.
3162 \item
3163 The package \ctanpkg{mathtools}
3164 is a popular extension of the \amsmath/ package.
3165 This package incorporates some of the features and improvements
3166 provided by the \ctanpkg{mathtools} package.
3167 Compatibility with the \ctanpkg{mathtools} package
3168 has been tested with v1.31 (\markdate{2024-10-04}),
3169 and it is maintained whether \ctanpkg{eqnlines}
3170 is loaded before or after \ctanpkg{mathtools}.
3171 Some features like emphasising equations via \ctanpkg{empheq}
3172 do not (yet) work.
3173 \item
3174 This package has several overlapping goals and considerations
3175 with the package \ctanpkg{breqn} in handling
3176 long equations more conveniently.
3177 However, the approach is very different from \ctanpkg{breqn}
3178 which mainly aims at automation.
3179 \item
3180 This package cooperates with the package \ctanpkg{hyperref}
3181 to create anchors and references within the electronic document.
3182 Compatibility with the \ctanpkg{hyperref} package
3183 has been tested with v7.01l (\markdate{2024-11-05}).
3184 \item
3185 This package cooperates with the package \ctanpkg{beamer}
3186 in assigning default colours for math content.
3187 Compatibility with the \ctanpkg{beamer} package
3188 has been tested with v3.74 (\markdate{2025-06-15}).
3189 \item
3190 This package supports the display of labels and references
3191 through the package \ctanpkg{showkeys}.
3192 Compatibility with the \ctanpkg{showkeys} package
3193 has been tested with v3.21 (\markdate{2024-05-23}).
3194 \item
3195 This package supports placement of QED symbols within |proof|s
3196 through the |\qedhere| interface of the package \ctanpkg{amsthm}.
3197 Compatibility with the \ctanpkg{amsthm} package
3198 has been tested with v2.20.6 (\markdate{2020-05-29}).
3199 \item
3200 This package supports PDF tagging
3201 using the framework defined in \ctanpkg{tagpdf} and \ctanpkg{luamml}
3202 (when using the |lualatex| engine).
3203 It uses and adjusts some methods from
3204 the development framework \ctanpkg{latex-lab} (|math| and |amsmath| modules).
3205 Compatibility has been tested with the package versions
3206 \ctanpkg{tagpdf} v0.99w (\markdate{2025-10-31}),
3207 \ctanpkg{luamml} v0.7.0 (\markdate{2025-10-20}) and
3208 \ctanpkg{latex-lab} (\markdate{2025-11-01}).
3209 Support for PDF tagging is preliminary, partial and fragile;
3210 it may break due to future developments of the PDF tagging framework.
3211 \item
3212 This package is currently not compatible
3213 with the package \ctanpkg{cleveref}
3214 (thanks to Jon\'a\v s Dujava for pointing out).
3215 The command |\Cref| will not refer properly to equation numbers
3216 recorded by the |equations| environment.
3217 Further features of either package and/or/in combination with \amsmath/
3218 may fail due to the patching by the package.
3219 The alternative package \ctanpkg{zref-clever} appears to work as intended.
3220 Incompatibility with the \ctanpkg{cleveref} package
3221 has been observed for v0.21.4 (\markdate{2018-03-27}).
3222 Compatibility with the \ctanpkg{zref-clever} package
3223 has been tested with v0.5.1 (\markdate{2024-11-28}).
3224 \end{itemize}
3225
3226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3227 \iffalse
3228 \subsection{Feature Suggestions}
3229
3230 The following is a list of features for consideration
3231 towards future versions of this package.
3232 Their potential use may range between useful and niche;
3233 and their difficulty between easy and impossible.
3234
3235 Documentation:
3236 %
3237 \begin{itemize}
3238 \item
3239 complete code documentation
3240 %
3241 \item
3242 list of all option keys with scope, defaults and special values
3243 %
3244 \end{itemize}
3245
3246 Additional functionality:
3247 %
3248 \begin{itemize}
3249 \item
3250 alignment for columns mode (two columns as before)
3251 %
3252 \item
3253 extended columns mode, allow alignment in lines mode
3254 %
3255 \item
3256 reduce intercolumn space below zero if indentation permits
3257 %
3258 \item
3259 single column compressible lines in columns mode
3260 (determine alignment line first)
3261 %
3262 \item
3263 flexible columns mode (note math classes, punctuation, intercolumn space)
3264 %
3265 \item
3266 routine to compose custom option environments
3267 \end{itemize}
3268
3269 Fix or complete functionality:
3270 %
3271 \begin{itemize}
3272 \item
3273 |\vspace| for |equationsbox| (requires line container)
3274 %
3275 \item
3276 adjust PDF tagging with development in kernel,
3277 describe functionality when ready
3278 %
3279 \item
3280 |\intertext| might not collaborate correctly with PDF tagging
3281 %
3282 \item
3283 alternative alignment for `|\&:|' to align with relation (further left)
3284 %
3285 \item
3286 change math classes at following alignment by control (requires cell container)
3287 %
3288 \item
3289 modifier `|@|' or `|_|' for |\&| to just add space in |columns| mode
3290 %
3291 \item
3292 scan for `|[]|' after `|;|' to add space; or use other modifier `|@|')
3293 %
3294 \item
3295 adjust column separation with `|\&[]|' (perhaps use min, also allow shrink?)
3296 %
3297 \item
3298 skip intercolumn for columns |A=B=C|
3299 %
3300 \item
3301 clear several columns with `|\&*|'
3302 %
3303 \end{itemize}
3304
3305 Some technical and/or internal items to be done include:
3306 %
3307 \begin{itemize}
3308 \item
3309 test files
3310 %
3311 \item
3312 check documentation for all features
3313 %
3314 \item
3315 change |\@ifpackageloaded| to |\IfPackageLoaded...|
3316 when command is less recent.
3317 %
3318 \item
3319 change bool registers to |char| 0 and 1 and |\||ifodd|
3320 %
3321 \end{itemize}
3322
3323 \fi
3324
3325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3326 \subsection{Revision History}
3327
3328 \iffalse
3329
3330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3331 \paragraph{vN.N.N+:} \markdate{20YY-MM-DD}
3332
3333 \begin{itemize}
3334 \item
3335 \ldots
3336 \end{itemize}
3337
3338 \fi
3339
3340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3341 \paragraph{v1.0.1:} \markdate{2026-03-23}
3342
3343 \begin{itemize}
3344 \item
3345 fix for not applying |math text| colour for boxes in \ctanpkg{beamer}
3346 \item
3347 traditional alias values |p|, |b|, |B|, |V| for |matrix| option in boxes
3348 \item
3349 suppress modifier warning for combination `|\>$|' ending a box%$
3350 \item
3351 minor setting adjustments
3352 \item
3353 package maintenance
3354 \end{itemize}
3355
3356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3357 \paragraph{v1.0:} \markdate{2026-02-15}
3358
3359 \begin{itemize}
3360 \item
3361 stable release
3362 \end{itemize}
3363
3364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3365 \paragraph{v0.15.2:} \markdate{2026-02-15}
3366
3367 \begin{itemize}
3368 \item
3369 added column punctuation for left column in |cases| boxes
3370 (uses preset |punctcases|)
3371 \item
3372 added column separation |matrixsep| for |matrix| boxes
3373 \item
3374 added glue adjustment |classbreakskip| (muskip) for continued equation |\&;|
3375 \end{itemize}
3376
3377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3378 \paragraph{v0.15.1:} \markdate{2026-02-12}
3379
3380 \begin{itemize}
3381 \item
3382 deactivated numbering for |equations|
3383 and symbolic forms |\[|\,\ldots|\]|, |\<|\,\ldots|\>| by default
3384 (to match with \latex/ and \amsmath/ behaviour;
3385 enable by |\eqnlinesset{number=on}|;
3386 use |\eqnlinesset{sqropt=nonumber}| to keep deactivated for |\[|\,\ldots|\]|)
3387 \item
3388 changed equality relation alignment modifier `\verbbar' to `|?|'
3389 \item
3390 added alignment modifier `\verbbar' for within terms
3391 \end{itemize}
3392
3393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3394 \paragraph{v0.15:} \markdate{2026-02-07}
3395
3396 \begin{itemize}
3397 \item
3398 added column break operator `|\&|'
3399 \item
3400 added equality relation alignment modifiers `|=|', `\verbbar', `|;|' and `|:|'
3401 \item
3402 renamed continued equation modifier to `|/|' (was `|~|')
3403 \item
3404 added options |modifier...| to switch modifiers in various situations
3405 \item
3406 disabled modifiers for |matrix| environments to avoid warnings
3407 \item
3408 disabled modifiers for all environments;
3409 modifiers remain active for symbolic forms
3410 \item
3411 activated numbering for square and angle symbolic forms by default
3412 (revert previous behaviour by |\eqnlinesset{sqropt=nonumber,angopt=nonumber}|)
3413 \item
3414 added and adjusted options and controls for punctuation and equality relations
3415 \end{itemize}
3416
3417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3418 \paragraph{v0.14.1:} \markdate{2026-01-30}
3419
3420 \begin{itemize}
3421 \item
3422 changed math classes for |delim| to open/close
3423 \item
3424 added modifier `|!|' for |equationbox|
3425 (also trailing for |\<|\,\ldots|\>|) and |\\|
3426 to trigger |\eqnapplypunct|
3427 \item
3428 added option |scanbox| to scan box environments
3429 and enable trailing modifiers
3430 \end{itemize}
3431
3432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3433 \paragraph{v0.14:} \markdate{2026-01-28}
3434
3435 \begin{itemize}
3436 \item
3437 added |cases| and |matrix| environments
3438 \item
3439 added punctuation modifiers `|.|' and `|,|'
3440 to |\eqnsep|, |\eqnbreak|, |\\| and |equationsbox|
3441 \item
3442 made |\eqnpunctapply| work within cells and embedded groups
3443 \item
3444 made |\eqnpunct| work for left cells in a column
3445 \item
3446 added modifiers `|<|' and `|>|' for class options |ampeq| and |eqamp|
3447 \item
3448 added option |delim| for delimiter selection
3449 \item
3450 added option |style| for text and display math styles
3451 \item
3452 added option |spread*| to reduce line spread
3453 \end{itemize}
3454
3455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3456 \paragraph{v0.13:} \markdate{2026-01-14}
3457
3458 \begin{itemize}
3459 \item
3460 added trailing modifiers to conveniently adjust punctuation
3461 \item
3462 added |verbose| mode for debugging purposes,
3463 removed |eqnlines-dev| package version
3464 \item
3465 fixed spacing issues with `|\\~|'
3466 \end{itemize}
3467
3468 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3469 \paragraph{v0.12.2:} \markdate{2026-01-13}
3470
3471 \begin{itemize}
3472 \item
3473 registered environments with luamml for label processing
3474 \item
3475 use |\eqnlinesprovide| for starred variants separately
3476 \end{itemize}
3477
3478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3479 \paragraph{v0.12.1:} \markdate{2025-12-28}
3480
3481 \begin{itemize}
3482 \item
3483 fixed unwanted deferring of numbering when using |\\~| in continuous mode
3484 \end{itemize}
3485
3486 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3487 \paragraph{v0.12:} \markdate{2025-12-27}
3488
3489 \begin{itemize}
3490 \item
3491 split off source code documentation into separate document \verbpkg|-src|
3492 \item
3493 added modified newline `|\\~|' to indicate continued equation
3494 with deferred numbering and punctuation suppressed
3495 \item
3496 added |\eqnsep|, |\eqnbreak|, |\eqnjoin| for single-line compositions,
3497 mapped `|\\|' for single equations to |\eqnbreak|
3498 \item
3499 added modifier `|`|' to |equationsbox|
3500 \item
3501 removed faulty option |crerror|
3502 \end{itemize}
3503
3504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3505 \paragraph{v0.11:} \markdate{2025-10-25}
3506
3507 \begin{itemize}
3508 \item
3509 added option |punctall| and modifier `|`|'
3510 to specify several levels of punctuation at once
3511 \end{itemize}
3512
3513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3514 \paragraph{v0.10.1:} \markdate{2025-06-23}
3515
3516 \begin{itemize}
3517 \item
3518 fix for setting default colours (|math text|) in \ctanpkg{beamer}
3519 \end{itemize}
3520
3521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3522 \paragraph{v0.10:} \markdate{2025-05-29}
3523
3524 \begin{itemize}
3525 \item
3526 added |numberline| modes |center|, |median|, |top| and |bottom|
3527 with continuous vertical adjustments
3528 (thanks to Jon\'a\v s Dujava for testing)
3529 \item
3530 fixed spacing following |\paragraph|
3531 (thanks to Jon\'a\v s Dujava for report)
3532 \item
3533 added control |inject| to add free-style content after the present line
3534 \item
3535 added control |markline| and |qed| to display a (QED) mark
3536 \item
3537 added support for \ctanpkg{amsthm} through |\qedhere|
3538 (thanks to Jon\'a\v s Dujava for suggestion)
3539 \item
3540 fixed minor issues
3541 \item
3542 internal structure and minor interface changes
3543 \end{itemize}
3544
3545 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3546 \paragraph{v0.9:} \markdate{2025-05-18}
3547
3548 \begin{itemize}
3549 \item
3550 option |transpose| to transpose rows and columns in columns mode
3551 (thanks to Christophe Bal for suggestion)
3552 \item
3553 added |\eqncontrol| interface for control within lines and cells
3554 \item
3555 internal structure and interface changes
3556 \item
3557 added |\vspace*| for persistent glue at page breaks
3558 \item
3559 added framed tags (|frametag|)
3560 \item
3561 added |\raisetag!| to enforce raising (or lowering) of tags
3562 even if space is sufficient
3563 \item
3564 added modifiers, relaxed order, changed lines mode modifier from `|~|' to `|=|'
3565 \item
3566 fixed minor issues
3567 \item
3568 thanks to Jon\'a\v s Dujava for various reports and suggestions
3569 \end{itemize}
3570
3571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3572 \paragraph{v0.8:} \markdate{2025-04-30}
3573
3574 \begin{itemize}
3575 \item
3576 added framed cells (|\framecell|)
3577 \item
3578 added automatic best line selection for tag placement
3579 (|best| and |evadetag|)
3580 \item
3581 symbolic environment |\<|\,\ldots|\>| forwards to |equationsbox| in math mode
3582 \item
3583 added wrapping for |equationsbox| (|frame|, |wrap|)
3584 \item
3585 horizontal adjustment reworked and completed; |\shoveby| added
3586 \item
3587 extended |\label| to assign names to labels for |\namedref|
3588 \item
3589 interface for alternative representations (|alt| and |\eqnalt|)
3590 \item
3591 options to adjust line width and margins
3592 (|linewidth|, |marginleft|, |marginright|)
3593 \item
3594 added option |scanpar| to allow |\par| appearing in equation body
3595 \item
3596 added continuous penalties (|prepenalty|, |postpenalty|, |interpenalty|)
3597 \item
3598 added overloading for |displaymath| and remaining \amsmath/ math environments
3599 \item
3600 minor interface changes (rename, recombine, values)
3601 \item
3602 documentation expanded
3603 \item
3604 several issues fixed
3605 \end{itemize}
3606
3607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3608 \paragraph{v0.7.1:} \markdate{2025-04-09}
3609
3610 \begin{itemize}
3611 \item
3612 improvements for PDF tagging
3613 \item
3614 backup all available math environments at the start using |backup| switch
3615 \end{itemize}
3616
3617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3618 \paragraph{v0.7:} \markdate{2025-04-03}
3619
3620 \begin{itemize}
3621 \item
3622 manual expanded, examples added
3623 \item
3624 fixes for numbering, tagging, options, |linesfallback|, zero lines
3625 \item
3626 expansions for vertical spacing modes, tag display, |subeqtemplate|
3627 \item
3628 some consolidations
3629 \item
3630 internal rearrangements
3631 \end{itemize}
3632
3633 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3634 \paragraph{v0.6.1:} \markdate{2025-03-27}
3635
3636 \begin{itemize}
3637 \item
3638 |\eqnpunct| can place punctuation within the current equation cell
3639 \item
3640 |numberline=none| now acts as |numberline=all| and |nonumber|
3641 \item
3642 fixed and extended |tagmargin|
3643 with |tagmarginratio| and |tagmarginthreshold|
3644 \item
3645 padding now applies to single-line equations as well
3646 \end{itemize}
3647
3648 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3649 \paragraph{v0.6:} \markdate{2025-03-11}
3650
3651 \begin{itemize}
3652 \item
3653 preliminary PDF tagging support
3654 (\url{https://latex3.github.io/tagging-project/};
3655 \amsmath/ \emph{must} be loaded \emph{before} \ctanpkg{eqnlines}
3656 to avoid errors
3657 \item
3658 classic \latex//\amsmath/ vs.\ \ctanpkg{eqnlines} presets
3659 \item
3660 changed vertical spacing schemes and added further options
3661 \item
3662 supplied dimensions processed by |\glueexpr|
3663 \item
3664 more independent of \amsmath/ structures
3665 \item
3666 internal reorganisations
3667 \end{itemize}
3668
3669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3670 \paragraph{v0.5:} \markdate{2025-02-25}
3671
3672 \begin{itemize}
3673 \item
3674 preview version published on CTAN
3675 \item
3676 thanks to Till Bargheer for testing and reports
3677 \end{itemize}
3678
3679 %</main|manual>
3680 %<*main>
3681 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3684
3685 \appendix
3686 %</main>
3687 %<*main|source>
3688 \raggedright
3689 \settowidth\MacroIndent{\rmfamily\scriptsize 0000\ }
3690
3691 \DocInput{\thepkg/.dtx}
3692 %</main|source>
3693
3694 \end{document}
3695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3696 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3698 %</main|manual|source>
3699 % \fi
3700 %
3701 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3702 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3703 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3704 %
3705 % \iffalse
3706 %<*package>
3707 % \fi
3708 %
3709 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3710 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3711 % \section{Implementation}
3712 %
3713 % This appendix documents the implementation
3714 % for the various components of the \markpkg{eqnlines} package.
3715 %
3716 % The code for the package is based on the \amsmath/ package,
3717 % see the reference manual for details.
3718 % It was forked at version v2.17t dated \markdate{2024-11-05}.
3719 % Most of the code was substantially redesigned
3720 % (macros renamed, reshuffled, enhanced),
3721 % but many of the underlying mechanisms were preserved.
3722 % The documentation thus contains excerpts
3723 % from the \amsmath/ package documentation
3724 % explaining some details of the implementation.
3725 %
3726 % Please note that the documentation is completed
3727 % only for few sections in the present version.
3728 % Various open issues are remarked.
3729 %
3730 %
3731 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3732 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3733 % \section{General Support}
3734 %
3735 % In the following we describe general purpose supporting routines.
3736 %
3737 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3738 % \subsection{Debugging Messages}
3739 %
3740 % The package offers a verbose mode for debugging purposes.
3741 % It outputs extra information on the current location
3742 % within the code in order to track progress:
3743 % \TODO describe
3744 % \begin{macrocode}
3745 \def\eql@verbose@on{%
3746 \def\eql@verbose@info##1{\PackageInfo{eqnlines}{##1}}%
3747 \def\eql@verbose@infoarg##1##2{\eql@verbose@info{##1##2}}%
3748 }
3749 \def\eql@verbose@off{%
3750 \let\eql@verbose@info\@gobble
3751 \let\eql@verbose@infoarg\@gobbletwo
3752 }
3753 \eql@verbose@off
3754 % \end{macrocode}
3755 %
3756 % \TODO describe
3757 % \begin{macrocode}
3758 \def\eql@verbose@msg@enterenv{entering \@currenvir}
3759 \def\eql@verbose@msg@leaveenv{ leaving \@currenvir}
3760 \def\eql@verbose@msg@start#1{starting \string#1}
3761 \def\eql@verbose@msg@end#1{ \space ending \string#1}
3762 \def\eql@verbose@msg@within#1{ \space within \string#1}
3763 \def\eql@verbose@msg@enter#1{entering \string#1}
3764 \def\eql@verbose@msg@leave#1{ leaving \string#1}
3765 \def\eql@verbose@msg@startline@number{starting line \the\eql@row@}
3766 \def\eql@verbose@msg@startline@new{starting new line}
3767 % \end{macrocode}
3768 %
3769 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3770 % \subsection{Supporting Definitions}
3771 %
3772 % \ebool{\eql@false}
3773 % \ebool{\eql@true}
3774 % Rather than the standard \latex/ scheme of
3775 % |\|\textit{xxx}|false|, |\|\textit{xxx}|true| and |\if|\textit{xxx}
3776 % for boolean variables \textit{xxx},
3777 % we use a scheme where |\|\textit{xxx}
3778 % is either undefined or defined (to an empty macro)
3779 % and is tested against by the $\varepsilon$-\tex/
3780 % conditional |\ifdefined\|\textit{xxx}.
3781 % In order to make the scheme more tangible,
3782 % we define the two expected values for boolean variables:
3783 % \begin{macrocode}
3784 \let\eql@false\@undefined
3785 \let\eql@true\@empty
3786 % \end{macrocode}
3787 %
3788 % \TODO for comparison within |\ifx|
3789 % \begin{macrocode}
3790 \def\eql@relax{\relax}
3791 % \end{macrocode}
3792 %
3793 % \TODO describe
3794 % \begin{macrocode}
3795 \def\eql@append#1#2{\edef#1{\unexpanded\expandafter{#1#2}}}
3796 \def\eql@appendexpand#1#2{\edef#1{\unexpanded\expandafter{#1}#2}}
3797 \def\eql@appendmacro#1#2{\eql@appendexpand#1{\unexpanded\expandafter{#2}}}
3798 \def\eql@letcs#1{\expandafter\let\csname#1\endcsname}
3799 % \end{macrocode}
3800 %
3801 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3802 % \subsection{Dollardollar Abstraction}
3803 %
3804 % \macro{\eql@dollardollar@begin}
3805 % \macro{\eql@dollardollar@end}
3806 % As of 2025 \latex/ defines |\dollardollar@begin| and |\dollardollar@end|
3807 % to represent (and adjust) the beginning and end of
3808 % bare \tex/ display equations (`|$$|').
3809 % For the time being, we make sure to revert to `|$$|' if these
3810 % macros are not yet available:
3811 % \begin{macrocode}
3812 \ifdefined\dollardollar@begin
3813 \def\eql@dollardollar@begin{\dollardollar@begin}
3814 \def\eql@dollardollar@end{\dollardollar@end}
3815 \else
3816 \def\eql@dollardollar@begin{$$}
3817 \def\eql@dollardollar@end{$$}
3818 \fi
3819 % \end{macrocode}
3820 %
3821 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3822 % \subsection{Look-Ahead in Alignment}
3823 %
3824 % Scanning for optional arguments |[|\,\ldots|]| or modifiers such as `|*|'
3825 % using the \latex/ |\@ifnextchar| mechanism
3826 % has two challenges within aligned equations:
3827 % a square bracket or star may well be part of
3828 % the intended mathematical expression
3829 % and the look-ahead could trip upon an alignment character `|&|'
3830 % which inadvertently triggers to enter the next alignment column.
3831 %
3832 % \macro{\eql@ifnextchar@loose}
3833 % \macro{\eql@ifnextchar@tight}
3834 % To address the first challenge, we can force the special characters to
3835 % follow immediately the macro invocation.
3836 % For clarity, we copy \latex/'s original |\@ifnextchar|
3837 % in |\kernel@ifnextchar| which skips over spaces as |\eql@ifnextchar@loose|.
3838 % We replicate the \ctanpkg{amsgen} version |\new@ifnextchar|
3839 % that does not skip over spaces as |\eql@ifnextchar@loose|.
3840 % The space before |#1| allows to look-ahead for spaces as well:
3841 % \begin{macrocode}
3842 \let\eql@ifnextchar@loose\kernel@ifnextchar
3843 \long\def\eql@ifnextchar@tight#1#2#3{%
3844 \let\reserved@d= #1%
3845 \def\reserved@a{#2}%
3846 \def\reserved@b{#3}%
3847 \futurelet\@let@token\eql@ifnch@tight
3848 }
3849 \def\eql@ifnch@tight{%
3850 \ifx\@let@token\reserved@d
3851 \let\reserved@b\reserved@a
3852 \fi
3853 \reserved@b
3854 }
3855 % \end{macrocode}
3856 %
3857 % \macro{\eql@atxi}
3858 % \macro{\eql@atxii}
3859 % Capture `|@|' as a character (catcode 12)
3860 % rather than a letter (catcode 11) as |\eql@atxii|
3861 % so that we can look-ahead for `|@|' with both
3862 % |\makeatother| and |\makeatletter| modes:
3863 % \begin{macrocode}
3864 \let\eql@atxi=@
3865 \begingroup
3866 \makeatother
3867 \let\tmp=@%
3868 \makeatletter
3869 \global\let\eql@atxii\tmp
3870 \endgroup
3871 % \end{macrocode}
3872 %
3873 % \macro{\eql@ifnextgobble@...}
3874 % \macro{\eql@ifstar@...}
3875 % \macro{\eql@testopt@...}
3876 % \macro{\eql@teststaropt@...}
3877 % We introduce a collection of look-ahead macros
3878 % which do or do not skip over spaces.
3879 % The macros |\eql@ifstar@...| and |\eql@testopt@...|
3880 % replicate the \latex/ counterparts |\@ifstar| and |\@testopt|.
3881 % The macros |\eql@ifnextgobble@...| work like |\@ifnextchar|,
3882 % but also gobble the specific character if found;
3883 % one might define |\eql@ifstar@...| as |\eql@ifnextgobble@...*|.
3884 % The macros |\eql@teststaropt@...| tests for combinations
3885 % of `|*|' and optional arguments |[|\ldots|]|:
3886 % \begin{macrocode}
3887 \long\def\eql@ifnextgobble@loose#1#2{\eql@ifnextchar@loose#1{\@firstoftwo{#2}}}
3888 \long\def\eql@ifnextgobble@tight#1#2{\eql@ifnextchar@tight#1{\@firstoftwo{#2}}}
3889 \long\def\eql@ifstar@loose#1{\eql@ifnextchar@loose*{\@firstoftwo{#1}}}
3890 \long\def\eql@ifstar@tight#1{\eql@ifnextchar@tight*{\@firstoftwo{#1}}}
3891 \long\def\eql@ifat@loose#1#2{\eql@ifnextgobble@loose{@}{#1}{%
3892 \eql@ifnextgobble@loose\eql@atxii{#1}{#2}}}
3893 \long\def\eql@ifat@tight#1#2{\eql@ifnextgobble@tight{@}{#1}{%
3894 \eql@ifnextgobble@tight\eql@atxii{#1}{#2}}}
3895 \long\def\eql@testopt@loose#1#2{\eql@ifnextchar@loose[{#1}{#1[{#2}]}}%]
3896 \long\def\eql@testopt@tight#1#2{\eql@ifnextchar@tight[{#1}{#1[{#2}]}}%]
3897 \long\def\eql@teststaropt@loose#1#2#3{%
3898 \eql@ifstar@loose{\eql@testopt@loose{#1}{#3}}{\eql@testopt@loose{#2}{#3}}}
3899 \long\def\eql@teststaropt@tight#1#2#3{%
3900 \eql@ifstar@tight{\eql@testopt@tight{#1}{#3}}{\eql@testopt@tight{#2}{#3}}}
3901 \long\def\eql@teststaroropt@loose#1#2#3{%
3902 \eql@ifstar@loose{#1}{\eql@testopt@loose{#2}{#3}}}
3903 \long\def\eql@teststaroropt@tight#1#2#3{%
3904 \eql@ifstar@tight{#1}{\eql@testopt@tight{#2}{#3}}}
3905 \long\def\eql@gobbleopt[#1]{}
3906 \long\def\eql@gobbleoptone[#1]#2{}
3907 % \end{macrocode}
3908 %
3909 % \TODO describe
3910 % \begin{macrocode}
3911 \def\eql@testopt@default{\eql@testopt@default}
3912 % \end{macrocode}
3913 %
3914 % \TODO describe
3915 % \begin{macrocode}
3916 \let\eql@parseopt@warn@env\@empty
3917 \let\eql@parseopt@warn@cr\@empty
3918 % \end{macrocode}
3919 %
3920 % \TODO describe
3921 % \begin{macrocode}
3922 \def\eql@parseopt@env{%
3923 \let\eql@parseopt@warn\eql@parseopt@warn@env\eql@parseopt}
3924 \def\eql@parseopt@cr{%
3925 \let\eql@parseopt@warn\eql@parseopt@warn@cr\eql@parseopt}
3926 % \end{macrocode}
3927 %
3928 % \TODO describe
3929 % \begin{macrocode}
3930 \def\eql@parseopt#1#2{%
3931 \def\eql@parseopt@case{#1}%
3932 \def\eql@parseopt@end{#2}%
3933 \eql@parseopt@peek
3934 }
3935 \def\eql@parseopt@peek{%
3936 \futurelet\eql@parseopt@token\eql@parseopt@select
3937 }
3938 \def\eql@parseopt@select{%
3939 \let\eql@parseopt@next\eql@parseopt@other
3940 \ifx\eql@parseopt@token\@sptoken
3941 \let\eql@parseopt@next\eql@parseopt@end
3942 \fi
3943 \eql@parseopt@case
3944 \eql@parseopt@next
3945 }
3946 \def\eql@parseopt@other{\eql@parseopt@warn\eql@parseopt@end}
3947 \def\eql@parseopt@gobble#1{\eql@parseopt@peek}
3948 % \end{macrocode}
3949 %
3950 % \macro{\eql@spbgroup}
3951 % \macro{\eql@spegroup}
3952 % \macro{\eql@srbgroup}
3953 % \macro{\eql@sregroup}
3954 % The second challenge is addressed by enclosing the look-ahead
3955 % in spurious groups
3956 % \unskip\footnote{See
3957 % \url{https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/3040},\\
3958 % \url{https://www.latex-project.org/cgi-bin/ltxbugs2html?pr=amslatex/1834}
3959 % and\\
3960 % \url{https://tex.stackexchange.com/
3961 % questions/9897/showcase-of-brace-tricks-egroup-iffalse-fi-etc}.
3962 % }
3963 % which protect against triggering `|&|'.
3964 % The macros |\eql@spbgroup| and |\eql@spegroup| open and close a
3965 % spurious group.
3966 % For some reason, the look-ahead mechanism requires further protections
3967 % by inserting |\relax| at the beginning
3968 % and by resetting |\@let@token| at the end.
3969 % These adjustments are included
3970 % in the macros |\eql@srbgroup| and |\eql@spegroup|:
3971 % \begin{macrocode}
3972 \def\eql@spbgroup{\iffalse{\fi\ifnum0=`}\fi}
3973 \def\eql@spegroup{\ifnum0=`{\fi\iffalse}\fi}
3974 \def\eql@srbgroup{\relax\iffalse{\fi\ifnum0=`}\fi}
3975 \def\eql@sregroup{\let\@let@token\relax\ifnum0=`{\fi\iffalse}\fi}
3976 % \end{macrocode}
3977 %
3978 % \macro{\eql@ampprotect}
3979 % \macro{\eql@ampprotecttwo}
3980 % The macros |\eql@ampprotect| and |\eql@ampprotecttwo|
3981 % inject the opening and closing of spurious groups
3982 % into the look-ahead mechanism:
3983 % \begin{macrocode}
3984 \long\def\eql@ampprotect#1#2{\eql@srbgroup#1{\eql@sregroup#2}}
3985 \long\def\eql@ampprotecttwo#1#2#3{%
3986 \eql@srbgroup#1{\eql@sregroup#2}{\eql@sregroup#3}}
3987 % \end{macrocode}
3988 %
3989 % \macro{...@ampsafe}
3990 % We introduce a collection of `|&|'-safe look-ahead macros:
3991 % \begin{macrocode}
3992 \def\eql@ifnextchar@loose@ampsafe#1{%
3993 \eql@ampprotecttwo{\eql@ifnextchar@loose#1}}
3994 \def\eql@ifnextchar@tight@ampsafe#1{%
3995 \eql@ampprotecttwo{\eql@ifnextchar@tight#1}}
3996 \def\eql@ifstar@loose@ampsafe{\eql@ampprotecttwo\eql@ifstar@loose}
3997 \def\eql@ifstar@tight@ampsafe{\eql@ampprotecttwo\eql@ifstar@tight}
3998 \def\eql@testopt@loose@ampsafe{\eql@ampprotect\eql@testopt@loose}
3999 \def\eql@testopt@tight@ampsafe{\eql@ampprotect\eql@testopt@tight}
4000 \def\eql@teststaropt@loose@ampsafe{\eql@ampprotecttwo\eql@teststaropt@loose}
4001 \long\def\eql@teststaropt@tight@ampsafe{%
4002 \eql@ampprotecttwo\eql@teststaropt@tight}
4003 % \end{macrocode}
4004 %
4005 % \macro{\eql@amproof}
4006 % \macro{\eql@amprevert}
4007 % We may want to replace \latex/'s definitions |\@ifnextchar|,
4008 % |\@ifstar| and |\@testopt| to respect `|&|' characters
4009 % within aligned equations.
4010 % This might make unrelated definitions with optional arguments
4011 % and starred variants more robust in this context.
4012 % The macro |\eql@amproof| overwrites the original definitions,
4013 % and |\eql@amprevert| reverts the changes:
4014 % \begin{macrocode}
4015 \let\eql@ifnextchar@org\@ifnextchar
4016 \let\eql@ifstar@org\@ifstar
4017 \let\eql@testopt@org\@testopt
4018 \def\eql@amprevert{%
4019 \let\@ifnextchar\eql@ifnextchar@org
4020 \let\@testopt\eql@testopt@org
4021 \let\@ifstar\eql@ifstar@org
4022 }
4023 \def\eql@ampproof{%
4024 \let\@ifnextchar\eql@ifnextchar@loose@ampsafe
4025 \let\@testopt\eql@testopt@loose@ampsafe
4026 \let\@ifstar\eql@ifstar@loose@ampsafe
4027 }
4028 % \end{macrocode}
4029 %
4030 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4031 % \subsection{Error Messages}
4032 %
4033 % \macro{\eql@error}
4034 % \macro{\eql@warning}
4035 % Main error and warning message function for the package:
4036 % \begin{macrocode}
4037 \def\eql@error#1{\PackageError{eqnlines}{#1}{}}
4038 \def\eql@warning{\PackageWarning{eqnlines}}
4039 % \end{macrocode}
4040 %
4041 % \macro{\eql@error@mathmode}
4042 % Error messages concerning math mode:
4043 % \begin{macrocode}
4044 \def\eql@warn@here#1{\eql@warning{\string#1 not allowed outside equations}}
4045 \def\eql@error@mathmode#1{\eql@error{#1 allowed only in paragraph mode}}
4046 % \end{macrocode}
4047 %
4048 % \macro{\eql@warn@label@unused}
4049 % \macro{\eql@warn@label@multiple}
4050 % \macro{\eql@warn@tag@unused}
4051 % \macro{\eql@warn@tag@multiple}
4052 % \macro{\eql@warn@name@unused}
4053 % \macro{\eql@warn@name@multiple}
4054 % \macro{\eql@warn@ref@unused}
4055 % \macro{\eql@warn@ref@multiple}
4056 % Warning messages concerning unused and multiply declared labels and tags:
4057 % \begin{macrocode}
4058 \def\eql@warn@tags@unused#1#2{\eql@warning{Unused equation #1:
4059 #2 will be lost}}
4060 \def\eql@warn@tags@multiple#1#2#3{\eql@warning{Multiple equation #1:
4061 previous #2 will be lost#3}}
4062 \def\eql@warn@label@unused{\eql@warn@tags@unused{\string\label}%
4063 {label '\eql@tags@label'}}
4064 \def\eql@warn@label@multiple#1{\eql@warn@tags@multiple{\string\label's}%
4065 {label '\eql@tags@label'}{ and replaced by '#1'}}
4066 \def\eql@warn@name@unused{\eql@warn@tags@unused{label name}%
4067 {name declaration}}
4068 \def\eql@warn@name@multiple{\eql@warn@tags@multiple{label names}%
4069 {name declaration}{}}
4070 \def\eql@warn@tag@unused{\eql@warn@tags@unused{\string\tag}%
4071 {tag declaration}}
4072 \def\eql@warn@tag@multiple{\eql@warn@tags@multiple{\string\tag's}%
4073 {tag declaration will be lost}{}}
4074 \def\eql@warn@ref@unused{\eql@warn@tags@unused{tag label}%
4075 {tag label declaration}}
4076 \def\eql@warn@ref@multiple{\eql@warn@tags@multiple{tag labels}%
4077 {tag label declaration}{}}
4078 % \end{macrocode}
4079 %
4080 % \begin{macrocode}
4081 \def\eql@warn@parseopt{\eql@warning{Unknown modifier token:
4082 modifier parsing stopped}}
4083 \def\eql@warn@parseopt@verbose{\eql@warning{Unknown modifier token:
4084 '\meaning\eql@parseopt@token'}}
4085 % \end{macrocode}
4086 %
4087 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4088 % \subsection{amsmath Integration}
4089 %
4090 % \macro{\eql@amsmath@after}
4091 % \macro{\eql@amsmath@before}
4092 % \macro{\eql@amsmath@undefine}
4093 % \macro{\eql@amsmath@let}
4094 % We need to overwrite certain macros from \amsmath/.
4095 % The method |\eql@amsmath@after| executes argument |#1|
4096 % after loading \amsmath/ is loaded.
4097 % It also runs the code if \amsmath/ has already been loaded.
4098 % Furthermore, loading \amsmath/ requires
4099 % certain macros to be undefined. To this end
4100 % |\eql@amsmath@before| will execute argument |#1|
4101 % before any future loading of \amsmath/.
4102 % |\eql@amsmath@undefine| undefines a macro
4103 % in this way and |\eql@amsmath@let| overwrites
4104 % a macro of |\amsmath/|:
4105 % \begin{macrocode}
4106 \def\eql@amsmath@after#1{\AddToHook{package/amsmath/after}{#1}}
4107 \def\eql@amsmath@before#1{%
4108 \@ifpackageloaded{amsmath}{}{\AddToHook{package/amsmath/before}{#1}}}
4109 \def\eql@amsmath@undefine#1{\eql@amsmath@before{\let#1\@undefined}}
4110 \def\eql@amsmath@let#1#2{\eql@amsmath@undefine#1\let#1#2}
4111 % \end{macrocode}
4112 %
4113 % \TODO temporary fix for development stages
4114 % \begin{macrocode}
4115 \@ifpackageloaded{amsmath}{}{%
4116 \DeclareHookRule{package/amsmath/after}%
4117 {eqnlines}{after}{latex-lab-testphase-math}}
4118 % \end{macrocode}
4119 %
4120 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4121 % \subsection{PDF Tagging Support}
4122 %
4123 % \macro{\eql@tagging@...}
4124 % Proper PDF tagging
4125 % \unskip\footnote{see \url{https://latex3.github.io/tagging-project/}}
4126 % support requires a \latex/ version at least of 2025.
4127 % For the time being, we define an abstraction layer so that
4128 % the package will collaborate with \latex/ versions around 2020:
4129 % \TODO adjust to further developments
4130 % \begin{macrocode}
4131 \let\eql@tagging@on\eql@false
4132 \IfFormatAtLeastTF{2025-06-01}{%
4133 \csname tag_if_active:T\endcsname{\let\eql@tagging@on\eql@true}}{}
4134 \ifdefined\eql@tagging@on
4135 \def\eql@tagging@mathsave{%
4136 \UseTaggingSocket{math/luamml/save/nNn}{{}\displaystyle{mtd}}}
4137 \def\eql@tagging@mathaddlast{%
4138 \UseTaggingSocket{math/luamml/mtable/finalizecol}{last}}
4139 \def\eql@tagging@tagbegin{%
4140 \UseTaggingSocket{math/display/tag/begin}}
4141 \def\eql@tagging@tagend{%
4142 \UseTaggingSocket{math/display/tag/end}}
4143 \def\eql@tagging@tagsave{%
4144 \UseTaggingSocket{math/luamml/mtable/tag/save}}
4145 \def\eql@tagging@tagaddbox{%
4146 \setbox\z@\copy\eql@tagbox@%
4147 \UseTaggingSocket{math/luamml/mtable/tag/set}}
4148 \def\eql@tagging@tablesaveinner{%
4149 \UseExpandableTaggingSocket{math/luamml/mtable/innertable/save}}
4150 \def\eql@tagging@tableaddinner{%
4151 \UseTaggingSocket{math/luamml/mtable/innertable/finalize}}
4152 \def\eql@tagging@tablesavelines{%
4153 \UseExpandableTaggingSocket{math/luamml/mtable/finalize}{gather}}
4154 \def\eql@tagging@tablesavealign{%
4155 \UseExpandableTaggingSocket{math/luamml/mtable/finalize}{align}}
4156 \def\eql@tagging@alignleft{%
4157 \UseTaggingSocket{math/luamml/mtable/aligncol}{left}}
4158 \def\eql@tagging@aligncenter{%
4159 \UseTaggingSocket{math/luamml/mtable/aligncol}{center}}
4160 \def\eql@tagging@alignright{%
4161 \UseTaggingSocket{math/luamml/mtable/aligncol}{right}}
4162 % \end{macrocode}
4163 % We need to get hold of the equation body in all cases
4164 % so that we can feed it into the tagging mechanism:
4165 % \begin{macrocode}
4166 \let\eql@single@doscan\eql@true
4167 \let\eql@scan@body\eql@scan@body@rescan
4168 % \end{macrocode}
4169 % \macro{\eql@tagging@start}
4170 % \macro{\eql@tagging@end}
4171 % We need to activate tagging for display equations
4172 % for environments and for enclosures |\[|\,\ldots|\]| and |\<|\,\ldots|\>|.
4173 % The tagging interface registration macro |\RegisterMathEnvironment|
4174 % will work only partially for our cases, hence we
4175 % replicate code from |\math_register_halign_env:nn|.
4176 % Make sure collection is not yet active (|\l__math_collected_bool|).
4177 % Then feed collected environment name,
4178 % options and body into |\__math_process:nn|.
4179 % Indicate the start of a display equation:
4180 % \begin{macrocode}
4181 \def\eql@tagging@start{%
4182 \csname bool_if:NF\expandafter\endcsname
4183 \csname l__math_collected_bool\endcsname{%
4184 \edef\eql@tmp{{\@currenvir}{[\unexpanded\expandafter{\eql@tagging@opt}]%
4185 \the\eql@scan@reg@}}%
4186 \csname __math_process:nn\expandafter\endcsname\eql@tmp
4187 \@kernel@math@registered@begin
4188 \csname bool_set_true:N\expandafter\endcsname
4189 \csname l__math_collected_bool\endcsname
4190 }%
4191 }
4192 \def\eql@tagging@end{}
4193 \def\eql@tagging@register@luamml#1{%
4194 \AddToHook{package/luamml/after}{%
4195 \eql@letcs{c__luamml_label_#1_tl}\@empty}}
4196 \def\eql@tagging@register@env{\csname math_register_env:n\endcsname}
4197 % \end{macrocode}
4198 % When tagging is deactivated, provide empty definitions:
4199 % \begin{macrocode}
4200 \else
4201 \let\eql@tagging@mathsave\@empty
4202 \let\eql@tagging@mathaddlast\@empty
4203 \let\eql@tagging@tagbegin\@empty
4204 \let\eql@tagging@tagend\@empty
4205 \let\eql@tagging@tagsave\@empty
4206 \let\eql@tagging@tagaddbox\@empty
4207 \let\eql@tagging@tablesaveinner\@empty
4208 \let\eql@tagging@tableaddinner\@empty
4209 \let\eql@tagging@tablesavelines\@empty
4210 \let\eql@tagging@tablesavealign\@empty
4211 \let\eql@tagging@alignleft\@empty
4212 \let\eql@tagging@aligncenter\@empty
4213 \let\eql@tagging@alignright\@empty
4214 \let\eql@tagging@start\@empty
4215 \let\eql@tagging@end\@empty
4216 \let\eql@tagging@register@luamml\@gobble
4217 \let\eql@tagging@register@env\@gobble
4218 \fi
4219 % \end{macrocode}
4220 %
4221 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4222 % \subsection{Key-Value Processing}
4223 %
4224 % The package uses the \ctanpkg{keyval} mechanism to parse
4225 % key-value pairs to specify adjustments to the behaviour
4226 % of the equations environments:
4227 % \begin{macrocode}
4228 \RequirePackage{keyval}
4229 % \end{macrocode}
4230 %
4231 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4232 % \paragraph{Value Selection.}
4233 %
4234 % \macro{\eql@decide@select}
4235 % Some parameter values take values in a given set,
4236 % e.g.\ |true| vs.\ |false| or |left| vs.\ |right|.
4237 % The macro |\eql@decide@select| is a general purpose selector.
4238 % Arguments |#1| and |#2| describe the category and key
4239 % which are used only towards error messages.
4240 % Argument |#3| contains the value and argument |#4|
4241 % is a list of values and corresponding actions in the format
4242 % \[
4243 % |{{{|\textit{val1a}|,|\textit{val1b}|,|\ldots|}{|\textit{act1}|},|
4244 % |{{|\textit{val2a}|,|\textit{val2b}|,|\ldots|}{|\textit{act2}|},|
4245 % \ldots|}|.
4246 % \]
4247 % The (single) value |\relax| matches everything
4248 % (can be used for handling generic values after specific ones).
4249 % If no corresponding value is found in the list,
4250 % an error message is invoked.
4251 % Single expansion is applied to the list of values:
4252 % \begin{macrocode}
4253 \def\eql@decide@relax{\eql@tmpb:=\relax}
4254 \def\eql@decide@select#1#2#3#4{%
4255 \def\eql@tmpa{#3}%
4256 \let\eql@tmpd\@undefined
4257 \@for\eql@tmpc:=#4\do{%
4258 \ifdefined\eql@tmpd\else
4259 \edef\eql@tmpb{\noexpand\eql@tmpb:=\expandafter\@firstoftwo\eql@tmpc}%
4260 \ifx\eql@tmpb\eql@decide@relax
4261 \let\eql@tmpa\eql@relax
4262 \fi
4263 \expandafter\@for\eql@tmpb\do{%
4264 \ifx\eql@tmpa\eql@tmpb
4265 \edef\eql@tmpd{\unexpanded\expandafter\expandafter\expandafter{%
4266 \expandafter\@secondoftwo\eql@tmpc}}%
4267 \fi
4268 }%
4269 \fi
4270 }%
4271 \ifdefined\eql@tmpd
4272 \eql@tmpd
4273 \else
4274 \eql@error{undefined value '#3' for option '#2' of '#1'}%
4275 \fi
4276 }
4277 % \end{macrocode}
4278 %
4279 % Decide between |true| and |false| or related pairs of values:
4280 % \begin{macrocode}
4281 \def\eql@decide@true{on,true,yes,enabled}
4282 \def\eql@decide@false{off,false,no,disabled}
4283 % \end{macrocode}
4284 %
4285 % \macro{\eql@decide@if}
4286 % \begin{macrocode}
4287 \def\eql@decide@if#1#2#3#4#5{%
4288 \eql@decide@select{#1}{#2}{#3}{%
4289 {\eql@decide@true{#4}},%
4290 {\eql@decide@false{#5}}}}
4291 % \end{macrocode}
4292 %
4293 % \macro{\eql@decide@bool}
4294 % Store a boolean value into a conditional register:
4295 % \begin{macrocode}
4296 \def\eql@decide@bool#1#2#3#4{%
4297 \eql@decide@if{#1}{#2}{#3}{\let#4\eql@true}{\let#4\eql@false}}
4298 % \end{macrocode}
4299 %
4300 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4301 % \paragraph{Key Declaration.}
4302 %
4303 % \macro{\eql@define@key}
4304 % For convenience, we define a wrapper for \ctanpkg{keyval}'s |\define@key|
4305 % which accepts lists of categories and keys.
4306 % We prepend the prefix |eql@| to all our categories so that we can hide it
4307 % from the user in error messages:
4308 % \begin{macrocode}
4309 \def\eql@define@key#1#2{%
4310 \eql@ifnextchar@loose[%]
4311 {\eql@definekey@opt{#1}{#2}}%
4312 {\eql@definekey@noopt{#1}{#2}}%
4313 }
4314 \def\eql@definekey@noopt#1#2#3{\eql@definekey@for{#1}{#2}{{#3}}}
4315 \def\eql@definekey@opt#1#2[#3]#4{\eql@definekey@for{#1}{#2}{[#3]{#4}}}
4316 \def\eql@definekey@for#1#2#3{%
4317 \def\eql@for@fn##1##2##3{\define@key{eql@##3}{##2}#3}%
4318 \edef\eql@for@vara{\noexpand\eql@for@vara:=#1}%
4319 \expandafter\@for\eql@for@vara\do{%
4320 \edef\eql@for@varb{\noexpand\eql@for@varb:=#2}%
4321 \expandafter\@for\eql@for@varb\do{%
4322 \edef\eql@for@call##1{%
4323 \noexpand\eql@for@fn{##1}{\eql@for@varb}{\eql@for@vara}}%
4324 \eql@for@call{##1}%
4325 }%
4326 }%
4327 }
4328 % \end{macrocode}
4329 %
4330 % \macro{\eql@setkeys}
4331 % Our wrapper of \ctanpkg{keyval}'s |\setkeys|
4332 % prepends the prefix |eql@| to the category,
4333 % and it expands the list argument once:
4334 % \begin{macrocode}
4335 \def\eql@setkeys#1#2{%
4336 \def\eql@tmp{\setkeys{eql@#1}}%
4337 \expandafter\eql@tmp\expandafter{#2}%
4338 }
4339 % \end{macrocode}
4340 %
4341 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4342 % \paragraph{Options and Control Interface.}
4343 %
4344 % \macro{\eql@nextopt}
4345 % \macro{\eql@nextopt@process}
4346 % It can be convenient to add arguments to the following
4347 % equations environment, e.g.\ towards defining
4348 % modifier macros:
4349 % \begin{macrocode}
4350 \let\eql@nextopt\@empty
4351 \def\eql@nextopt@process#1{%
4352 \eql@setkeys{#1}\eql@nextopt
4353 \let\eql@tagging@opt\eql@nextopt
4354 \global\let\eql@nextopt\@empty
4355 }
4356 % \end{macrocode}
4357 %
4358 % \imacro{\eqnaddopt}
4359 % \begin{macrocode}
4360 \newcommand{\eqnaddopt}[1]{%
4361 \ifx\eql@nextopt\@empty
4362 \eql@append\eql@nextopt{#1}%
4363 \else
4364 \eql@append\eql@nextopt{,#1}%
4365 \fi
4366 }
4367 % \end{macrocode}
4368 %
4369 % \macro{\eqnlinesset}
4370 % Process global configuration options
4371 % including the package options:
4372 % \begin{macrocode}
4373 \newcommand{\eqnlinesset}[1]{%
4374 \eql@setkeys{setup}{#1}%
4375 \ignorespaces
4376 }
4377 % \end{macrocode}
4378 %
4379 % \macro{\eql@control@default}
4380 % \begin{macrocode}
4381 \protected\def\eql@control@default{%
4382 \eql@warn@here\eqncontrol
4383 \@gobble
4384 }
4385 \let\eqncontrol\eql@control@default
4386 % \end{macrocode}
4387 %
4388 % \imacro{\eqncontrol}
4389 % Macro for general-purpose control within equations using key-value pairs:
4390 % \begin{macrocode}
4391 \newcommand{\eql@control}[1]{%
4392 \relax
4393 \eql@setkeys{control}{#1}%
4394 \ignorespaces
4395 }
4396 % \end{macrocode}
4397 %
4398 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4399 % \subsection{Scanning the Equation Body}
4400 %
4401 % The multi-line equatiuon environment must scan its body twice:
4402 % once to determine how wide the columns are and then to actually
4403 % typeset them. This means that we must collect all text in this body
4404 % before calling the environment macros.
4405 % The mechanism and its description follows \amsmath/ closely.
4406 %
4407 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4408 % \paragraph{Token Register.}
4409 %
4410 % \macro{\eql@scan@reg@}
4411 % We start by defining a token register to hold the equation body.
4412 % \begin{macrocode}
4413 \newtoks\eql@scan@reg@
4414 % \end{macrocode}
4415 %
4416 % \macro{\eql@scan@body@dump}
4417 % \macro{\eql@scan@body@rescan}
4418 % \macro{\eql@scan@body}
4419 % The macro |\eql@scan@body@dump| dumps the equation body
4420 % from the register so that we do not have to pass it
4421 % around in arguments. The macro |\eql@scan@body@rescan|
4422 % rescans the tokens so that special commands
4423 % such as |\verb| can be processed properly.
4424 % The register |\eql@scan@body|
4425 % holds the currently selected mode of operation:
4426 % \TODO may skip expandafter before scantokens?
4427 % \begin{macrocode}
4428 \def\eql@scan@body@dump{\the\eql@scan@reg@}
4429 \def\eql@scan@body@rescan{%
4430 \expandafter\scantokens\expandafter{\the\eql@scan@reg@}}
4431 \let\eql@scan@body\eql@scan@body@dump
4432 % \end{macrocode}
4433 %
4434 % \macro{\eql@scan@addto}
4435 % We define a macro to append to the token register |\eql@scan@reg@|:
4436 % \begin{macrocode}
4437 \long\def\eql@scan@addto#1{\eql@scan@reg@\expandafter{\the\eql@scan@reg@#1}}
4438 % \end{macrocode}
4439 %
4440 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4441 % \paragraph{Environment Body.}
4442 %
4443 % The following mechanism scans the contents of an environment
4444 % taking into account nested environments
4445 % that may be contained in the body.
4446 %
4447 % \macro{\eql@scan@env}
4448 % The macro |\eql@scan@env| starts the scan for the |\end{...}|
4449 % command of the current environment. The argument is a call-back macro
4450 % to process the body in |\eql@scan@reg@|:
4451 % \begin{macrocode}
4452 \def\eql@scan@env{%
4453 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@scan@env
4454 \def\eql@scan@end{\expandafter\end\expandafter{\@currenvir}}%
4455 \eql@scan@reg@{}\def\eql@scan@stack{b}%
4456 % \end{macrocode}
4457 % We call |\eql@scan@env@iterate| which will scan until
4458 % the next occurrence of |\end| and then count the number
4459 % of occurrences of |\begin| before |\end| in |\eql@scan@stack|.
4460 % If we simply called |\eql@scan@env@iterate| directly,
4461 % the error message for an unwanted |\par| token (usually from a blank line)
4462 % would refer to |\eql@scan@env@iterate| which would not be illuminating.
4463 % We use a little finesse to get a more intelligible error message:
4464 % We use the actual environment name as the name of the temporary function
4465 % that is |\let| to |\eql@scan@env@iterate|:
4466 % \begin{macrocode}
4467 \edef\eql@scan@iterate{\expandafter\noexpand\csname\@currenvir\endcsname}%
4468 \expandafter\let\expandafter\eql@scan@env@org\eql@scan@iterate
4469 \ifdefined\eql@scan@par
4470 \expandafter\let\eql@scan@iterate\eql@scan@env@iterate
4471 \else
4472 \expandafter\let\eql@scan@iterate\eql@scan@env@iterate@nopar
4473 \fi
4474 \eql@scan@iterate
4475 }
4476 % \end{macrocode}
4477 %
4478 % \macro{\eql@scan@env@iterate}
4479 % |\eql@scan@env@iterate| takes two arguments: the first will consist of
4480 % all text up to the next |\end| command, the second will be the
4481 % |\end| command's argument. If there are any extra |\begin|
4482 % commands in the body text, a marker is pushed onto a stack
4483 % via |\eql@scan@env@count|.
4484 % An empty state for this stack means that we
4485 % have reached the |\end| that matches our original |\begin|.
4486 % Otherwise we need to include the |\end| and its argument in the
4487 % material that we are adding to our environment body accumulator:
4488 % \begin{macrocode}
4489 \long\def\eql@scan@env@iterate#1\end#2{%
4490 \edef\eql@scan@stack{%
4491 \eql@scan@env@count#1\begin\end\expandafter\@gobble\eql@scan@stack}%
4492 \ifx\@empty\eql@scan@stack
4493 \@checkend{#2}%
4494 \eql@scan@addto{#1}%
4495 \expandafter\let\eql@scan@iterate\eql@scan@env@org
4496 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@scan@env
4497 \expandafter\eql@scan@call
4498 \else
4499 \eql@scan@addto{#1\end{#2}}%
4500 \expandafter\eql@scan@iterate
4501 \fi
4502 }
4503 % \end{macrocode}
4504 %
4505 % \macro{\eql@scan@env@iterate@nopar}
4506 % Version of |\eql@scan@env@iterate| which does not accept |\par|
4507 % within the argument:
4508 % \begin{macrocode}
4509 \def\eql@scan@env@iterate@nopar#1\end#2{\eql@scan@env@iterate#1\end{#2}}
4510 % \end{macrocode}
4511 %
4512 % \macro{\eql@scan@env@count}
4513 % When adding a piece of the current environment's contents to
4514 % |\eql@scan@reg@|, we scan it to check for additional |\begin|
4515 % tokens, and add a `|b|' to the stack for any that we find.
4516 % \begin{macrocode}
4517 \long\def\eql@scan@env@count#1\begin#2{%
4518 \ifx\end#2\else b\expandafter\eql@scan@env@count\fi
4519 }
4520 % \end{macrocode}
4521 %
4522 % The call-back macro |\eql@scan@env@cancel| ignores the body
4523 % as well as the end clause for the environment:
4524 % \begin{macrocode}
4525 \def\eql@scan@env@cancel{%
4526 \@namedef{end\@currenvir}{\ignorespacesafterend}%
4527 \eql@scan@end
4528 }
4529 % \end{macrocode}
4530 %
4531 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4532 % \paragraph{Square Brackets.}
4533 %
4534 % The following is a version of the above mechanism
4535 % that scans for an equation body enclosed by |\[|\,\ldots|\]|
4536 % paying attention to potential further instances of the square bracket
4537 % enclosures contained in the body.
4538 %
4539 % \macro{\eql@scan@sqr}
4540 % Start scanning for |\]|:
4541 % \begin{macrocode}
4542 \def\eql@scan@sqr{%
4543 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@scan@sqr
4544 \def\eql@scan@end{\]}%
4545 \eql@scan@reg@{}\def\eql@scan@stack{b}%
4546 \let\eql@scan@sqr@org\[%\]
4547 \ifdefined\eql@scan@par
4548 \let\[\eql@scan@sqr@iterate%\]
4549 \else
4550 \let\[\eql@scan@sqr@iterate@nopar%\]
4551 \fi
4552 \[%\]
4553 }
4554 % \end{macrocode}
4555 %
4556 % \macro{\eql@scan@sqr@iterate}
4557 % Iterate until we find a balanced pairing of square brackets.
4558 % Then call the call-back macro:
4559 % \begin{macrocode}
4560 \long\def\eql@scan@sqr@iterate#1\]{%
4561 \edef\eql@scan@stack{%
4562 \eql@scan@sqr@count#1\[\]\expandafter\@gobble\eql@scan@stack}%
4563 \ifx\@empty\eql@scan@stack
4564 \let\[\eql@scan@sqr@org%\]
4565 \eql@scan@addto{#1}%
4566 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@scan@sqr
4567 \expandafter\eql@scan@call
4568 \else
4569 \eql@scan@addto{#1\]}%
4570 \expandafter\[%\]
4571 \fi
4572 }
4573 % \end{macrocode}
4574 %
4575 % \macro{\eql@scan@sqr@iterate@nopar}
4576 % Version of |\eql@scan@sqr@iterate| which does not accept |\par|
4577 % within the argument:
4578 % \begin{macrocode}
4579 \def\eql@scan@sqr@iterate@nopar#1\]{\eql@scan@sqr@iterate#1\]}
4580 % \end{macrocode}
4581 %
4582 % \macro{\eql@scan@sqr@count}
4583 % Push a `|b|' for every encountered instance of `|\[|':
4584 % \begin{macrocode}
4585 \long\def\eql@scan@sqr@count#1\[#2{%\]
4586 \ifx\]#2\else b\expandafter\eql@scan@sqr@count\fi
4587 }
4588 % \end{macrocode}
4589 %
4590 % \macro{\eql@scan@sqrang@cancel}
4591 % The call-back macro |\eql@scan@sqrang@cancel| ignores the body
4592 % and the closing bracket:
4593 % \begin{macrocode}
4594 \def\eql@scan@sqrang@cancel{\ignorespaces}
4595 % \end{macrocode}
4596 %
4597 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4598 % \paragraph{Angle Brackets.}
4599 %
4600 % The following is another version of the mechanism
4601 % which scans for an equation body enclosed by |\<|\,\ldots|\>|.
4602 %
4603 % \macro{\eql@scan@ang}
4604 % Start scanning for |\>|:
4605 % \begin{macrocode}
4606 \def\eql@scan@ang{%
4607 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@scan@ang
4608 \def\eql@scan@end{\>}%
4609 \eql@scan@reg@{}\def\eql@scan@stack{b}%
4610 \let\eql@scan@ang@org\<%\>
4611 \ifdefined\eql@scan@par
4612 \let\<\eql@scan@ang@iterate%\>
4613 \else
4614 \let\<\eql@scan@ang@iterate@nopar%\>
4615 \fi
4616 \<%\>
4617 }
4618 % \end{macrocode}
4619 %
4620 % \macro{\eql@scan@ang@iterate}
4621 % Iterate until we find a balanced pairing of angle brackets:
4622 % \begin{macrocode}
4623 \long\def\eql@scan@ang@iterate#1\>{%
4624 \edef\eql@scan@stack{%
4625 \eql@scan@ang@count#1\<\>\expandafter\@gobble\eql@scan@stack}%
4626 \ifx\@empty\eql@scan@stack
4627 \let\<\eql@scan@ang@org%\>
4628 \eql@scan@addto{#1}%
4629 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@scan@ang
4630 \expandafter\eql@scan@call
4631 \else
4632 \eql@scan@addto{#1\>}%
4633 \expandafter\<%\>
4634 \fi
4635 }
4636 % \end{macrocode}
4637 %
4638 % \macro{\eql@scan@ang@iterate@nopar}
4639 % Version of |\eql@scan@ang@iterate| which does not accept |\par|
4640 % within the argument:
4641 % \begin{macrocode}
4642 \def\eql@scan@ang@iterate@nopar#1\>{\eql@scan@ang@iterate#1\>}
4643 % \end{macrocode}
4644 %
4645 % \macro{\eql@scan@ang@count}
4646 % Push a `|b|' for every encountered instance of `|\<|':
4647 % \begin{macrocode}
4648 \long\def\eql@scan@ang@count#1\<#2{%\>
4649 \ifx\>#2\else b\expandafter\eql@scan@ang@count\fi
4650 }
4651 % \end{macrocode}
4652 %
4653 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4654 % \paragraph{Interface.}
4655 %
4656 % \TODO describe
4657 % \macro{\eql@sqr@open}
4658 % If already in math mode, ignore the enclosed contents.
4659 % \begin{macrocode}
4660 \protected\def\eql@sqr@open{%
4661 \ifmmode
4662 \expandafter\eql@sqr@cancel
4663 \else
4664 \expandafter\eql@equations@sqr@open
4665 \fi
4666 }
4667 % \end{macrocode}
4668 %
4669 % \macro{\eql@sqr@close}
4670 % Definition for `|\]|':
4671 % \TODO NOTE: |\protected| acts as |\relax| and starts a row in |\halign|,
4672 % so we overwrite |\]| when starting.
4673 % \begin{macrocode}
4674 \protected\def\eql@sqr@close{%
4675 \eql@error{'\string\]' may only close '\string\['}%\]
4676 }
4677 % \end{macrocode}
4678 %
4679 % \macro{\eql@sqr@cancel}
4680 % \begin{macrocode}
4681 \def\eql@sqr@cancel{%
4682 \eql@error@mathmode{\string\[...\string\]}%
4683 \let\eql@scan@call\eql@scan@sqrang@cancel
4684 \eql@scan@sqr
4685 }
4686 % \end{macrocode}
4687 %
4688 % \macro{\eql@ang@open}
4689 % Definition for `|\<|'.
4690 % Forward to |equationsbox| if in math mode, otherwise to |equations|:
4691 % \begin{macrocode}
4692 \protected\def\eql@ang@open{%
4693 \ifmmode
4694 \expandafter\eql@box@ang@open
4695 \else
4696 \expandafter\eql@equations@ang@open
4697 \fi
4698 }
4699 % \end{macrocode}
4700 %
4701 % \macro{\eql@ang@close}
4702 % Definition for `|\>|':
4703 % \TODO NOTE: |\protected| acts as |\relax| and starts a row in |\halign|,
4704 % so we overwrite |\>| when starting.
4705 % \begin{macrocode}
4706 \protected\def\eql@ang@close{%
4707 \eql@error{'\string\>' may only close '\string\<'}%\>
4708 }
4709 % \end{macrocode}
4710 %
4711 %
4712 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4713 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4714 % \section{Parameters and Registers}
4715 %
4716 % In the following, we collect parameter and register definitions.
4717 %
4718 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4719 % \subsection{Parameters}
4720 %
4721 % \TODO describe
4722 %
4723 % \TODO maybe sort parameters into sections
4724 % \TODO or sort parameters in sections here
4725 %
4726 % \ebool{\eql@tagsleft}
4727 % The boolean parameter |\eql@tagsleft|
4728 % specifies whether the tags are placed at the left or right margin:
4729 % \begin{macrocode}
4730 \let\eql@tagsleft\eql@false
4731 % \end{macrocode}
4732 %
4733 % \ebool{\eql@layoutleft}
4734 % The boolean parameter |\eql@layoutleft|
4735 % specifies whether to use left or central alignment layout:
4736 % \begin{macrocode}
4737 \let\eql@layoutleft\eql@false
4738 % \end{macrocode}
4739 %
4740 % \macro{\eql@layoutleftmargin}
4741 % \macro{\eql@layoutleftmarginmin}
4742 % \macro{\eql@layoutleftmarginmax}
4743 % The default width of the left margin in left alignment layout
4744 % is specified by |\eql@layoutleftmargin|.
4745 % It may be pushed down to |\eql@layoutleftmarginmin|
4746 % and up to |\eql@layoutleftmarginmax|:
4747 % \begin{macrocode}
4748 \def\eql@layoutleftmargin{\leftmargini}
4749 \def\eql@layoutleftmarginmax{.5\maxdimen}
4750 \def\eql@layoutleftmarginmin{\z@}
4751 % \end{macrocode}
4752 %
4753 % \macro{\eql@mathstyle}
4754 % The math style to be used within cells
4755 % is specified by |\eql@mathstyle|:
4756 % \begin{macrocode}
4757 \let\eql@mathstyle\displaystyle
4758 % \end{macrocode}
4759 %
4760 % \ldimen{\eql@tagmargin@}
4761 % \ldimen{\eql@tagmargin@ratio@}
4762 % \macro{\eql@tagmargin@val}
4763 % \macro{\eql@tagmargin@threshold}
4764 % The intended margin width for tags in centeral alignment layout
4765 % is stored in |\eql@tagmargin@| which is sourced by |\eql@tagmargin@val|.
4766 % An undefined |\eql@tagmargin@val| will compute the margin width
4767 % as the maximum width of tags (without separation).
4768 % |\eql@tagmargin@ratio@| describes the maximum ratio
4769 % of lines with tags to total number of lines
4770 % for which |\eql@tagmargin@| is set to zero:
4771 % \TODO threshold
4772 % \begin{macrocode}
4773 \newdimen\eql@tagmargin@
4774 \let\eql@tagmargin@val\@undefined
4775 \newdimen\eql@tagmargin@ratio@
4776 \eql@tagmargin@ratio@\p@
4777 \def\eql@tagmargin@threshold{0.5}
4778 % \end{macrocode}
4779 %
4780 % \ldimen{\eql@indent@}
4781 % The currently selected indentation width is speficied by |\eql@indent@|.
4782 % This dimension register is set to the macro |\eql@indent@val|
4783 % when entering the equation environments:
4784 % \begin{macrocode}
4785 \newdimen\eql@indent@
4786 \def\eql@indent@val{2em}
4787 % \end{macrocode}
4788 %
4789 % \ldimen{\eql@paddingleft@}
4790 % \ldimen{\eql@paddingright@}
4791 % The padding of an equation (column) is specified by
4792 % |\eql@paddingleft@| and |\eql@paddingright@|.
4793 % These dimension registers are set to the macros
4794 % |\eql@paddingleft@val| and |\eql@paddingright@val|, respectively,
4795 % when entering the equation environments:
4796 % \begin{macrocode}
4797 \newdimen\eql@paddingleft@
4798 \newdimen\eql@paddingright@
4799 \let\eql@paddingleft@val\@undefined
4800 \let\eql@paddingright@val\@undefined
4801 % \end{macrocode}
4802 %
4803 % \macro{\eql@display@linewidth}
4804 % \macro{\eql@display@marginleft}
4805 % \macro{\eql@display@marginright}
4806 % \TODO describe
4807 % \begin{macrocode}
4808 \let\eql@display@linewidth\@undefined
4809 \let\eql@display@marginleft\@undefined
4810 \let\eql@display@marginright\@undefined
4811 % \end{macrocode}
4812 %
4813 % \macro{\eql@box@colsep}
4814 % \macro{\eql@box@shortsep}
4815 % \macro{\eql@box@condsep}
4816 % \macro{\eql@box@matrixsep}
4817 % The macro |\eql@box@colsep| specifies the intercolumn separation
4818 % for equation boxes:
4819 % \TODO describe
4820 % \begin{macrocode}
4821 \def\eql@box@colsep{2em}
4822 \def\eql@box@shortsep{1em}
4823 \def\eql@box@condsep{\eql@box@shortsep}
4824 \def\eql@box@matrixsep{\eql@box@shortsep}
4825 % \end{macrocode}
4826 %
4827 % \macro{\eql@break@line@sep}
4828 % \macro{\eql@break@line@shortsep}
4829 % \macro{\eql@break@col@sep}
4830 % \macro{\eql@break@col@shortsep}
4831 % \TODO describe
4832 % \begin{macrocode}
4833 \def\eql@break@line@sep{2em minus 1em}
4834 \def\eql@break@line@shortsep{1em}
4835 \def\eql@break@col@sep{2em minus 1em}
4836 \def\eql@break@col@shortsep{1em}
4837 % \end{macrocode}
4838 %
4839 % \macro{\eql@spread@val}
4840 % The extra spread of equation lines is specified by |\eql@spread@val|:
4841 % \begin{macrocode}
4842 \let\eql@spread@reset\eql@false
4843 \def\eql@spread@val{\jot}
4844 \newdimen\eql@spread@
4845 % \end{macrocode}
4846 %
4847 % \ldimen{\eql@tagfuzz@}
4848 % The value |\eql@tagfuzz@| specifies the margin of error for
4849 % comparing whether a tag fits a given equation line.
4850 % We should not expect rounding errors in the fixed point arithmetic of \tex/,
4851 % nevertheless:
4852 % \TODO probably do not need this due to fixed point arithmetic.
4853 % \begin{macrocode}
4854 \newdimen\eql@tagfuzz@
4855 \eql@tagfuzz@16sp\relax
4856 % \end{macrocode}
4857 %
4858 % \macro{\eql@display@height}
4859 % \macro{\eql@display@depth}
4860 % An equation will appear to the surrounding text
4861 % with a fixed apparent height and depth specified
4862 % by |\eql@display@height| and |\eql@display@depth|, respectively:
4863 % \begin{macrocode}
4864 \def\eql@display@height\@undefined
4865 \def\eql@display@depth\@undefined
4866 % \end{macrocode}
4867 %
4868 % \macro{\eql@skip@mode@short}
4869 % The setting |\eql@skip@mode@short| specifies
4870 % when a reduced amount of glue should be used around equations
4871 % in case the text line above the equation fits in the space
4872 % that is left available in the first equation line.
4873 % Value |0| turns this feature off,
4874 % value |1| reduces the glue above the equation,
4875 % value |2| furthermore reduces the glue below a single equation line and
4876 % value |3| also reduces the glue below multi-line equations:
4877 % \begin{macrocode}
4878 \def\eql@skip@mode@short{2}
4879 % \end{macrocode}
4880 %
4881 % \begin{macrocode}
4882 \def\eql@skip@mode@cont@above{2}
4883 \def\eql@skip@mode@cont@below{0}
4884 % \end{macrocode}
4885 %
4886 % \begin{macrocode}
4887 \def\eql@skip@mode@par@above{3}
4888 \def\eql@skip@mode@par@below{0}
4889 % \end{macrocode}
4890 %
4891 % \begin{macrocode}
4892 \def\eql@skip@mode@top@above{4}
4893 \def\eql@skip@mode@top@below{0}
4894 % \end{macrocode}
4895 %
4896 % \begin{macrocode}
4897 \newcount\eql@skip@mode@leave@
4898 \let\eql@skip@force@leave\@undefined
4899 % \end{macrocode}
4900 %
4901 % \macro{\eql@skip@force@above}
4902 % \macro{\eql@skip@force@below}
4903 % \tcounter{\eql@skip@mode@above@}
4904 % \tcounter{\eql@skip@mode@below@}
4905 % 0: short, 1: long, 2: cont, 3: par, 4: top, 5: no, 6: med, 7: custom
4906 % \begin{macrocode}
4907 \newcount\eql@skip@mode@above@
4908 \newcount\eql@skip@mode@below@
4909 \let\eql@skip@force@above\@undefined
4910 \let\eql@skip@force@below\@undefined
4911 \let\eql@skip@custom@above\@undefined
4912 \let\eql@skip@custom@below\@undefined
4913 % \end{macrocode}
4914 %
4915 % \macro{\eql@skip@cont@above}
4916 % The glue when an equation is at the top of a horizontal list
4917 % is specified by |\eql@skip@cont@above|:
4918 % \macro{\eql@skip@top@above}
4919 % \macro{\eql@skip@top@below}
4920 % The glue when an equation is at the top of a vertical list
4921 % is specified by |\eql@skip@top@above|
4922 % and |\eql@skip@top@below|:
4923 % \macro{\eql@skip@par@above}
4924 % The glue when an equation starts a paragraph
4925 % is specified by |\eql@skip@par@above|:
4926 % \macro{\eql@skip@med@above}
4927 % \macro{\eql@skip@med@below}
4928 % The surrounding glue for an equation with reduced spacing
4929 % is given by |\eql@skip@med@above| and |\eql@skip@med@below|:
4930 %
4931 % \begin{macrocode}
4932 \def\eql@skip@long@above{\abovedisplayskip}
4933 \def\eql@skip@long@below{\belowdisplayskip}
4934 \def\eql@skip@short@above{\abovedisplayshortskip}
4935 \def\eql@skip@short@below{\belowdisplayshortskip}
4936 \def\eql@skip@cont@above{\eql@skip@short@above}
4937 \def\eql@skip@cont@below{\eql@skip@short@below}
4938 \def\eql@skip@par@above{\eql@skip@long@above}
4939 \def\eql@skip@par@below{\eql@skip@long@below}
4940 \def\eql@skip@top@above{\eql@skip@long@above}
4941 \def\eql@skip@top@below{\eql@skip@long@below}
4942 \def\eql@skip@med@above{\abovedisplayskip/2}
4943 \def\eql@skip@med@below{\belowdisplayskip/2}
4944 \def\eql@skip@tag@above{\z@skip}
4945 \def\eql@skip@tag@below{\z@skip}
4946 % \end{macrocode}
4947 %
4948 % \ldimen{\eql@colsepmin@}
4949 % \macro{\eql@colsepmin@val}
4950 % \macro{\eql@colsepmax@val}
4951 % The minimum intercolumn separatation is specified by |\eql@colsepmin@|.
4952 % This dimension register is set to |\eql@colsepmin@val|
4953 % when entering the equation environments to allow font-dependent values.
4954 % Furthermore, |\eql@colsepmax@val|
4955 % specifies the maximum intercolumn separation:
4956 % \begin{macrocode}
4957 \newdimen\eql@colsepmin@
4958 \def\eql@colsepmin@val{1em}
4959 \def\eql@colsepmax@val{.5\maxdimen}
4960 % \end{macrocode}
4961 %
4962 % \ldimen{\eql@tagwidthmin@}
4963 % The minimum tag width is specified by |\eql@tagwidthmin@|:
4964 % \begin{macrocode}
4965 \newdimen\eql@tagwidthmin@
4966 \eql@tagwidthmin@\z@
4967 % \end{macrocode}
4968 %
4969 % \ldimen{\eql@tagsepmin@}
4970 % The minimum separation between an equation and its tag
4971 % is given by |\eql@tagsepmin@|.
4972 % \tex/'s built-in value is half a quad
4973 % \unskip\footnote{another half of a quad
4974 % is left empty at the other end of the line.}
4975 % in font number 2.
4976 % As the tag is processed in text mode, we use |0.5em| instead.
4977 % \begin{macrocode}
4978 \newdimen\eql@tagsepmin@
4979 \def\eql@tagsepmin@val{.5\fontdimen6\textfont\tw@}
4980 % \end{macrocode}
4981 %
4982 % \macro{\eql@equations@sqr@opt}
4983 % \macro{\eql@equations@ang@opt}
4984 % \macro{\eql@box@ang@opt}
4985 % Store the default arguments for |\[|\,\ldots|\]| and |\<|\,\ldots|\>|,
4986 % respectively:
4987 % \begin{macrocode}
4988 \def\eql@equations@sqr@opt{equation}
4989 \def\eql@equations@ang@opt{columns}
4990 \def\eql@box@ang@opt{columns}
4991 % \end{macrocode}
4992 %
4993 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4994 % \paragraph{Multi-Line Align Mode.}
4995 %
4996 % \begin{macrocode}
4997 \let\eql@columns@fulllength\eql@false
4998 % \end{macrocode}
4999 %
5000 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5001 % \subsection{Registers}
5002 %
5003 % \TODO describe
5004 %
5005 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5006 % \paragraph{General.}
5007 %
5008 % \TODO describe
5009 % \begin{macrocode}
5010 \newcount\eql@count@
5011 \newdimen\eql@dimen@
5012 \newskip\eql@skip@
5013 % \end{macrocode}
5014 %
5015 % \TODO describe
5016 % \begin{macrocode}
5017 \let\eql@display@container\@empty
5018 % \end{macrocode}
5019 %
5020 % \lbox{\eql@cellbox@}
5021 % \lbox{\eql@tagbox@}
5022 % \ldimen{\eql@cellwidth@}
5023 % \ldimen{\eql@prevwidth@}
5024 % \ldimen{\eql@tagwidth@}
5025 % \ldimen{\eql@prevdepth@}
5026 % \tcounter{\eql@prevgraf@}
5027 % The box |\eql@cellbox@| holds the present alignment component
5028 % and |\eql@tagbox@| the tag for the present line.
5029 % The corresponding dimensions |\eql@cellwidth@| and |\eql@tagwidth@|
5030 % hold their widths.
5031 % |\eql@prevwidth@| holds the width of the previous alignment component:
5032 % \TODO adjust
5033 % \begin{macrocode}
5034 \newbox\eql@cellbox@
5035 \newbox\eql@tagbox@
5036 \newdimen\eql@cellwidth@
5037 \newdimen\eql@prevwidth@
5038 \newdimen\eql@tagwidth@
5039 \newdimen\eql@prevdepth@
5040 \newcount\eql@prevgraf@
5041 % \end{macrocode}
5042 %
5043 % \ldimen{\eql@totalwidth@}
5044 % \ldimen{\eql@tagwidth@max@}
5045 % \ldimen{\eql@totalheight@}
5046 % \begin{macrocode}
5047 \newdimen\eql@totalwidth@
5048 \newdimen\eql@tagwidth@max@
5049 \newdimen\eql@totalheight@
5050 \newdimen\eql@topheight@
5051 \newdimen\eql@bottomdepth@
5052 % \end{macrocode}
5053 %
5054 % \ldimen{\eql@line@height@}
5055 % \ldimen{\eql@line@depth@}
5056 % The dimension registers |\eql@line@height@| and |\eql@line@depth@| keep
5057 % track of the height and depth of the present line in an alignment:
5058 % \begin{macrocode}
5059 \newdimen\eql@line@height@
5060 \newdimen\eql@line@depth@
5061 % \end{macrocode}
5062 %
5063 % \ldimen{\eql@line@width@}
5064 % \ldimen{\eql@line@avail@}
5065 % \ldimen{\eql@line@pos@}
5066 % \tcounter{\eql@line@widthsep@}
5067 % \tcounter{\eql@line@availsep@}
5068 % \tcounter{\eql@line@possep@}
5069 % \ldimen{\eql@line@offset@}
5070 % \ldimen{\eql@line@prevdepth@}
5071 % \ldimen{\eql@line@interline@}
5072 % \begin{macrocode}
5073 \newdimen\eql@line@width@
5074 \newdimen\eql@line@avail@
5075 \newdimen\eql@line@pos@
5076 \newcount\eql@line@availsep@
5077 \newcount\eql@line@widthsep@
5078 \newcount\eql@line@possep@
5079 \newdimen\eql@line@offset@
5080 \newdimen\eql@line@prevdepth@
5081 \newdimen\eql@line@interline@
5082 % \end{macrocode}
5083 %
5084 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5085 % \paragraph{Rows and Columns.}
5086 %
5087 % \tcounter{\eql@row@}
5088 % \tcounter{\eql@totalrows@}
5089 % \tcounter{\eql@tagrows@}
5090 % \TODO tagrows
5091 % |\eql@row@| counts the present row (1-based)
5092 % and |\eql@totalrows@| holds the total number of rows:
5093 % \begin{macrocode}
5094 \newcount\eql@row@
5095 \newcount\eql@totalrows@
5096 \newcount\eql@tagrows@
5097 % \end{macrocode}
5098 %
5099 % \macro{\eql@column@}
5100 % \macro{\eql@totalcolumns@}
5101 % \begin{macrocode}
5102 \newcount\eql@column@
5103 \newcount\eql@totalcolumns@
5104 % \end{macrocode}
5105 %
5106 % \ldimen{\eql@colsep@}
5107 % The dimension of the intercolumn separation for align environments
5108 % is stored in |\eql@colsep@|:
5109 % \begin{macrocode}
5110 \newdimen\eql@colsep@
5111 % \end{macrocode}
5112 %
5113 % \tcounter{\eql@intercolumns@}
5114 % \begin{macrocode}
5115 \newcount\eql@intercolumns@
5116 % \end{macrocode}
5117 %
5118 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5119 % \paragraph{Vertical Spacing Adjustments.}
5120 %
5121 % \ldimen{\eql@display@firstavail@}
5122 % \macro{\eql@display@firstavail@set}
5123 % The unused space on the first line of an alignment is stored in
5124 % |\eql@display@firstavail@| for comparison against
5125 % |\predisplaysize| and determining short skip mode of display equations.
5126 % It it convenient to set it via |\eql@display@firstavail@set|
5127 % provided that we are on the first line:
5128 % \begin{macrocode}
5129 \newdimen\eql@display@firstavail@
5130 \def\eql@display@firstavail@set#1{%
5131 \ifnum\eql@row@=\@ne
5132 \global\eql@appendexpand\eql@display@container{%
5133 \eql@display@firstavail@\the#1\relax}%
5134 \fi
5135 }
5136 % \end{macrocode}
5137 %
5138 % The counter stores whether the tag one first/last line is
5139 % raised/lowered as |1|/|2| (or |3| for both).
5140 % This implies a different vskip corresponding to the
5141 % mostly empty line:
5142 % \TODO adjust
5143 % \begin{macrocode}
5144 \newdimen\eql@display@aboveextend@
5145 \newdimen\eql@display@belowextend@
5146 % \end{macrocode}
5147 %
5148 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5149 % \paragraph{Shared Registers.}
5150 %
5151 % \lcond{\ifmeasuring@}
5152 % All display environments get typeset twice -- once during a
5153 % ``measuring'' phase and then again during a ``production'' phase.
5154 % We reuse the original \amsmath/ definition |\ifmeasuring@|
5155 % to determine which case we're in,
5156 % so we and other packages may take appropriate action.
5157 % It does not hurt to define this conditional in any case.
5158 % We should tell \ctanpkg{hyperref} about measuring processes
5159 % as we're not \amsmath/ and not being catered for:
5160 % \begin{macrocode}
5161 \ifdefined\measuring@true\else
5162 \expandafter\newif\csname ifmeasuring@\endcsname
5163 \fi
5164 \AddToHook{package/hyperref/after}{%
5165 \ifdefined\Hy@ifnotmeasuring
5166 \renewcommand\Hy@ifnotmeasuring[1]{\ifmeasuring@\else#1\fi}%
5167 \fi
5168 }
5169 % \end{macrocode}
5170 %
5171 % \lcond{\if@display}
5172 % \amsmath/ defines the conditional |\||if@display|
5173 % to test whether we're in a display equation
5174 % including the inner math parts of equation blocks.
5175 % We provide it in case \amsmath/ is absent,
5176 % and initialise it:
5177 % \begin{macrocode}
5178 \ifdefined\@displaytrue\else
5179 \expandafter\newif\csname if@display\endcsname
5180 \everydisplay\expandafter{\the\everydisplay\@displaytrue}
5181 \fi
5182 % \end{macrocode}
5183 %
5184 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5185 % \subsection{Hooks}
5186 %
5187 % \macro{\eql@hook@...}
5188 % For what it's worth, we define a couple of entry points
5189 % where one might hook into the equations typesetting framework.
5190 % The \latex/ hook framewould would be more versatile,
5191 % but as the purpose of these hooks is rather unclear at the moment,
5192 % we make this as efficient as it could get:
5193 % \TODO may add a few more hooks
5194 % \begin{macrocode}
5195 \let\eql@hook@blockbefore\@empty
5196 \let\eql@hook@blockafter\@empty
5197 \let\eql@hook@blockin\@empty
5198 \let\eql@hook@blockout\@empty
5199 \let\eql@hook@linein\@empty
5200 \let\eql@hook@lineout\@empty
5201 \let\eql@hook@colin\@empty
5202 \let\eql@hook@colout\@empty
5203 \let\eql@hook@eqin\@empty
5204 \let\eql@hook@eqout\@empty
5205 \let\eql@hook@innerleft\@empty
5206 \let\eql@hook@innerright\@empty
5207 \let\eql@hook@innerlead\@empty
5208 % \end{macrocode}
5209 %
5210 %
5211 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5212 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5213 % \section{Features}
5214 %
5215 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5216 % \subsection{Punctuation}
5217 %
5218 % The equations environments supply an automatic punctuation scheme
5219 % which allows to define a default punctuation
5220 % at the end of each column, line and equation block.
5221 %
5222 % \macro{\eql@punct@col}
5223 % \macro{\eql@punct@line}
5224 % \macro{\eql@punct@block}
5225 % \macro{\eql@punct@next}
5226 % \macro{\eql@punct@top}
5227 % \macro{\eql@punct@cases}
5228 % These macros store the punctuation character for columns, lines and blocks.
5229 % An undefined value indicates that the punctuation should be handed
5230 % down to the next lower level:
5231 % \TODO update
5232 % \begin{macrocode}
5233 \let\eql@punct@col\@empty
5234 \let\eql@punct@line\@undefined
5235 \let\eql@punct@block\@undefined
5236 \let\eql@punct@next\@undefined
5237 \let\eql@punct@top\@undefined
5238 \let\eql@punct@cases\@empty
5239 % \end{macrocode}
5240 %
5241 % \macro{\eql@punct@sep}
5242 % This macro stores the separation to be applied
5243 % before the punctuation (unless it is empty):
5244 % \begin{macrocode}
5245 \let\eql@punct@class\@empty
5246 \let\eql@punct@sep\@empty
5247 % \end{macrocode}
5248 %
5249 % \macro{\eql@punct@top@set}
5250 % \macro{\eql@punct@top@stop}
5251 % \macro{\eql@punct@top@reset}
5252 % \TODO describe
5253 % \begin{macrocode}
5254 \def\eql@punct@top@set{\let\eql@punct@top\eql@punct@block}
5255 \def\eql@punct@top@stop{\let\eql@punct@top\relax}
5256 \def\eql@punct@top@reset{\let\eql@punct@top\@undefined}
5257 % \end{macrocode}
5258 %
5259 % \macro{\eql@punct@set}
5260 % \TODO describe
5261 % \begin{macrocode}
5262 \def\eql@punct@tilde{~}
5263 \def\eql@punct@set#1#2{%
5264 \def#1{#2}%
5265 \ifx#1\eql@relax
5266 \let#1\@undefined
5267 \fi
5268 \ifx#1\eql@punct@tilde
5269 \let#1\@empty
5270 \fi
5271 }
5272 \def\eql@punct@clear{%
5273 \let\eql@punct@col\@empty
5274 \let\eql@punct@line\@empty
5275 \let\eql@punct@block\@empty
5276 }
5277 \def\eql@punct@next@clear{\let\eql@punct@next\@empty}
5278 % \end{macrocode}
5279 %
5280 % Set the punction for blocks.
5281 % Note that the macro |\eqnpunct| sets the punctuation for the
5282 % following equation block or for the current cell.
5283 % Starred versions clear the punctuation for the respectively levels:
5284 %
5285 % \TODO describe
5286 % \begin{macrocode}
5287 \def\eql@punct@addopt{%
5288 \eql@ifstar@tight\eql@punct@addopt@relax\eql@punct@addopt@set}
5289 \def\eql@punct@addopt@set#1{\eqnaddopt{punct={#1}}\ignorespaces}
5290 \def\eql@punct@addopt@relax{\eqnaddopt{punct*}\ignorespaces}
5291 % \end{macrocode}
5292 %
5293 % \TODO describe
5294 % \begin{macrocode}
5295 \def\eql@punct@setnext{%
5296 \eql@ifstar@tight\eql@punct@setnext@relax\eql@punct@setnext@set}
5297 \def\eql@punct@setnext@set#1{%
5298 \eql@punct@set\eql@punct@next{#1}%
5299 \ifdefined\eql@punct@next\else\let\eql@punct@next\relax\fi
5300 \ignorespaces}
5301 \def\eql@punct@setnext@relax{\let\eql@punct@next\relax\ignorespaces}
5302 % \end{macrocode}
5303 %
5304 % \imacro{\eqnpunct}
5305 % \TODO describe
5306 % \begin{macrocode}
5307 \let\eqnpunct\eql@punct@addopt
5308 % \end{macrocode}
5309 %
5310 % \macro{\eql@punct@fill@next}
5311 % Fill the next punctuation:
5312 % \begin{macrocode}
5313 \def\eql@punct@fill@next#1{%
5314 \ifdefined\eql@punct@next
5315 \ifx\eql@punct@next\relax
5316 \let\eql@punct@next\@undefined
5317 \fi
5318 \else
5319 \ifx\eql@punct@top\relax\else
5320 \let\eql@punct@next#1%
5321 \fi
5322 \fi
5323 }
5324 % \end{macrocode}
5325 %
5326 % \macro{\eql@punct@output@next}
5327 % Output the next punctuation.
5328 % If non-empty, prepend some separation:
5329 % \begin{macrocode}
5330 \def\eql@punct@output@next{%
5331 \ifx\eql@punct@next\@empty\else
5332 \ifmmode\eql@punct@class\fi
5333 \eql@punct@sep
5334 \eql@punct@next
5335 \fi
5336 \let\eql@punct@next\@undefined
5337 }
5338 % \end{macrocode}
5339 %
5340 % \macro{\eql@punct@print@next}
5341 % Print the next punctuation if available:
5342 % \begin{macrocode}
5343 \def\eql@punct@print@next{%
5344 \ifdefined\eql@punct@next
5345 \eql@punct@output@next
5346 \fi
5347 }
5348 % \end{macrocode}
5349 %
5350 % \macro{\eql@punct@apply@next}
5351 % Print the next punctuation if available.
5352 % Stop further punctuation within the current group:
5353 % \begin{macrocode}
5354 \def\eql@punct@apply@next{%
5355 \ifdefined\eql@punct@next
5356 \eql@punct@output@next
5357 \eql@punct@top@stop
5358 \fi
5359 }
5360 % \end{macrocode}
5361 %
5362 % \macro{\eql@punct@print@col}
5363 % Print the punctuation for the present column:
5364 % \begin{macrocode}
5365 \def\eql@punct@print@col{%
5366 \eql@punct@fill@next\eql@punct@col
5367 \eql@punct@print@next
5368 }
5369 % \end{macrocode}
5370 %
5371 % \macro{\eql@punct@apply@col}
5372 % Output the punctuation for the present column.
5373 % Stop further punctuation within the current group:
5374 % \begin{macrocode}
5375 \def\eql@punct@apply@col{%
5376 \eql@punct@fill@next\eql@punct@col
5377 \eql@punct@apply@next
5378 }
5379 % \end{macrocode}
5380 %
5381 % Output the punctuation for the present line unless disabled:
5382 % \macro{\eql@punct@print@line}
5383 % \begin{macrocode}
5384 \def\eql@punct@print@line{%
5385 \eql@punct@fill@next\eql@punct@line
5386 \eql@punct@print@next
5387 }
5388 % \end{macrocode}
5389 %
5390 % Output the punctuation for the present line unless disabled.
5391 % Stop further punctuation within the current group:
5392 % \macro{\eql@punct@apply@line}
5393 % \begin{macrocode}
5394 \def\eql@punct@apply@line{%
5395 \eql@punct@fill@next\eql@punct@line
5396 \eql@punct@apply@next
5397 }
5398 % \end{macrocode}
5399 %
5400 % \macro{\eql@punct@apply@block}
5401 % Output the punctuation for the present block unless disabled.
5402 % Stop further punctuation within the current group:
5403 % \begin{macrocode}
5404 \def\eql@punct@apply@block{%
5405 \eql@punct@fill@next\eql@punct@block
5406 \eql@punct@apply@next
5407 }
5408 % \end{macrocode}
5409 %
5410 % \macro{\eql@punct@apply@top}
5411 % Output the top punctuation unless disabled.
5412 % Stop further punctuation globally:
5413 % \begin{macrocode}
5414 \def\eql@punct@apply@top{%
5415 \eql@punct@fill@next\eql@punct@top
5416 \eql@punct@print@next
5417 \global\eql@punct@top@stop
5418 }
5419 % \end{macrocode}
5420 %
5421 % \imacro{\eqnpunctapply}
5422 % Output the top punctuation unless disabled.
5423 % Stop further punctuation globally:
5424 % \begin{macrocode}
5425 \newcommand{\eqnpunctapply}{\ifmmode\else\unskip\fi\eql@punct@apply@top}
5426 % \end{macrocode}
5427 %
5428 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5429 % \subsection{Math Classes at Alignment}
5430 %
5431 % The following describes the adjustment of math classes
5432 % surrounding the alignment marker.
5433 %
5434 % \macro{\eql@class@innerright@sel@}
5435 % Select between |\eql@class@innerlead| and |\eql@class@innerright|
5436 % depending on whether the left part of the aligned column is empty:
5437 % \begin{macrocode}
5438 \def\eql@class@innerright@sel@{%
5439 \ifdim\eql@prevwidth@=\z@
5440 \eql@class@innerlead
5441 \else
5442 \eql@class@innerright
5443 \fi
5444 }
5445 % \end{macrocode}
5446 %
5447 % \macro{\eql@class@innerleft@set}
5448 % \macro{\eql@class@innerright@set}
5449 % \macro{\eql@class@innerlead@set}
5450 % Set the left, right and leading math classes.
5451 % Setting the right math class disables the leading math class,
5452 % so the leading math class must be specified after the right one:
5453 % \begin{macrocode}
5454 \def\eql@class@innerleft@set#1{%
5455 \def\eql@class@innerleft{#1}%
5456 }
5457 \def\eql@class@innerright@set#1{%
5458 \def\eql@class@innerright{#1}%
5459 \let\eql@class@innerright@sel\eql@class@innerright
5460 }
5461 \def\eql@class@innerlead@set#1{%
5462 \def\eql@class@innerlead{#1}%
5463 \let\eql@class@innerright@sel\eql@class@innerright@sel@
5464 }
5465 % \end{macrocode}
5466 %
5467 % \begin{macrocode}
5468 \def\eql@class@rel@symb{=}
5469 \def\eql@class@rel@break#1{\eql@class@rel@start{#1}\mathclose{}}
5470 \def\eql@class@rel@start#1{\mathrel{\phantom{#1}}}
5471 \def\eql@class@rel@break@set#1{\def\eql@class@rel@break##1{#1}}
5472 \def\eql@class@rel@start@set#1{\def\eql@class@rel@start##1{#1}}
5473 \def\eql@class@rel@break@skip{\thickmuskip-\medmuskip}
5474 \def\eql@class@rel@amp{&}
5475 \def\eql@class@rel@amprelax{&\relax}
5476 \def\eql@class@rel@relaxamp{\relax&}
5477 \def\eql@class@rel@ordamp{{}&}
5478 \def\eql@class@rel@make#1{%
5479 \ifdefined\eql@class@rel@after
5480 \def\eql@tmp{&#1}%
5481 \ifx\eql@tmp\eql@class@rel@amp
5482 \def\eql@tmp{&\eql@class@rel@break\eql@class@rel@symb
5483 \mskip\muexpr\eql@class@rel@break@skip\relax}%
5484 \else\ifx\eql@tmp\eql@class@rel@amprelax
5485 \def\eql@tmp{&\eql@class@rel@start\eql@class@rel@symb}%
5486 \fi\fi
5487 \else
5488 \def\eql@tmp{#1&}%
5489 \ifx\eql@tmp\eql@class@rel@amp
5490 \def\eql@tmp{&\mathclose{}%
5491 \mskip\muexpr\eql@class@rel@break@skip\relax}%
5492 \fi
5493 \ifx\eql@tmp\eql@class@rel@relaxamp
5494 \def\eql@tmp{&\mathclose{}\mathopen{}\mathrel{}}%
5495 \fi
5496 \ifx\eql@tmp\eql@class@rel@ordamp
5497 \def\eql@tmp{&\mathclose{}}%
5498 \fi
5499 \fi
5500 \eql@tmp
5501 }
5502 % \end{macrocode}
5503 %
5504 % \macro{\eql@class@ampeq}
5505 % \macro{\eql@class@eqamp}
5506 % We define two standard combinations of math classes
5507 % intended to be used with `|&=|' (|ampeq|) or `|=&|' (|eqamp|).
5508 % The default setting is `|&=|' (|ampeq|):
5509 % \begin{macrocode}
5510 \def\eql@class@ampeq{%
5511 \eql@class@innerleft@set{}%
5512 \eql@class@innerright@set{{}}%
5513 \let\eql@class@rel@after\eql@true
5514 }
5515 \def\eql@class@eqamp{%
5516 \eql@class@innerleft@set{}%
5517 \eql@class@innerright@set{\mathrel{}}%
5518 \eql@class@innerlead@set{\mathclose{}}%
5519 \let\eql@class@rel@after\eql@false
5520 }
5521 \eql@class@ampeq
5522 % \end{macrocode}
5523 %
5524 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5525 % \subsection{Framed Cells}
5526 %
5527 % \TODO describe
5528 % \TODO warn if issued in even cells
5529 % \begin{macrocode}
5530 \let\eql@frame@cmd\@undefined
5531 \newdimen\eql@frame@margin@
5532 \def\eql@frame@set[#1]{%
5533 \global\eql@append\eql@cell@container{\def\eql@frame@cmd{#1}}}
5534 \protected\def\framecell{\eql@testopt@tight@ampsafe\eql@frame@set\fbox}
5535 \def\eql@frame@measure{%
5536 \setbox\z@\hbox{\eql@frame@cmd{}}%
5537 \eql@frame@[email protected]\wd\z@
5538 }
5539 \def\eql@frame@print{%
5540 \setbox\eql@cellbox@\hbox{%
5541 \eql@frame@cmd{\unhbox\eql@cellbox@}%
5542 }%
5543 }
5544 \def\eql@frame@adjust{%
5545 \setbox\eql@cellbox@\hbox{%
5546 \eql@frame@cmd{%
5547 \unhbox\eql@cellbox@
5548 \unkern
5549 \unskip
5550 }%
5551 \hfil
5552 \kern\z@
5553 }%
5554 }
5555 % \end{macrocode}
5556 %
5557 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5558 % \subsection{Single-Line Composition}
5559 %
5560 % \TODO describe
5561 %
5562 % \macro{\eql@break@line}
5563 % \macro{\eql@break@col}
5564 % \begin{macrocode}
5565 \def\eql@break@line{%
5566 \let\eql@break@sep\eql@break@line@sep
5567 \let\eql@break@shortsep\eql@break@line@shortsep
5568 \let\eql@break@print\eql@punct@print@line
5569 \let\eql@punct@term\eql@false
5570 \let\eql@class@rel@composed\@undefined
5571 \eql@ampprotect\eql@break@test\eql@break@process}
5572 \def\eql@break@col{%
5573 \let\eql@break@sep\eql@break@col@sep
5574 \let\eql@break@shortsep\eql@break@col@shortsep
5575 \let\eql@break@print\eql@punct@print@col
5576 \let\eql@punct@term\eql@false
5577 \let\eql@class@rel@composed\@undefined
5578 \eql@ampprotect\eql@break@test\eql@break@process}
5579 \def\eql@break@cr{%
5580 \let\eql@break@sep\eql@break@line@sep
5581 \let\eql@break@shortsep\eql@break@line@shortsep
5582 \let\eql@break@print\eql@punct@print@line
5583 \let\eql@punct@term\eql@false
5584 \let\eql@class@rel@composed\@undefined
5585 \eql@ampprotect\eql@break@cr@test\eql@break@process}
5586 \def\eql@break@amp{%
5587 \eql@ampprotecttwo\eql@break@amp@testescape
5588 \eql@amp@org\eql@break@process}
5589 \def\eql@break@amp@testescape#1#2{%
5590 \eql@ifnextgobble@tight/{#1}{\eql@break@amp@testnoescape{#2}}}
5591 \def\eql@break@amp@testnoescape#1{%
5592 \relax
5593 \let\eql@break@sep\eql@break@col@sep
5594 \let\eql@break@shortsep\eql@break@col@shortsep
5595 \let\eql@break@print\eql@punct@print@col
5596 \let\eql@punct@term\eql@false
5597 \let\eql@class@rel@composed\@undefined
5598 \eql@break@amp@test{#1}}
5599 % \end{macrocode}
5600 %
5601 % \TODO describe
5602 % \begin{macrocode}
5603 \def\eql@break@test@setopt{\let\eql@break@test\eql@break@testopt}
5604 \def\eql@break@test@setall{\let\eql@break@test\eql@break@testall}
5605 \def\eql@break@cr@test@setopt{\let\eql@break@cr@test\eql@break@testopt}
5606 \def\eql@break@cr@test@setall{\let\eql@break@cr@test\eql@break@testall}
5607 \def\eql@break@amp@test@setopt{\let\eql@break@amp@test\eql@break@testopt}
5608 \def\eql@break@amp@test@setall{\let\eql@break@amp@test\eql@break@testall}
5609 % \end{macrocode}
5610 %
5611 % \macro{\eql@break@testopt}
5612 % \TODO describe
5613 % \begin{macrocode}
5614 \def\eql@break@testopt#1{\eql@ifstar@tight
5615 {\let\eql@break@sep\eql@break@shortsep#1}{\eql@break@testopt@arg{#1}}}
5616 \def\eql@break@testopt@arg#1{\eql@ifnextchar@tight[%
5617 {\eql@break@testopt@set{#1}}{#1}}
5618 \def\eql@break@testopt@set#1[#2]{\def\eql@break@sep{#2}#1}
5619 % \end{macrocode}
5620 %
5621 % \macro{\eql@break@testall}
5622 % \macro{\eql@break@testall@parse}
5623 % \TODO describe
5624 % \begin{macrocode}
5625 \def\eql@break@testall{\eql@parseopt@cr\eql@break@testall@parse}
5626 \def\eql@break@testall@parse{%
5627 \ifx\eql@parseopt@token[%
5628 \let\eql@parseopt@next\eql@break@parse@val
5629 \fi
5630 \ifx\eql@parseopt@token*%
5631 \let\eql@parseopt@next\eql@break@parse@star
5632 \fi
5633 \ifx\eql@parseopt@token.%
5634 \let\eql@parseopt@next\eql@parseopt@punctpass
5635 \fi
5636 \ifx\eql@parseopt@token,%
5637 \let\eql@parseopt@next\eql@parseopt@punctpass
5638 \fi
5639 \ifx\eql@parseopt@token~%
5640 \let\eql@parseopt@next\eql@parseopt@punctpass
5641 \fi
5642 \ifx\eql@parseopt@token`%
5643 \let\eql@parseopt@next\eql@parseopt@punctnext
5644 \fi
5645 \ifx\eql@parseopt@token!%
5646 \let\eql@parseopt@next\eql@parseopt@punctterm
5647 \fi
5648 \ifx\eql@parseopt@token/%
5649 \let\eql@parseopt@next\eql@parseopt@punctclear
5650 \fi
5651 \ifx\eql@parseopt@token=%
5652 \let\eql@parseopt@next\eql@parseopt@relsymb
5653 \fi
5654 \ifx\eql@parseopt@token;%
5655 \let\eql@parseopt@next\eql@parseopt@relcont
5656 \fi
5657 \ifx\eql@parseopt@token:%
5658 \let\eql@parseopt@next\eql@parseopt@relstart
5659 \fi
5660 \ifx\eql@parseopt@token|%
5661 \let\eql@parseopt@next\eql@parseopt@relord
5662 \fi
5663 \ifx\eql@parseopt@token?%
5664 \let\eql@parseopt@next\eql@break@parse@rel
5665 \fi
5666 }
5667 \def\eql@break@parse@val[#1]{%
5668 \def\eql@break@sep{#1}\eql@parseopt@peek}
5669 \def\eql@break@parse@star#1{%
5670 \let\eql@break@sep\eql@break@shortsep\eql@parseopt@peek}
5671 \def\eql@break@parse@rel#1#2{%
5672 \def\eql@class@rel@composed{#2}\eql@parseopt@end}
5673 % \end{macrocode}
5674 %
5675 % \macro{\eql@break@process}
5676 % \begin{macrocode}
5677 \def\eql@break@process{%
5678 \ifdefined\eql@punct@term\eql@punct@apply@top\fi
5679 \ifdefined\eql@class@rel@composed
5680 \eql@class@rel@composed
5681 \else
5682 \eql@break@print
5683 \hspace{\glueexpr\eql@break@sep\relax}%
5684 \fi
5685 }
5686 % \end{macrocode}
5687 %
5688 % \macro{\eql@break@join}
5689 % \begin{macrocode}
5690 \def\eql@break@join{\eql@srbgroup
5691 \eql@ifstar@tight
5692 {\eql@break@join@opt[\eql@break@col@shortsep]}%
5693 {\eql@testopt@tight\eql@break@join@opt\eql@break@col@sep}}
5694 \def\eql@break@join@opt[#1]#2{\eql@sregroup%
5695 \hspace{\glueexpr#1\relax}#2\hspace{\glueexpr#1\relax}}
5696 % \end{macrocode}
5697 %
5698 % \macro{\eqnsep}
5699 % \macro{\eqnbreak}
5700 % \macro{\eqnjoin}
5701 % \TODO expand to lines and columns mode
5702 % \begin{macrocode}
5703 \newcommand{\eqnsep}{\eql@break@col}
5704 \newcommand{\eqnbreak}{\eql@break@line}
5705 \newcommand{\eqnjoin}{\eql@break@join}
5706 % \end{macrocode}
5707 %
5708 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5709 % \subsection{Alternative Content Description}
5710 %
5711 % \TODO describe
5712 % \TODO would be nice to provide as environments as well
5713 % \TODO implement for PDF tagging
5714 %
5715 % \begin{macrocode}
5716 \DeclareRobustCommand{\eqnalt}[2][]{}
5717 % \end{macrocode}
5718 %
5719 %
5720 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5721 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5722 % \section{Equation Numbering}
5723 %
5724 % \TODO describe
5725 %
5726 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5727 % \subsection{Supporting Definitions}
5728 %
5729 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5730 % \paragraph{Parameters.}
5731 %
5732 % \begin{macrocode}
5733 \let\eql@tags@autolabel\eql@false
5734 \let\eql@tags@autotag\eql@true
5735 \let\eql@tags@warn\eql@true
5736 % \end{macrocode}
5737 %
5738 % \begin{macrocode}
5739 \def\eql@tags@name@generic{[equation]}
5740 % \end{macrocode}
5741 %
5742 % \begin{macrocode}
5743 \let\eql@tagpos@doconvert\eql@false
5744 % \end{macrocode}
5745 %
5746 % \begin{macrocode}
5747 \def\eql@tagpos@snap{4pt}
5748 % \end{macrocode}
5749 %
5750 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5751 % \paragraph{Registers.}
5752 %
5753 % \begin{macrocode}
5754 \let\eql@numbering@mode\@undefined
5755 % \end{macrocode}
5756 %
5757 % \begin{macrocode}
5758 \let\eql@numbering@active\eql@false
5759 \let\eql@numbering@multi\eql@true
5760 % \end{macrocode}
5761 %
5762 % \begin{macrocode}
5763 \let\eql@tags@container\@undefined
5764 \def\eql@tags@container@clear{%
5765 \let\eql@tags@label\@undefined
5766 \let\eql@tags@name\@undefined
5767 \let\eql@tags@tag\@undefined
5768 \let\eql@tags@ref\@undefined
5769 \let\eql@tags@anchor\@empty
5770 \eql@tagpos@shift@\z@
5771 \eql@tagpos@smashup@\z@
5772 \eql@tagpos@smashdown@\z@
5773 \let\eql@tagpos@reserve\eql@true
5774 }
5775 % \end{macrocode}
5776 %
5777 % \begin{macrocode}
5778 \let\eql@tags@label\@undefined
5779 \let\eql@tags@name\@undefined
5780 \let\eql@tags@tag\@undefined
5781 \let\eql@tags@ref\@undefined
5782 \let\eql@tags@frame@cmd\@firstofone
5783 % \end{macrocode}
5784 %
5785 % \tcounter{\eql@tags@glabel@}
5786 % \begin{macrocode}
5787 \newcount\eql@tags@glabel@
5788 \eql@tags@glabel@\z@
5789 \def\eql@tags@glabel{equation.eql-\the\eql@tags@glabel@}
5790 \def\eql@tags@glabel@step{\global\advance\eql@tags@glabel@\@ne}
5791 % \end{macrocode}
5792 %
5793 % \begin{macrocode}
5794 \let\eql@tagpos@continuous\eql@false
5795 % \end{macrocode}
5796 %
5797 % \begin{macrocode}
5798 \newcount\eql@tagpos@row@
5799 \newcount\eql@tagpos@prevrow@
5800 \newdimen\eql@tagpos@shift@
5801 \newdimen\eql@tagpos@smashup@
5802 \newdimen\eql@tagpos@smashdown@
5803 \newdimen\eql@tagpos@current@
5804 \newdimen\eql@tagpos@plain@
5805 \newdimen\eql@tagpos@raised@
5806 \newdimen\eql@tagpos@target@
5807 \newdimen\eql@tagpos@headroom@
5808 \newdimen\eql@tagpos@footroom@
5809 % \end{macrocode}
5810 %
5811 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5812 % \subsection{Schemes}
5813 %
5814 % \TODO describe
5815 %
5816 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5817 % \paragraph{Table.}
5818 %
5819 % \begin{macrocode}
5820 \def\eql@numbering@tab@sub{sub}
5821 \def\eql@numbering@tab@all{all}
5822 \def\eql@numbering@tab@first{first}
5823 \def\eql@numbering@tab@last{last}
5824 \def\eql@numbering@tab@in{in}
5825 \def\eql@numbering@tab@out{out}
5826 \def\eql@numbering@tab@middle{middle}
5827 \def\eql@numbering@tab@best{best}
5828 \def\eql@numbering@tab@here{here}
5829 \def\eql@numbering@tab@top{top}
5830 \def\eql@numbering@tab@bottom{bottom}
5831 \def\eql@numbering@tab@center{center}
5832 \def\eql@numbering@tab@centerone{centerone}
5833 \def\eql@numbering@tab@median{median}
5834 \def\eql@numbering@tab@baseline{baseline}
5835 % \end{macrocode}
5836 %
5837 % \begin{macrocode}
5838 \let\eql@numbering@mode\eql@numbering@tab@all
5839 \let\eql@numbering@mode@multi\eql@numbering@tab@all
5840 \let\eql@numbering@mode@single\eql@numbering@tab@out
5841 % \end{macrocode}
5842 %
5843 % \TODO describe
5844 % \begin{macrocode}
5845 \let\eql@numbering@tab@subeq\eql@numbering@tab@sub
5846 \let\eql@numbering@tab@subequation\eql@numbering@tab@sub
5847 \let\eql@numbering@tab@subequations\eql@numbering@tab@sub
5848 \let\eql@numbering@tab@mid\eql@numbering@tab@middle
5849 \let\eql@numbering@tab@outside\eql@numbering@tab@out
5850 \let\eql@numbering@tab@inside\eql@numbering@tab@in
5851 \let\eql@numbering@tab@within\eql@numbering@tab@in
5852 \let\eql@numbering@tab@opt\eql@numbering@tab@best
5853 \let\eql@numbering@tab@optimal\eql@numbering@tab@best
5854 \let\eql@numbering@tab@pick\eql@numbering@tab@here
5855 \let\eql@numbering@tab@med\eql@numbering@tab@median
5856 \eql@letcs{eql@numbering@tab@center*}\eql@numbering@tab@baseline
5857 \eql@letcs{eql@numbering@tab@center!}\eql@numbering@tab@centerone
5858 % \end{macrocode}
5859 %
5860 % \TODO describe
5861 % \begin{macrocode}
5862 \let\eql@numbering@tab@a\eql@numbering@tab@all
5863 \let\eql@numbering@tab@s\eql@numbering@tab@sub
5864 \let\eql@numbering@tab@f\eql@numbering@tab@first
5865 \let\eql@numbering@tab@l\eql@numbering@tab@last
5866 \let\eql@numbering@tab@o\eql@numbering@tab@out
5867 \let\eql@numbering@tab@i\eql@numbering@tab@in
5868 \let\eql@numbering@tab@h\eql@numbering@tab@here
5869 \let\eql@numbering@tab@t\eql@numbering@tab@top
5870 \let\eql@numbering@tab@b\eql@numbering@tab@bottom
5871 \let\eql@numbering@tab@c\eql@numbering@tab@center
5872 \let\eql@numbering@tab@m\eql@numbering@tab@median
5873 \eql@letcs{eql@numbering@tab@+}\eql@numbering@tab@best
5874 \eql@letcs{eql@numbering@tab@m*}\eql@numbering@tab@middle
5875 \eql@letcs{eql@numbering@tab@c*}\eql@numbering@tab@baseline
5876 \eql@letcs{eql@numbering@tab@c!}\eql@numbering@tab@centerone
5877 % \end{macrocode}
5878 %
5879 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5880 % \paragraph{Implementations.}
5881 %
5882 % \TODO describe
5883 % \begin{macrocode}
5884 \def\eql@numbering@init@all{\let\eql@numbering@multi\eql@true}
5885 % \end{macrocode}
5886 %
5887 % \TODO describe
5888 % \begin{macrocode}
5889 \def\eql@numbering@init@sub{%
5890 \let\eql@numbering@multi\eql@true
5891 \ifdefined\eql@subequations@active
5892 \let\eql@numbering@mode\eql@numbering@tab@all
5893 \else
5894 \let\eql@numbering@subeq@use\eql@true
5895 \fi
5896 }
5897 % \end{macrocode}
5898 %
5899 % \begin{macrocode}
5900 \def\eql@numbering@init@first{\eql@tagpos@row@\@ne}
5901 \def\eql@numbering@init@last{\eql@tagpos@row@\@MM}
5902 \def\eql@numbering@init@here{\eql@tagpos@row@\m@ne}
5903 % \end{macrocode}
5904 %
5905 % \TODO describe
5906 % \begin{macrocode}
5907 \def\eql@numbering@init@in{%
5908 \ifdefined\eql@tagsleft
5909 \eql@numbering@init@last
5910 \else
5911 \eql@numbering@init@first
5912 \fi
5913 }
5914 % \end{macrocode}
5915 %
5916 % \TODO describe
5917 % \begin{macrocode}
5918 \def\eql@numbering@init@out{%
5919 \ifdefined\eql@tagsleft
5920 \eql@numbering@init@first
5921 \else
5922 \eql@numbering@init@last
5923 \fi
5924 }
5925 % \end{macrocode}
5926 %
5927 % \TODO describe
5928 % \begin{macrocode}
5929 \def\eql@tagpos@eval@middle{%
5930 \ifnum\eql@tagpos@row@=\z@
5931 \eql@tagpos@row@\numexpr(\eql@totalrows@
5932 +\ifdefined\eql@tagsleft\z@\else\@ne\fi)/\tw@\relax
5933 \fi
5934 }
5935 % \end{macrocode}
5936 %
5937 % \TODO describe
5938 % \begin{macrocode}
5939 \def\eql@tagpos@eval@best{%
5940 \ifnum\eql@tagpos@row@=\z@
5941 \let\eql@numbering@best@use\eql@true
5942 \eql@numbering@init@out
5943 \fi
5944 }
5945 % \end{macrocode}
5946 %
5947 % \TODO describe
5948 % \begin{macrocode}
5949 \def\eql@numbering@init@continuous{\let\eql@tagpos@continuous\eql@true}
5950 % \end{macrocode}
5951 %
5952 % \TODO describe
5953 % \begin{macrocode}
5954 \let\eql@numbering@init@top\eql@numbering@init@continuous
5955 \def\eql@tagpos@eval@top{%
5956 \eql@tagpos@current@\z@
5957 }
5958 % \end{macrocode}
5959 %
5960 % \TODO describe
5961 % \begin{macrocode}
5962 \let\eql@numbering@init@bottom\eql@numbering@init@continuous
5963 \def\eql@tagpos@eval@bottom{%
5964 \eql@tagpos@current@\dimexpr\eql@totalheight@
5965 -\eql@tagheight@block@-\eql@tagdepth@block@\relax
5966 }
5967 % \end{macrocode}
5968 %
5969 % \TODO describe
5970 % \begin{macrocode}
5971 \let\eql@numbering@init@center\eql@numbering@init@continuous
5972 \def\eql@tagpos@eval@center{%
5973 \ifnum\eql@totalrows@=\@ne
5974 \eql@tagpos@row@\@ne
5975 \fi
5976 \eql@tagpos@current@\dimexpr(\eql@totalheight@
5977 -\eql@tagheight@block@-\eql@tagdepth@block@)/\tw@\relax
5978 }
5979 % \end{macrocode}
5980 %
5981 % \TODO describe
5982 % \begin{macrocode}
5983 \let\eql@numbering@init@centerone\eql@numbering@init@continuous
5984 \def\eql@tagpos@eval@centerone{%
5985 \eql@tagpos@current@\dimexpr(\eql@totalheight@
5986 -\eql@tagheight@block@-\eql@tagdepth@block@)/\tw@\relax
5987 }
5988 % \end{macrocode}
5989 %
5990 % \TODO describe
5991 % \begin{macrocode}
5992 \let\eql@numbering@init@baseline\eql@numbering@init@continuous
5993 \def\eql@tagpos@eval@baseline{%
5994 \eql@tagpos@current@\dimexpr(\eql@totalheight@
5995 +\eql@topheight@-\eql@bottomdepth@)/\tw@-\eql@tagheight@block@\relax
5996 }
5997 % \end{macrocode}
5998 %
5999 % \TODO describe
6000 % \begin{macrocode}
6001 \let\eql@numbering@init@median\eql@numbering@init@continuous
6002 \def\eql@tagpos@eval@median{%
6003 \ifnum\eql@tagpos@row@=\z@
6004 \ifodd\eql@totalrows@
6005 \eql@tagpos@row@\numexpr(\eql@totalrows@+\@ne)/\tw@\relax
6006 \else
6007 \eql@tagpos@row@\numexpr(\eql@totalrows@+\tw@)/\tw@\relax
6008 \eql@dimensions@get\eql@tagpos@row@
6009 \advance\eql@tagpos@shift@\dimexpr\eql@line@height@
6010 +(\eql@line@interline@-\eql@tagheight@block@
6011 +\eql@tagdepth@block@)/\tw@\relax
6012 \fi
6013 \ifnum\eql@totalrows@=\@ne
6014 \eql@tagpos@row@\@ne
6015 \else
6016 \eql@tagpos@adjust@eval@convert
6017 \eql@tagpos@row@\z@
6018 \fi
6019 \fi
6020 }
6021 % \end{macrocode}
6022 %
6023 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6024 % \paragraph{Selection.}
6025 %
6026 % \begin{macrocode}
6027 \def\eql@numbering@set#1{%
6028 \ifcsname eql@numbering@tab@#1\endcsname
6029 \expandafter\let\expandafter\eql@numbering@mode
6030 \csname eql@numbering@tab@#1\endcsname
6031 \ifx\eql@numbering@mode\eql@numbering@tab@all
6032 \let\eql@numbering@mode@multi\eql@numbering@mode
6033 \else\ifx\eql@numbering@mode\eql@numbering@tab@sub
6034 \let\eql@numbering@mode@multi\eql@numbering@mode
6035 \else
6036 \let\eql@numbering@mode@single\eql@numbering@mode
6037 \fi\fi
6038 \else
6039 \eql@error{numbering mode '#1' unknown: setting mode to 'all'}%
6040 \let\eql@numbering@mode\eql@numbering@tab@all
6041 \fi
6042 }
6043 % \end{macrocode}
6044 %
6045 % \TODO describe
6046 % \begin{macrocode}
6047 \def\eql@numbering@init{%
6048 \let\eql@numbering@multi\eql@false
6049 \let\eql@tagpos@continuous\eql@false
6050 \let\eql@numbering@subeq@use\eql@false
6051 \let\eql@numbering@best@use\eql@false
6052 \eql@tagpos@row@\z@
6053 \csname eql@numbering@init@\eql@numbering@mode\endcsname
6054 \ifdefined\eql@numbering@active
6055 \let\eql@numbering@eqnswinit\@eqnswtrue
6056 \else
6057 \let\eql@numbering@eqnswinit\@eqnswfalse
6058 \fi
6059 \let\eql@numbering@active\eql@false
6060 }
6061 % \end{macrocode}
6062 %
6063 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6064 % \subsection{Interface}
6065 %
6066 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6067 % \paragraph{Activation.}
6068 %
6069 % \TODO note |\nonumber| already defined, modifications by amsmath
6070 %
6071 % \begin{macrocode}
6072 \eql@amsmath@after{%
6073 \let\eql@print@eqnum@default\print@eqnum
6074 \let\eql@incr@eqnum@default\incr@eqnum
6075 }
6076 % \end{macrocode}
6077 %
6078 % \TODO describe
6079 % \begin{macrocode}
6080 \protected\def\donumber{%
6081 \if@eqnsw\else
6082 \global\@eqnswtrue
6083 \ifx\print@eqn\@empty
6084 \global\let\print@eqn\eql@print@eqnum@default
6085 \fi
6086 \ifx\incr@eqn\@empty
6087 \global\let\incr@eqn\eql@incr@eqnum@default
6088 \fi
6089 \fi
6090 }
6091 % \end{macrocode}
6092 %
6093 % \TODO reconsider operation
6094 % \imacro{\numberhere}
6095 % \begin{macrocode}
6096 \protected\def\eql@numberhere{%
6097 \ifdefined\eql@numbering@multi
6098 \global\@eqnswtrue
6099 \else
6100 \global\eql@tagpos@row@\eql@row@
6101 \fi
6102 }
6103 % \end{macrocode}
6104 %
6105 % \TODO describe
6106 % \imacro{\numbernext}
6107 % \begin{macrocode}
6108 \protected\def\eql@numbernext{%
6109 \ifdefined\eql@numbering@multi
6110 \global\@eqnswfalse
6111 \else
6112 \ifdefined\eql@tagpos@continuous\else
6113 \ifnum\eql@tagpos@row@=\eql@row@
6114 \global\advance\eql@tagpos@row@\@ne
6115 \fi
6116 \fi
6117 \fi
6118 }
6119 % \end{macrocode}
6120 %
6121 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6122 % \paragraph{Activation Trigger.}
6123 %
6124 % \begin{macrocode}
6125 \def\eql@tags@autoenable{%
6126 \global\@eqnswtrue
6127 \ifnum\eql@tagpos@row@=\m@ne
6128 \numberhere
6129 \fi
6130 }
6131 % \end{macrocode}
6132 %
6133 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6134 % \paragraph{Labels.}
6135 %
6136 % \TODO describe
6137 %
6138 % \macro{\eql@label@org}
6139 % \begin{macrocode}
6140 \let\eql@label@org\label
6141 % \end{macrocode}
6142 %
6143 % \TODO describe
6144 % \begin{macrocode}
6145 \def\eql@label@gobble{\eql@ampprotect\eql@testopt@tight\eql@gobbleoptone{}}
6146 % \end{macrocode}
6147 %
6148 % \TODO describe
6149 % \begin{macrocode}
6150 \protected\def\eql@label{%
6151 \eql@ampprotect\eql@testopt@tight\eql@tags@add@labelname\eql@testopt@default
6152 }
6153 % \end{macrocode}
6154 %
6155 % \TODO describe
6156 % \begin{macrocode}
6157 \def\eql@tags@add@labelname[#1]#2{%
6158 \def\eql@tmp{#1}%
6159 \ifx\eql@tmp\eql@testopt@default\else
6160 \eql@tags@add@name{#1}%
6161 \fi
6162 \eql@tags@add@label{#2}%
6163 }
6164 % \end{macrocode}
6165 %
6166 % \TODO describe
6167 % \begin{macrocode}
6168 \def\eql@tags@set@label#1{%
6169 \ifdefined\eql@tags@warn
6170 \ifdefined\eql@tags@label
6171 \eql@warn@label@multiple{#1}%
6172 \fi
6173 \fi
6174 \def\eql@tags@label{#1}%
6175 }
6176 % \end{macrocode}
6177 %
6178 % \TODO describe
6179 % \begin{macrocode}
6180 \def\eql@tags@set@name#1{%
6181 \ifdefined\eql@tags@warn
6182 \ifdefined\eql@tags@name
6183 \eql@warn@name@multiple
6184 \fi
6185 \fi
6186 \def\eql@tags@name{#1}%
6187 }
6188 % \end{macrocode}
6189 %
6190 % \TODO describe
6191 % \begin{macrocode}
6192 \def\eql@tags@add@label#1{%
6193 \ifdefined\eql@tags@autolabel
6194 \eql@tags@autoenable
6195 \fi
6196 \global\eql@appendexpand\eql@tags@container{%
6197 \noexpand\eql@tags@set@label{#1}}%
6198 }
6199 % \end{macrocode}
6200 %
6201 % \TODO describe
6202 % \begin{macrocode}
6203 \def\eql@tags@add@name#1{%
6204 \protected@edef\eql@tmp{\noexpand\eql@tags@set@name{#1}}%
6205 \global\eql@appendmacro\eql@tags@container\eql@tmp
6206 }
6207 % \end{macrocode}
6208 %
6209 % \TODO describe
6210 % \begin{macrocode}
6211 \def\eql@tags@addblock@label#1{%
6212 \eql@appendexpand\eql@tags@container@block{%
6213 \noexpand\eql@tags@set@label{#1}}%
6214 }
6215 % \end{macrocode}
6216 %
6217 % \TODO describe
6218 % \begin{macrocode}
6219 \def\eql@tags@addblock@name#1{%
6220 \protected@edef\eql@tmp{\noexpand\eql@tags@set@name{#1}}%
6221 \eql@appendmacro\eql@tags@container@block\eql@tmp
6222 }
6223 % \end{macrocode}
6224 %
6225 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6226 % \paragraph{Tags.}
6227 %
6228 % \TODO describe
6229 %
6230 % \macro{\eql@tag@default}
6231 % \begin{macrocode}
6232 \protected\def\eql@tag@default{%
6233 \eql@warn@here\tag
6234 \eql@tag@gobble
6235 }
6236 \let\tag\eql@tag@default
6237 % \end{macrocode}
6238 %
6239 % \macro{\eql@tag@gobble}
6240 % \begin{macrocode}
6241 \def\eql@tag@gobble{%
6242 \eql@ampprotecttwo\eql@teststaropt@tight\eql@gobbleoptone\eql@gobbleoptone{}}
6243 % \end{macrocode}
6244 %
6245 % \TODO describe
6246 % \begin{macrocode}
6247 \protected\def\eql@tag{%
6248 \eql@ampprotecttwo\eql@teststaropt@tight
6249 {\eql@tags@add@tagform@off\eql@tags@add@tagref}{\eql@tags@add@tagref}%
6250 \eql@testopt@default
6251 }
6252 % \end{macrocode}
6253 %
6254 % \macro{\eql@tags@add@tagref}
6255 % \begin{macrocode}
6256 \def\eql@tags@add@tagref[#1]#2{%
6257 \def\eql@tmp{#1}%
6258 \ifx\eql@tmp\eql@testopt@default\else
6259 \eql@tags@add@ref{#1}%
6260 \fi
6261 \eql@tags@add@tag{#2}%
6262 }
6263 % \end{macrocode}
6264 %
6265 % \TODO describe
6266 % \begin{macrocode}
6267 \def\eql@tags@set@tag#1{%
6268 \ifdefined\eql@tags@warn
6269 \ifdefined\eql@tags@tag
6270 \eql@warn@tag@multiple
6271 \fi
6272 \fi
6273 \def\eql@tags@tag{#1}%
6274 }
6275 % \end{macrocode}
6276 %
6277 % \TODO describe
6278 % \begin{macrocode}
6279 \def\eql@tags@set@ref#1{%
6280 \ifdefined\eql@tags@warn
6281 \ifdefined\eql@tags@ref
6282 \eql@warn@ref@multiple
6283 \fi
6284 \fi
6285 \def\eql@tags@ref{#1}%
6286 }
6287 % \end{macrocode}
6288 %
6289 % \TODO describe
6290 % \begin{macrocode}
6291 \def\eql@tags@add@tag#1{%
6292 \ifdefined\eql@tags@autotag
6293 \eql@tags@autoenable
6294 \fi
6295 \protected@edef\eql@tmp{\noexpand\eql@tags@set@tag{#1}}%
6296 \global\eql@appendmacro\eql@tags@container\eql@tmp
6297 }
6298 % \end{macrocode}
6299 %
6300 % \TODO describe
6301 % \begin{macrocode}
6302 \def\eql@tags@add@ref#1{%
6303 \protected@edef\eql@tmp{\noexpand\eql@tags@set@ref{#1}}%
6304 \global\eql@appendmacro\eql@tags@container\eql@tmp
6305 }
6306 % \end{macrocode}
6307 %
6308 % \macro{\eql@tags@add@tagform@off}
6309 % \begin{macrocode}
6310 \def\eql@tags@add@tagform@off{%
6311 \global\eql@append\eql@tags@container{\let\eql@tags@tagform\@firstofone}%
6312 }
6313 % \end{macrocode}
6314 %
6315 % \TODO describe
6316 % \begin{macrocode}
6317 \def\eql@tags@addblock@tag#1{%
6318 \protected@edef\eql@tmp{\noexpand\eql@tags@set@tag{#1}}%
6319 \eql@appendmacro\eql@tags@container@block\eql@tmp
6320 }
6321 % \end{macrocode}
6322 %
6323 % \TODO describe
6324 % \begin{macrocode}
6325 \def\eql@tags@addblock@ref#1{%
6326 \protected@edef\eql@tmp{\noexpand\eql@tags@set@ref{#1}}%
6327 \eql@appendmacro\eql@tags@container@block\eql@tmp
6328 }
6329 % \end{macrocode}
6330 %
6331 % \TODO describe
6332 % \begin{macrocode}
6333 \def\eql@tags@addblock@tagform@off{%
6334 \eql@append\eql@tags@container@block{\let\eql@tags@tagform\@firstofone}%
6335 }
6336 % \end{macrocode}
6337 %
6338 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6339 % \paragraph{Raise Tags.}
6340 %
6341 % \macro{\raisetag}
6342 % \begin{macrocode}
6343 \def\eql@raisetag@default{%
6344 \eql@warn@here\raisetag
6345 \eql@raisetag@gobble
6346 }
6347 % \end{macrocode}
6348 %
6349 % \begin{macrocode}
6350 \def\eql@raisetag@gobble{%
6351 \eql@ampprotecttwo\eql@ifstar@tight\@gobble\@gobble
6352 }
6353 % \end{macrocode}
6354 %
6355 % \TODO describe
6356 % \begin{macrocode}
6357 \eql@amsmath@let\raisetag\eql@raisetag@default
6358 % \end{macrocode}
6359 %
6360 % \begin{macrocode}
6361 \def\eql@raisetag{%
6362 \eql@ampprotecttwo\eql@ifstar@tight\eql@tags@add@raiseshift\eql@raisetag@test
6363 }
6364 % \end{macrocode}
6365 %
6366 % \begin{macrocode}
6367 \def\eql@raisetag@test#1{%
6368 \def\eql@tmpa{#1}\def\eql@tmpb{!}%
6369 \ifx\eql@tmpa\eql@tmpb
6370 \eql@tags@add@forceraise
6371 \else
6372 \eql@tags@add@raisesmash{#1}%
6373 \fi
6374 }
6375 % \end{macrocode}
6376 %
6377 % \begin{macrocode}
6378 \def\eql@tags@add@raiseshift#1{%
6379 \global\eql@appendexpand\eql@tags@container{%
6380 \advance\eql@tagpos@shift@\the\glueexpr#1\relax\relax}%
6381 }
6382 % \end{macrocode}
6383 %
6384 % \begin{macrocode}
6385 \def\eql@tags@add@raisesmash#1{%
6386 \dimen@\glueexpr#1\relax
6387 \ifdim\dimen@<\z@
6388 \global\eql@appendexpand\eql@tags@container{%
6389 \advance\eql@tagpos@smashdown@-\the\dimen@\relax}%
6390 \else
6391 \global\eql@appendexpand\eql@tags@container{%
6392 \advance\eql@tagpos@smashup@\the\dimen@\relax}%
6393 \fi
6394 }
6395 % \end{macrocode}
6396 %
6397 % \begin{macrocode}
6398 \def\eql@tags@add@forceraise{%
6399 \global\eql@append\eql@tags@container{\let\eql@tagpos@reserve\eql@false}%
6400 }
6401 % \end{macrocode}
6402 %
6403 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6404 % \subsection{Integration}
6405 %
6406 % \TODO describe
6407 %
6408 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6409 % \paragraph{Support.}
6410 %
6411 % \TODO describe
6412 %
6413 % \begin{macrocode}
6414 \def\eql@numbering@settools{%
6415 \let\label\eql@label
6416 \let\tag\eql@tag
6417 \let\raisetag\eql@raisetag
6418 \let\numberhere\eql@numberhere
6419 \let\numbernext\eql@numbernext
6420 }
6421 % \end{macrocode}
6422 %
6423 % \TODO not necessary anymore
6424 % \begin{macrocode}
6425 \def\eql@numbering@settools@gobble{%
6426 \let\label\eql@label@gobble
6427 \let\tag\eql@tag@gobble
6428 \let\raisetag\eql@raisetag@gobble
6429 \let\numberhere\relax
6430 \let\numbernext\relax
6431 }
6432 % \end{macrocode}
6433 %
6434 % \begin{macrocode}
6435 \def\eql@numbering@autoblock{%
6436 \begingroup
6437 \let\eql@tags@warn\eql@false
6438 \eql@tags@container@block
6439 \ifdefined\eql@tags@autolabel
6440 \ifdefined\eql@tags@label
6441 \global\@eqnswtrue
6442 \fi
6443 \fi
6444 \ifdefined\eql@tags@autotag
6445 \ifdefined\eql@tags@tag
6446 \global\@eqnswtrue
6447 \fi
6448 \fi
6449 \endgroup
6450 }
6451 % \end{macrocode}
6452 %
6453 % \begin{macrocode}
6454 \def\eql@numbering@warnunused{%
6455 \ifdefined\eql@tags@label
6456 \eql@warn@label@unused
6457 \fi
6458 \ifdefined\eql@tags@name
6459 \eql@warn@name@unused
6460 \fi
6461 \ifdefined\eql@tags@tag
6462 \eql@warn@tag@unused
6463 \fi
6464 \ifdefined\eql@tags@erf
6465 \eql@warn@ref@unused
6466 \fi
6467 }
6468 % \end{macrocode}
6469 %
6470 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6471 % \paragraph{Single Line.}
6472 %
6473 % \TODO describe
6474 % \begin{macrocode}
6475 \def\eql@numbering@single@init{%
6476 \let\eql@numbering@multi\eql@false
6477 \eql@numbering@settools
6478 \eql@numbering@eqnswinit
6479 \eql@numbering@autoblock
6480 \global\let\eql@tags@container\eql@tags@container@block
6481 \let\eql@tags@warn\eql@true
6482 }
6483 % \end{macrocode}
6484 %
6485 % \begin{macrocode}
6486 \def\eql@numbering@single@eval{%
6487 \ifnum\eql@tagpos@row@=\m@ne
6488 \@eqnswfalse
6489 \fi
6490 }
6491 % \end{macrocode}
6492 %
6493 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6494 % \paragraph{Multi-Line Measuring Pass.}
6495 %
6496 % \TODO describe
6497 %
6498 % \begin{macrocode}
6499 \def\eql@numbering@measure@init{%
6500 \eql@numbering@settools
6501 \ifdefined\eql@numbering@multi\else
6502 \eql@numbering@eqnswinit
6503 \eql@numbering@autoblock
6504 \fi
6505 \global\let\eql@tags@container\eql@tags@container@block
6506 \let\eql@tags@warn\eql@true
6507 }
6508 % \end{macrocode}
6509 %
6510 % \TODO might select only relevant routines in init
6511 % \TODO describe
6512 % \begin{macrocode}
6513 \def\eql@numbering@measure@line@begin{%
6514 \ifdefined\eql@numbering@multi
6515 \global\eql@numbering@eqnswinit
6516 \fi
6517 }
6518 % \end{macrocode}
6519 %
6520 % \TODO describe
6521 % \begin{macrocode}
6522 \def\eql@numbering@measure@blocktag{%
6523 \ifdefined\eql@numbering@multi
6524 \@eqnswfalse
6525 \else
6526 \ifnum\eql@tagpos@row@=\m@ne
6527 \@eqnswfalse
6528 \fi
6529 \ifnum\eql@totalrows@=\z@
6530 \@eqnswfalse
6531 \fi
6532 \fi
6533 }
6534 % \end{macrocode}
6535 %
6536 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6537 % \paragraph{Multi-Line Print Pass.}
6538 %
6539 % \TODO describe
6540 %
6541 % \TODO can we be absolutely sure about all values being preserved
6542 % global might pick up a value from a higher level block and
6543 % restore it globally!
6544 % \begin{macrocode}
6545 \def\eql@numbering@print@init{%
6546 \let\eql@tags@warn\eql@false
6547 \ifdefined\eql@numbering@multi
6548 \eql@numbering@settools
6549 \global\let\eql@tags@container\eql@tags@container@block
6550 \else
6551 \let\eql@tags@container@block\eql@tags@container
6552 \eql@numbering@settools@gobble
6553 \fi
6554 }
6555 % \end{macrocode}
6556 %
6557 % \TODO might select only relevant routines in init
6558 % \TODO describe
6559 % \begin{macrocode}
6560 \def\eql@numbering@print@block@begin{%
6561 \ifdefined\eql@numbering@multi\else
6562 \ifnum\eql@tagpos@row@>\z@
6563 \eql@tags@makeblockanchor
6564 \global\eql@appendexpand\eql@tags@container@block{%
6565 \def\noexpand\eql@tags@anchor{%
6566 \unexpanded\expandafter{\eql@tags@anchor}}}%
6567 \fi
6568 \fi
6569 \ifdefined\eql@numbering@subeq@use
6570 \eql@tags@printsubeqlabel
6571 \fi
6572 }
6573 % \end{macrocode}
6574 %
6575 % \TODO describe
6576 % \begin{macrocode}
6577 \def\eql@numbering@print@line@begin{%
6578 \ifdefined\eql@numbering@multi
6579 \global\eql@numbering@eqnswinit
6580 \fi
6581 }
6582 % \end{macrocode}
6583 %
6584 % \TODO describe
6585 % \begin{macrocode}
6586 \def\eql@numbering@print@line@eval{%
6587 \ifdefined\eql@numbering@multi
6588 \if@eqnsw
6589 \eql@tags@container
6590 \fi
6591 \else
6592 \ifnum\eql@tagpos@row@=\eql@row@
6593 \@eqnswtrue
6594 \eql@tags@container@block
6595 \else
6596 \@eqnswfalse
6597 \fi
6598 \fi
6599 }
6600 % \end{macrocode}
6601 %
6602 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6603 % \subsection{Positioning}
6604 %
6605 % \TODO describe
6606 % \begin{macrocode}
6607 \def\eql@tagpos@single@eval{%
6608 \if@eqnsw
6609 \csname eql@tagpos@eval@\eql@numbering@mode\endcsname
6610 \ifnum\eql@tagpos@row@>\@ne
6611 \eql@tagpos@row@\@ne
6612 \fi
6613 \ifdefined\eql@tagpos@doconvert
6614 \let\eql@tagpos@continuous\eql@true
6615 \fi
6616 \ifdefined\eql@tagpos@continuous
6617 \eql@tagpos@single@eval@continuous
6618 \fi
6619 \else
6620 \eql@tagpos@row@\z@
6621 \fi
6622 \eql@tagpos@prevrow@\z@
6623 \eql@tagpos@headroom@\z@
6624 \eql@tagpos@footroom@\z@
6625 }
6626 % \end{macrocode}
6627 %
6628 % \TODO describe
6629 % \begin{macrocode}
6630 \def\eql@tagpos@single@eval@continuous{%
6631 \ifnum\eql@tagpos@row@>\z@
6632 \eql@tagpos@target@\eql@tagpos@shift@
6633 \else
6634 \eql@tagpos@target@\dimexpr\eql@line@height@
6635 -\eql@tagpos@current@+\eql@tagpos@shift@-\eql@tagheight@block@\relax
6636 \fi
6637 \eql@tagpos@row@\@ne
6638 \ifdim\ifdim\eql@tagpos@target@<\z@-\fi
6639 \eql@tagpos@target@<\glueexpr\eql@tagpos@snap\relax
6640 \eql@tagpos@target@\z@
6641 \fi
6642 }
6643 % \end{macrocode}
6644 %
6645 % \TODO describe
6646 % \begin{macrocode}
6647 \def\eql@tagpos@adjust@eval{%
6648 \if@eqnsw
6649 \csname eql@tagpos@eval@\eql@numbering@mode\endcsname
6650 \ifnum\eql@tagpos@row@>\eql@totalrows@
6651 \eql@tagpos@row@\eql@totalrows@
6652 \fi
6653 \ifdefined\eql@tagpos@doconvert
6654 \let\eql@tagpos@continuous\eql@true
6655 \fi
6656 \ifdefined\eql@tagpos@continuous
6657 \ifnum\eql@tagpos@row@>\z@
6658 \eql@tagpos@adjust@eval@convert
6659 \fi
6660 \eql@tagpos@adjust@eval@continuous
6661 \fi
6662 \else
6663 \eql@tagpos@row@\z@
6664 \eql@tagpos@prevrow@\z@
6665 \fi
6666 }
6667 % \end{macrocode}
6668 %
6669 % \TODO describe
6670 % \begin{macrocode}
6671 \def\eql@tagpos@adjust@eval@convert{%
6672 \eql@tagpos@current@\z@
6673 \eql@dimensions@for{%
6674 \ifnum\eql@row@<\eql@tagpos@row@
6675 \advance\eql@tagpos@current@\dimexpr\eql@line@interline@
6676 +\eql@line@height@+\eql@line@depth@\relax
6677 \fi
6678 \ifnum\eql@row@=\eql@tagpos@row@
6679 \advance\eql@tagpos@current@\dimexpr\eql@line@interline@
6680 +\eql@line@height@-\eql@tagheight@block@\relax
6681 \fi
6682 }%
6683 }
6684 % \end{macrocode}
6685 %
6686 % \TODO describe
6687 % \begin{macrocode}
6688 \def\eql@tagpos@adjust@eval@continuous{%
6689 \dimen@\dimexpr\eql@tagpos@current@-\eql@tagpos@shift@\relax
6690 \eql@tagpos@row@\eql@totalrows@
6691 \eql@tagpos@prevrow@\z@
6692 \eql@tagpos@headroom@\z@
6693 \eql@tagpos@footroom@\z@
6694 \eql@dimensions@for{%
6695 \ifnum\eql@tagpos@row@=\eql@totalrows@
6696 \eql@tagpos@headroom@\eql@line@interline@
6697 \eql@tagpos@target@\dimexpr\eql@line@interline@
6698 +\eql@line@height@-\dimen@-\eql@tagheight@block@\relax
6699 \ifdim\ifdim\eql@tagpos@target@<\z@-\fi
6700 \eql@tagpos@target@<\glueexpr\eql@tagpos@snap\relax
6701 \advance\dimen@\eql@tagpos@target@
6702 \eql@tagpos@target@\z@
6703 \fi
6704 \ifdim\eql@tagpos@target@>%
6705 \ifdefined\eql@tagsleft-1sp\relax\else\z@\fi
6706 \eql@tagpos@row@\eql@row@
6707 \eql@tagpos@prevrow@\numexpr\eql@row@-\@ne\relax
6708 \fi
6709 \advance\dimen@-\dimexpr\eql@line@interline@
6710 +\eql@line@depth@+\eql@line@height@\relax
6711 \fi
6712 \ifnum\eql@row@=\numexpr\eql@tagpos@row@+\@ne\relax
6713 \eql@tagpos@footroom@\eql@line@interline@
6714 \fi
6715 }%
6716 }
6717 % \end{macrocode}
6718 %
6719 % \TODO describe
6720 % \begin{macrocode}
6721 \def\eql@tagpos@print@line@eval{%
6722 \ifdefined\eql@tagpos@continuous
6723 \eql@tagpos@print@line@eval@continuous
6724 \else
6725 \eql@tagpos@print@line@eval@discrete
6726 \fi
6727 }
6728 % \end{macrocode}
6729 %
6730 % \TODO describe
6731 % \begin{macrocode}
6732 \def\eql@tagpos@print@line@eval@continuous{%
6733 \if@eqnsw
6734 \ht\eql@tagbox@\dimexpr\ht\eql@tagbox@-\eql@tagpos@smashup@\relax
6735 \dp\eql@tagbox@\dimexpr\dp\eql@tagbox@-\eql@tagpos@smashdown@\relax
6736 \eql@tagpos@plain@\eql@tagpos@target@
6737 \@tempdima\dimexpr\eql@line@height@+\eql@tagpos@headroom@
6738 -\ht\eql@tagbox@\relax
6739 \@tempdimb\dimexpr-\eql@line@depth@-\eql@tagpos@footroom@
6740 +\dp\eql@tagbox@\relax
6741 \ifnum\eql@row@=\@ne
6742 \@tempdima.5\maxdimen
6743 \fi
6744 \ifnum\eql@row@=\eql@totalrows@
6745 \@tempdimb-.5\maxdimen
6746 \fi
6747 \ifdim\eql@tagpos@plain@>\@tempdima
6748 \ifdim\eql@tagpos@plain@>\@tempdimb
6749 \ifdim\@tempdima>\@tempdimb
6750 \eql@tagpos@plain@\@tempdima
6751 \else
6752 \eql@tagpos@plain@\@tempdimb
6753 \fi
6754 \fi
6755 \else
6756 \ifdim\eql@tagpos@plain@<\@tempdimb
6757 \ifdim\@tempdima>\@tempdimb
6758 \eql@tagpos@plain@\@tempdimb
6759 \else
6760 \eql@tagpos@plain@\@tempdima
6761 \fi
6762 \fi
6763 \fi
6764 \ifnum\eql@tagpos@prevrow@>\z@
6765 \eql@tagpos@raised@\dimexpr\eql@line@height@+\dp\eql@tagbox@\relax
6766 \ifdim\eql@tagpos@raised@>\eql@tagpos@plain@\else
6767 \eql@tagpos@raised@\eql@tagpos@plain@
6768 \let\eql@tagpos@reserve\eql@false
6769 \fi
6770 \else
6771 \ifdim\eql@tagpos@target@>%
6772 \ifdefined\eql@tagsleft-1sp\relax\else\z@\fi
6773 \eql@tagpos@raised@\dimexpr\eql@line@height@+\dp\eql@tagbox@\relax
6774 \ifdim\eql@tagpos@raised@>\eql@tagpos@plain@\else
6775 \eql@tagpos@raised@\eql@tagpos@plain@
6776 \let\eql@tagpos@reserve\eql@false
6777 \fi
6778 \else
6779 \eql@tagpos@raised@\dimexpr-\eql@line@depth@
6780 -\ht\eql@tagbox@\relax
6781 \ifdim\eql@tagpos@raised@<\eql@tagpos@plain@\else
6782 \eql@tagpos@raised@\eql@tagpos@plain@
6783 \let\eql@tagpos@reserve\eql@false
6784 \fi
6785 \fi
6786 \fi
6787 \else
6788 \ifnum\eql@tagpos@prevrow@=\eql@row@
6789 \eql@tagwidth@\eql@tagwidth@block@
6790 \else
6791 \let\eql@tagpos@reserve\eql@false
6792 \fi
6793 \fi
6794 }
6795 % \end{macrocode}
6796 %
6797 % \TODO describe
6798 % \begin{macrocode}
6799 \def\eql@tagpos@print@line@eval@discrete{%
6800 \if@eqnsw
6801 \ht\eql@tagbox@\dimexpr\ht\eql@tagbox@-\eql@tagpos@smashup@\relax
6802 \dp\eql@tagbox@\dimexpr\dp\eql@tagbox@-\eql@tagpos@smashdown@\relax
6803 \eql@tagpos@plain@\eql@tagpos@shift@
6804 \eql@tagpos@headroom@\z@
6805 \eql@tagpos@footroom@\z@
6806 \ifdim\eql@tagpos@shift@>%
6807 \ifdefined\eql@tagsleft-1sp\relax\else\z@\fi
6808 \eql@tagpos@raised@\dimexpr\eql@line@height@+\dp\eql@tagbox@\relax
6809 \else
6810 \eql@tagpos@raised@\dimexpr-\eql@line@depth@-\ht\eql@tagbox@\relax
6811 \fi
6812 \else
6813 \let\eql@tagpos@reserve\eql@false
6814 \fi
6815 }
6816 % \end{macrocode}
6817 %
6818 % \TODO describe
6819 % \begin{macrocode}
6820 \def\eql@tagpos@print@line@end{%
6821 \ifdefined\eql@tagpos@continuous
6822 \ifnum\eql@tagpos@prevrow@=\eql@row@
6823 \ifdefined\eql@tagpos@reserve
6824 \global\eql@appendexpand\eql@tags@container@block{%
6825 \advance\eql@tagpos@headroom@\the\dimexpr\eql@line@height@
6826 +\eql@line@depth@\relax\relax}%
6827 \eql@displaybreak@star\@M
6828 \fi
6829 \fi
6830 \fi
6831 }
6832 % \end{macrocode}
6833 %
6834 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6835 % \subsection{Component Display}
6836 %
6837 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6838 % \paragraph{Showkeys Integration.}
6839 %
6840 % \TODO describe
6841 %
6842 % \begin{macrocode}
6843 \let\eql@SK@loaded\eql@false
6844 \let\eql@SK@label\@gobble
6845 \let\eql@SK@clearlabel\@empty
6846 \let\eql@SK@setlabel\@gobble
6847 \let\eql@SK@printlabel@right\@empty
6848 \let\eql@SK@printlabel@left\@empty
6849 \let\eql@SK@printlabel@line\@empty
6850 \def\eql@label@clean{\eql@label@org}
6851 \AddToHook{package/showkeys/after}{%
6852 \let\eql@SK@loaded\eql@true
6853 \def\eql@SK@label#1{\SK@\SK@@label#1}%
6854 \def\eql@SK@clearlabel{\let\eql@SK@lab\relax}%
6855 \eql@SK@clearlabel
6856 \def\eql@SK@@label#1>#2\SK@{%
6857 \def\eql@SK@lab{\smash{\SK@labelcolor\showkeyslabelformat{#2}}}%
6858 }%
6859 \def\eql@SK@setlabel#1{\SK@\eql@SK@@label#1}%
6860 \def\eql@SK@printlabel@right{%
6861 \ifx\eql@SK@lab\relax\else
6862 \rlap{\kern\marginparsep\eql@SK@lab}%
6863 \eql@SK@clearlabel
6864 \fi
6865 }%
6866 \def\eql@SK@printlabel@left{%
6867 \ifx\eql@SK@lab\relax\else
6868 \llap{\eql@SK@lab\kern\marginparsep}%
6869 \eql@SK@clearlabel
6870 \fi
6871 }%
6872 \def\eql@SK@printlabel@line{%
6873 \ifx\eql@SK@lab\relax\else
6874 \dimen@\prevdepth
6875 \nointerlineskip
6876 \ifdefined\eql@tagsleft
6877 \llap{%
6878 \eql@SK@lab
6879 \kern\marginparsep
6880 }%
6881 \eql@SK@clearlabel
6882 \else
6883 \rlap{%
6884 \dimen@\displaywidth
6885 \advance\dimen@\marginparsep
6886 \kern\dimen@
6887 \eql@SK@lab
6888 }%
6889 \fi
6890 \eql@SK@clearlabel
6891 \prevdepth\dimen@
6892 \fi
6893 }%
6894 \let\eql@label@org\label
6895 \def\eql@label@clean{\let\SK@\@gobbletwo\eql@label@org}
6896 }
6897 % \end{macrocode}
6898 %
6899 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6900 % \paragraph{Labels.}
6901 %
6902 % \macro{\eql@composetag@label}
6903 % \TODO describe
6904 % \begin{macrocode}
6905 \def\eql@composetag@label{%
6906 \eql@SK@clearlabel
6907 \ifdefined\eql@tags@label
6908 \eql@SK@setlabel\eql@tags@label
6909 \ifdefined\eql@tags@name
6910 \let\@currentlabelname\eql@tags@name
6911 \else
6912 \let\@currentlabelname\eql@tags@name@generic
6913 \fi
6914 \expandafter\eql@label@clean\expandafter{\eql@tags@label}%
6915 \fi
6916 }
6917 % \end{macrocode}
6918 %
6919 % \TODO describe
6920 % \begin{macrocode}
6921 \def\eql@tags@printsubeqlabel{%
6922 \eql@tags@container@parent
6923 \ifdefined\eql@tags@label
6924 \eql@tags@makeblockanchor
6925 \eql@SK@setlabel\eql@tags@label
6926 \begingroup
6927 \def\@currentcounter{equation}%
6928 \eql@tags@anchor
6929 \let\@currentlabelname\eql@tags@name@generic
6930 \protected@edef\@currentlabel{\p@equation\theparentequation}%
6931 \expandafter\eql@label@clean\expandafter{\eql@tags@label}%
6932 \endgroup
6933 \eql@SK@printlabel@line
6934 \fi
6935 }
6936 % \end{macrocode}
6937 %
6938 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6939 % \paragraph{Hyperref Anchors.}
6940 %
6941 % \TODO describe
6942 %
6943 % \begin{macrocode}
6944 \let\eql@Hy@anchor\@gobble
6945 \AddToHook{package/hyperref/after}{%
6946 \def\eql@Hy@anchor#1{%
6947 \Hy@raisedlink{\hyper@anchor{#1}}%
6948 }%
6949 }
6950 % \end{macrocode}
6951 %
6952 % \TODO describe
6953 % \begin{macrocode}
6954 \def\eql@tags@makeblockanchor{%
6955 \eql@tags@glabel@step
6956 \eql@Hy@anchor\eql@tags@glabel
6957 \edef\eql@tags@anchor{%
6958 \def\noexpand\thepage{\thepage}%
6959 \def\noexpand\@currentHref{\eql@tags@glabel}%
6960 }%
6961 }
6962 % \end{macrocode}
6963 %
6964 % \TODO describe
6965 %
6966 % \macro{\eql@composetag@anchor}
6967 % \begin{macrocode}
6968 \def\eql@composetag@anchor{%
6969 \ifdefined\eql@tags@tag
6970 \def\@currentcounter{equation}%
6971 \ifdefined\eql@tags@ref
6972 \let\@currentlabel\eql@tags@ref
6973 \else
6974 \protected@edef\@currentlabel{\p@equation\eql@tags@tag}%
6975 \fi
6976 \eql@tags@glabel@step
6977 \edef\@currentHref{\eql@tags@glabel}%
6978 \eql@Hy@anchor\@currentHref
6979 \else
6980 \refstepcounter{equation}%
6981 \protected@edef\eql@tags@tag{\theequation}%
6982 \fi
6983 \eql@tags@anchor
6984 }
6985 % \end{macrocode}
6986 %
6987 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6988 % \paragraph{Tag Layout.}
6989 %
6990 % \TODO describe
6991 %
6992 % \begin{macrocode}
6993 \def\eql@tags@taglayout@set@direct#1{%
6994 \def\eql@tags@taglayout##1{#1}%
6995 }
6996 \def\eql@tags@taglayout@set#1{%
6997 \def\eql@tags@taglayout##1{\hbox{\m@th\normalfont#1}}%
6998 }
6999 % \end{macrocode}
7000 %
7001 % \TODO describe
7002 % \begin{macrocode}
7003 \def\eql@tags@tagform@set@direct#1{%
7004 \def\eql@tags@tagform##1{#1}%
7005 }
7006 \def\eql@tags@tagform@set#1#2#3{%
7007 \def\eql@tags@tagform##1{#1\ignorespaces#2\unskip\@@italiccorr#3}%
7008 }
7009 % \end{macrocode}
7010 %
7011 % \begin{macrocode}
7012 \eql@tags@taglayout@set{#1}
7013 \eql@tags@tagform@set({#1})
7014 \def\eql@tags@tagcompose#1{\eql@tags@taglayout{\eql@tags@tagform{#1}}}
7015 % \end{macrocode}
7016 %
7017 % \begin{macrocode}
7018 \protected\def\tagform{\eql@tags@tagform}
7019 \protected\def\tagbox{\eql@tags@taglayout}
7020 \protected\def\tagboxed{\eql@tags@tagcompose}
7021 % \end{macrocode}
7022 %
7023 % \macro{\eqref}
7024 % \amsmath/ defines the macro |\eqref|
7025 % to refer to equation labels in a proper format.
7026 % We provide it for completeness:
7027 % \begin{macrocode}
7028 \protected\def\eql@eqref#1{\textup{\eql@tags@tagcompose{\ref{#1}}}}
7029 % \end{macrocode}
7030 %
7031 % \macro{\eql@composetag@tag}
7032 % \TODO describe
7033 % \begin{macrocode}
7034 \def\eql@composetag@tag{%
7035 \eql@tagging@tagbegin
7036 \eql@tags@frame@cmd{%
7037 \eql@tags@taglayout{%
7038 \eql@tags@tagform\eql@tags@tag
7039 \eql@tagging@tagsave
7040 }%
7041 }%
7042 \eql@tagging@tagend
7043 }
7044 % \end{macrocode}
7045 %
7046 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7047 % \subsection{Tag Composition}
7048 %
7049 % \TODO describe
7050 % \begin{macrocode}
7051 \def\eql@composetag@measure{%
7052 \ifdefined\eql@tags@tag\else
7053 \stepcounter{equation}%
7054 \let\eql@tags@tag\theequation
7055 \fi
7056 \eql@tags@frame@cmd{\eql@tags@taglayout{\eql@tags@tagform\eql@tags@tag}}%
7057 \ifdefined\eql@numbering@multi
7058 \global\let\eql@tags@container\eql@tags@container@clear
7059 \fi
7060 }
7061 % \end{macrocode}
7062 %
7063 % \TODO describe
7064 % \begin{macrocode}
7065 \def\eql@composetag@print{%
7066 \eql@composetag@anchor
7067 \eql@composetag@label
7068 \ifdefined\eql@tagsleft
7069 \eql@SK@printlabel@left
7070 \eql@composetag@tag
7071 \else
7072 \eql@composetag@tag
7073 \eql@SK@printlabel@right
7074 \fi
7075 \global\let\eql@tags@container\eql@tags@container@clear
7076 }
7077 % \end{macrocode}
7078 %
7079 % \TODO describe
7080 %
7081 % \TODO one might still compare width to zero and pretend the tag is absent??
7082 % \begin{macrocode}
7083 \def\eql@tagbox@make#1{%
7084 \setbox\eql@tagbox@\hbox{\eql@strut@tag\@lign#1}%
7085 \eql@tagwidth@\wd\eql@tagbox@
7086 \ifdim\eql@tagwidth@<\eql@tagwidthmin@
7087 \eql@tagwidth@\eql@tagwidthmin@
7088 \fi
7089 \advance\eql@tagwidth@\eql@tagsepmin@
7090 }
7091 % \end{macrocode}
7092 %
7093 % \TODO describe
7094 % \begin{macrocode}
7095 \def\eql@tagbox@print@adjustheadroom{%
7096 \dimen@\dimexpr\ht\eql@tagbox@+\eql@tagpos@current@-\eql@line@height@\relax
7097 \ifdim\dimen@>\z@
7098 \ifdim\dimen@>\eql@tagpos@headroom@
7099 \ht\eql@tagbox@\dimexpr\ht\eql@tagbox@-\eql@tagpos@headroom@\relax
7100 \else
7101 \ht\eql@tagbox@\dimexpr\eql@line@height@-\eql@tagpos@current@\relax
7102 \fi
7103 \fi
7104 }
7105 % \end{macrocode}
7106 %
7107 % \TODO describe
7108 % \begin{macrocode}
7109 \def\eql@tagbox@print@adjustfootroom{%
7110 \dimen@\dimexpr\dp\eql@tagbox@-\eql@tagpos@current@-\eql@line@depth@\relax
7111 \ifdim\dimen@>\z@
7112 \ifdim\dimen@>\eql@tagpos@footroom@
7113 \dp\eql@tagbox@\dimexpr\dp\eql@tagbox@-\eql@tagpos@footroom@\relax
7114 \else
7115 \dp\eql@tagbox@\dimexpr\eql@line@depth@+\eql@tagpos@current@\relax
7116 \fi
7117 \fi
7118 }
7119 % \end{macrocode}
7120 %
7121 % \TODO describe
7122 % \begin{macrocode}
7123 \def\eql@tagbox@print@extendabove{%
7124 \dimen@\dimexpr\ht\eql@tagbox@+\eql@tagpos@current@-\eql@line@height@\relax
7125 \ifdim\dimen@>\z@
7126 \global\eql@appendexpand\eql@display@container{%
7127 \eql@display@aboveextend@\the\dimen@\relax}%
7128 \fi
7129 }
7130 % \end{macrocode}
7131 %
7132 % \TODO describe
7133 % \begin{macrocode}
7134 \def\eql@tagbox@print@extendbelow{%
7135 \dimen@\dimexpr\dp\eql@tagbox@-\eql@tagpos@current@-\eql@line@depth@\relax
7136 \ifdim\dimen@>\z@
7137 \global\eql@appendexpand\eql@display@container{%
7138 \eql@display@belowextend@\the\dimexpr\dimen@\relax}%
7139 \fi
7140 }
7141 % \end{macrocode}
7142 %
7143 % \TODO describe
7144 % \begin{macrocode}
7145 \def\eql@tagbox@print@prepare{%
7146 \ifdefined\eql@tagpos@reserve
7147 \eql@tagpos@current@\eql@tagpos@plain@
7148 \else
7149 \eql@tagpos@current@\eql@tagpos@raised@
7150 \fi
7151 \ifdim\eql@tagpos@headroom@>\z@
7152 \eql@tagbox@print@adjustheadroom
7153 \fi
7154 \ifdim\eql@tagpos@footroom@>\z@
7155 \eql@tagbox@print@adjustfootroom
7156 \fi
7157 \ifnum\eql@row@=\@ne
7158 \eql@tagbox@print@extendabove
7159 \fi
7160 \ifnum\eql@row@=\eql@totalrows@
7161 \eql@tagbox@print@extendbelow
7162 \fi
7163 }
7164 % \end{macrocode}
7165 %
7166 % \TODO describe
7167 % \begin{macrocode}
7168 \def\eql@tagbox@print@tagsright{%
7169 \eql@tagbox@print@prepare
7170 \kern-\wd\eql@tagbox@
7171 \raise\eql@tagpos@current@\box\eql@tagbox@
7172 }
7173 % \end{macrocode}
7174 %
7175 % \TODO describe
7176 % \begin{macrocode}
7177 \def\eql@tagbox@print@tagsleft{%
7178 \eql@display@firstavail@set\z@
7179 \eql@tagbox@print@prepare
7180 \wd\eql@tagbox@\z@
7181 \raise\eql@tagpos@current@\box\eql@tagbox@
7182 }
7183 % \end{macrocode}
7184 %
7185 % \macro{\eql@tagbox@print@cell}
7186 % \begin{macrocode}
7187 \def\eql@tagbox@print@cell{%
7188 \eql@tagging@tagaddbox
7189 \ifdefined\eql@tagsleft
7190 \ifdefined\eql@tagpos@reserve
7191 \ifdim\eql@tagwidth@>\dimexpr\eql@line@avail@+\eql@tagfuzz@\relax
7192 \let\eql@tagpos@reserve\eql@false
7193 \fi
7194 \fi
7195 \if@eqnsw
7196 \eql@tagbox@print@tagsleft
7197 \fi
7198 \kern\displaywidth
7199 \else
7200 \kern\displaywidth
7201 \ifdefined\eql@tagpos@reserve
7202 \ifdim\eql@tagwidth@>%
7203 \dimexpr\displaywidth-\eql@line@width@+\eql@tagfuzz@\relax
7204 \let\eql@tagpos@reserve\eql@false
7205 \fi
7206 \fi
7207 \if@eqnsw
7208 \eql@tagbox@print@tagsright
7209 \fi
7210 \fi
7211 }
7212 % \end{macrocode}
7213 %
7214 %
7215 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7216 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7217 % \section{Subequation Numbering}
7218 %
7219 % We replicate the \amsmath/ functionality to
7220 % number a block of equations with a common number and
7221 % a sub-numbering.
7222 %
7223 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7224 % \subsection{Definitions}
7225 %
7226 % \lcounter{parentequation}
7227 % We define a counter to store the main equation number
7228 % while in subequation mode.
7229 % It makes sense to share this definition
7230 % with \amsmath/ as |parentequation|,
7231 % and we need to undefine it when \amsmath/
7232 % is loaded at a later stage:
7233 % \begin{macrocode}
7234 \eql@amsmath@undefine\c@parentequation
7235 \eql@amsmath@undefine\theparentequation
7236 \ifdefined\c@parentequation\else
7237 \newcounter{parentequation}
7238 \fi
7239 % \end{macrocode}
7240 %
7241 % \macro{\eql@subequations@template}
7242 % We store a template which will installed as |\theequation|
7243 % in subequations mode:
7244 % \TODO need to protect something?!
7245 % \begin{macrocode}
7246 \def\eql@subequations@template{\theparentequation\alph{equation}}
7247 \def\eql@subequations@template@set#1{\def\eql@tmp##1##2{#1}%
7248 \edef\eql@subequations@template{%
7249 \unexpanded\expandafter{\eql@tmp\theparentequation{equation}}}}
7250 % \end{macrocode}
7251 %
7252 % \macro{\eql@subequations@active}
7253 % A boolean register which tells whether subequations are in use
7254 % and thus must not be invoked again:
7255 % \begin{macrocode}
7256 \let\eql@subequations@active\eql@false
7257 % \end{macrocode}
7258 %
7259 % \macro{\eql@subequations@init}
7260 % Low-level initialise the subequations mode.
7261 % Store the equation counter in |\eql@subequations@restorecounter|
7262 % for the case that no equation numbers will be used.
7263 % Step the equation counter, copy it to |parentequation|
7264 % and initialise |\theparentequation|
7265 % (and its \ctanpkg{hyperref} counterpart)
7266 % with the expanded current value of |\theequation|;
7267 % fill with tag data instead if a tag has been specified.
7268 % Reset the equation counter and use the template
7269 % for |\thequation|:
7270 % \begin{macrocode}
7271 \def\eql@subequations@init{%
7272 \edef\eql@subequations@restorecounter{%
7273 \global\c@equation\the\c@equation\relax}%
7274 \eql@tags@container@block
7275 \ifdefined\eql@tags@tag
7276 \eql@tags@glabel@step
7277 \protected@edef\theHparentequation{\eql@tags@glabel}%
7278 \protected@edef\theparentequation{\eql@tags@tag}%
7279 \else
7280 \advance\c@equation\@ne
7281 \protected@edef\theparentequation{\theequation}%
7282 \ifdefined\theHequation
7283 \protected@edef\theHparentequation{\theHequation}%
7284 \fi
7285 \fi
7286 \global\c@parentequation\c@equation
7287 \global\c@equation\z@
7288 \let\theequation\eql@subequations@template
7289 \def\theHequation{\theHparentequation.\arabic{equation}}%
7290 }
7291 % \end{macrocode}
7292 %
7293 % \macro{\eql@subequations@close}
7294 % Low-level close the subequations mode.
7295 % If no number has been used, return to the original equation counter,
7296 % otherwise use the value stored in |parentequation|.
7297 % Note that we cannot use |\setcounter| here because the
7298 % \ctanpkg{calc} version would involve actions which are not
7299 % allowed after |\halign| within a display equation:
7300 % \begin{macrocode}
7301 \def\eql@subequations@close{%
7302 \ifnum\c@equation=\z@
7303 \eql@subequations@restorecounter
7304 \else
7305 \global\c@equation\c@parentequation
7306 \fi
7307 }
7308 % \end{macrocode}
7309 %
7310 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7311 % \subsection{Environment}
7312 %
7313 % \macro{\eql@subequations@start}
7314 % Start the subequations environment with optional parameters in |#1|.
7315 % Enter subequations mode and set an anchor for subsequent |\label|'s.
7316 % Manually print the \ctanpkg{showkeys} tag:
7317 % \TODO join with other similar anchor routines
7318 % |\eql@tags@printsubeqlabel|
7319 % \begin{macrocode}
7320 \def\eql@subequations@start{%
7321 \let\eql@tags@container@block\eql@tags@container@clear
7322 \eql@nextopt@process{subequations}%
7323 \eql@subequations@init
7324 \eql@tags@glabel@step
7325 \edef\eql@subequations@currentHref{\eql@tags@glabel}%
7326 \eql@Hy@anchor\eql@subequations@currentHref
7327 \edef\eql@subequations@thepage{\thepage}%
7328 \def\@currentcounter{equation}%
7329 \let\@currentHref\eql@subequations@currentHref
7330 \protected@edef\@currentlabel{\p@equation\theparentequation}%
7331 \eql@tags@container@block
7332 \ifdefined\eql@tags@name
7333 \let\@currentlabelname\eql@tags@name
7334 \else
7335 \let\@currentlabelname\eql@tags@name@generic
7336 \fi
7337 \let\eql@subequations@active\eql@true
7338 \ifdefined\eql@tags@label
7339 \eql@SK@label\eql@tags@label
7340 \fi
7341 \ignorespaces
7342 }
7343 % \end{macrocode}
7344 %
7345 % \macro{\eql@subequations@end}
7346 % End the subequations environment.
7347 % Issue the label if one has been specified and
7348 % an equation number has actually been used.
7349 % Then close subequations mode:
7350 % \TODO how about tag* ?! also within equations!
7351 % \begin{macrocode}
7352 \def\eql@subequations@end{%
7353 \ifnum\c@equation>\z@
7354 \eql@tags@container@block
7355 \ifdefined\eql@tags@label
7356 \begingroup
7357 \def\@currentcounter{equation}%
7358 \let\thepage\eql@subequations@thepage
7359 \let\@currentHref\eql@subequations@currentHref
7360 \protected@edef\@currentlabel{\p@equation\theparentequation}%
7361 \ifdefined\eql@tags@name
7362 \let\@currentlabelname\eql@tags@name
7363 \else
7364 \let\@currentlabelname\eql@tags@name@generic
7365 \fi
7366 \expandafter\eql@label@clean\expandafter{\eql@tags@label}%
7367 \endgroup
7368 \fi
7369 \fi
7370 \eql@subequations@close
7371 }
7372 % \end{macrocode}
7373 %
7374 % \environment{subequations}
7375 % The subequations environment tests for optional parameters
7376 % and passes on to the start and end routines:
7377 % \begin{macrocode}
7378 \newenvironment{eql@subequations}{%
7379 \eql@verbose@info\eql@verbose@msg@enterenv
7380 \eql@subequations@testall\eql@subequations@start%
7381 }{%
7382 \eql@subequations@end
7383 \ignorespacesafterend
7384 \eql@verbose@info\eql@verbose@msg@leaveenv
7385 }
7386 % \end{macrocode}
7387 %
7388 % \TODO describe
7389 % \begin{macrocode}
7390 \def\eql@subequations@testall{\eql@parseopt@env\eql@subequations@testall@parse}
7391 \def\eql@subequations@testall@parse{%
7392 \ifx\eql@parseopt@token[%]
7393 \let\eql@parseopt@next\eql@parseopt@opt
7394 \fi
7395 \ifx\eql@parseopt@token\eql@atxi
7396 \let\eql@parseopt@next\eql@parseopt@label
7397 \fi
7398 \ifx\eql@parseopt@token\eql@atxii
7399 \let\eql@parseopt@next\eql@parseopt@label
7400 \fi
7401 \ifx\eql@parseopt@token\label
7402 \let\eql@parseopt@next\eql@parseopt@end
7403 \fi
7404 }
7405 % \end{macrocode}
7406 %
7407 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7408 % \subsection{Subequation Scheme}
7409 %
7410 % \TODO describe
7411 %
7412 % \begin{macrocode}
7413 \def\eql@numbering@subeq@init{%
7414 \let\eql@save@theequation\theequation
7415 \let\eql@save@theHequation\theHequation
7416 \eql@subequations@init
7417 \let\eql@tags@container@parent\eql@tags@container@block
7418 \let\eql@tags@container@block\eql@tags@container@clear
7419 }
7420 % \end{macrocode}
7421 %
7422 % \TODO describe
7423 % \begin{macrocode}
7424 \def\eql@numbering@subeq@test{%
7425 \ifnum\eql@tagrows@<\tw@
7426 \let\eql@tags@container@block\eql@tags@container@parent
7427 \let\eql@numbering@subeq@use\eql@false
7428 \let\theequation\eql@save@theequation
7429 \let\theHequation\eql@save@theHequation
7430 \eql@subequations@restorecounter
7431 \fi
7432 }
7433 % \end{macrocode}
7434 %
7435 % \TODO describe
7436 % \begin{macrocode}
7437 % \TODO note must not use setcounter here (when calc is loaded)
7438 \def\eql@numbering@subeq@close{%
7439 \eql@subequations@close
7440 }
7441 % \end{macrocode}
7442 %
7443 %
7444 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7445 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7446 % \section{Display Equations Support}
7447 %
7448 % \TODO describe
7449 %
7450 % \begin{macrocode}
7451 \let\eql@display@injectbefore\@undefined
7452 \let\eql@display@injectafter\@undefined
7453 \let\eql@interline@container\@undefined
7454 \def\eql@interline@container@clear{%
7455 \eql@displaybreak@pen@\@MM
7456 \eql@vspaceskip@\z@skip
7457 }
7458 % \end{macrocode}
7459 %
7460 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7461 % \subsection{Display Breaks}
7462 %
7463 % \TODO describe
7464 %
7465 % \macro{\interdisplaylinepenalty}
7466 % \begin{macrocode}
7467 \interdisplaylinepenalty\@M
7468 % \end{macrocode}
7469 %
7470 % \macro{\eql@getdsp@pen}
7471 % \TODO isn't this the opposite order than |\@getpen|?!
7472 % \begin{macrocode}
7473 \def\eql@getdsp@pen#1{%
7474 \ifcase #1\@M \or 9999 \or 6999 \or 2999 \or \z@\fi
7475 }
7476 % \end{macrocode}
7477 %
7478 % \TODO allow a displaybreak before equations
7479 % \begin{macrocode}
7480 \protected\def\eql@displaybreak@default{%
7481 \eql@warning{Invalid use of \string\displaybreak}{}%
7482 \eql@teststaroropt@loose\@gobble\eql@gobbleopt{}}
7483 \eql@amsmath@after{\let\eql@displaybreak@default\displaybreak}
7484 \eql@amsmath@let\displaybreak\eql@displaybreak@default
7485 % \end{macrocode}
7486 %
7487 % \begin{macrocode}
7488 \newcount\eql@displaybreak@pen@
7489 \newcount\eql@displaybreak@prepen@
7490 \newcount\eql@displaybreak@postpen@
7491 % \end{macrocode}
7492 %
7493 % \TODO describe
7494 % \begin{macrocode}
7495 \protected\def\eql@displaybreak{%
7496 \relax
7497 \eql@ampprotecttwo\eql@teststaroropt@tight
7498 \eql@displaybreak@star\eql@displaybreak@level{4}%
7499 }
7500 % \end{macrocode}
7501 %
7502 % \begin{macrocode}
7503 \def\eql@displaybreak@star#1{%
7504 \global\eql@appendexpand\eql@interline@container{%
7505 \eql@displaybreak@pen@\the\numexpr#1\relax\relax}%
7506 }
7507 % \end{macrocode}
7508 %
7509 % \begin{macrocode}
7510 \def\eql@displaybreak@level[#1]{%
7511 \ifnum#1<\z@
7512 \global\eql@append\eql@interline@container{\eql@displaybreak@pen@\@MM}%
7513 \else
7514 \global\eql@appendexpand\eql@interline@container{%
7515 \eql@displaybreak@pen@-\@getpen{#1}\relax}%
7516 \fi
7517 }
7518 % \end{macrocode}
7519 %
7520 % \TODO describe
7521 % \begin{macrocode}
7522 \def\eql@displaybreak@pre#1{%
7523 \ifnum#1<\z@
7524 \eql@displaybreak@prepen@\@MM
7525 \else
7526 \eql@displaybreak@prepen@-\@getpen{#1}\relax
7527 \fi
7528 }
7529 % \end{macrocode}
7530 %
7531 % \TODO describe
7532 % \begin{macrocode}
7533 \def\eql@displaybreak@post#1{%
7534 \ifnum#1<\z@
7535 \eql@displaybreak@postpen@\@MM
7536 \else
7537 \eql@displaybreak@postpen@-\@getpen{#1}\relax
7538 \fi
7539 }
7540 % \end{macrocode}
7541 %
7542 % \TODO describe
7543 % \begin{macrocode}
7544 \def\eql@displaybreak@inter#1{%
7545 \ifnum#1<\z@
7546 \interdisplaylinepenalty\@M
7547 \else
7548 \interdisplaylinepenalty\eql@getdsp@pen{#1}\relax
7549 \fi
7550 }
7551 % \end{macrocode}
7552 %
7553 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7554 % \subsection{Explicit Vertical Space}
7555 %
7556 % \TODO describe
7557 %
7558 % \lskip{\eql@vspaceskip@}
7559 % \begin{macrocode}
7560 \newskip\eql@vspaceskip@
7561 % \end{macrocode}
7562 %
7563 % \begin{macrocode}
7564 \let\eql@vspace@org\vspace
7565 \def\eql@vspace{%
7566 \ifvmode
7567 \expandafter\eql@vspace@immediate
7568 \else
7569 \expandafter\eql@vspace@line
7570 \fi
7571 }
7572 % \end{macrocode}
7573 %
7574 % \TODO |\eql@vspace@addfixedafter| on last line has no effect.
7575 % should apply outside environment
7576 % \begin{macrocode}
7577 \def\eql@vspace@line{%
7578 \eql@ifstar@loose\eql@vspace@addfixedbefore\eql@vspace@add
7579 }
7580 \def\eql@vspace@add#1{%
7581 \global\eql@appendexpand\eql@interline@container{%
7582 \advance\eql@vspaceskip@\the\glueexpr#1\relax\relax}}
7583 \def\eql@vspace@addfixedbefore#1{%
7584 \global\eql@appendexpand\eql@interline@container{%
7585 \noexpand\eql@append\noexpand\eql@display@injectbefore{%
7586 \skip@\the\glueexpr#1\relax\relax
7587 \penalty\@M
7588 \vskip\skip@
7589 \global\advance\eql@line@interline@\skip@
7590 }%
7591 }%
7592 }
7593 \def\eql@vspace@addfixedafter#1{%
7594 \global\eql@appendexpand\eql@interline@container{%
7595 \noexpand\eql@append\noexpand\eql@display@injectafter{%
7596 \dimen@\prevdepth
7597 \hrule\@height\z@
7598 \skip@\the\glueexpr#1\relax\relax
7599 \penalty\@M
7600 \vskip\skip@
7601 \global\advance\eql@line@interline@\skip@
7602 \prevdepth\dimen@
7603 }%
7604 }%
7605 }
7606 % \end{macrocode}
7607 %
7608 % \TODO careful to not expand |\eql@display@container| after measure
7609 % \begin{macrocode}
7610 \def\eql@vspace@immediate{%
7611 \noalign\bgroup
7612 \eql@ifstar@loose\eql@vspace@fixed\eql@vspace@discardable
7613 }
7614 \def\eql@vspace@fixed#1{%
7615 \skip@\glueexpr#1\relax
7616 \ifnum\eql@row@=\@ne
7617 \global\eql@appendexpand\eql@display@container{%
7618 \advance\eql@abovespace@\the\skip@\relax}%
7619 \else\ifnum\eql@row@>\eql@totalrows@
7620 \global\eql@appendexpand\eql@display@container{%
7621 \advance\eql@belowspace@\the\skip@\relax}%
7622 \else
7623 \dimen@\prevdepth
7624 \hrule\@height\z@
7625 \penalty\@M
7626 \vskip\skip@
7627 \global\advance\eql@line@interline@\skip@
7628 \prevdepth\dimen@
7629 \fi\fi
7630 \egroup
7631 }
7632 \def\eql@vspace@discardable#1{%
7633 \skip@\glueexpr#1\relax
7634 \ifnum\eql@row@=\@ne
7635 \global\eql@appendexpand\eql@display@container{%
7636 \advance\eql@abovespace@\the\skip@\relax}%
7637 \else\ifnum\eql@row@>\eql@totalrows@
7638 \global\eql@appendexpand\eql@display@container{%
7639 \advance\eql@belowspace@\the\skip@\relax}%
7640 \else
7641 \vskip\skip@
7642 \global\advance\eql@line@interline@\skip@
7643 \fi\fi
7644 \egroup
7645 }
7646 % \end{macrocode}
7647 %
7648 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7649 % \subsection{Default Vertical Spacing}
7650 %
7651 % \TODO describe
7652 %
7653 % \macro{\eql@strut}
7654 % \macro{\eql@strutbox@}
7655 % Next follows a special internal strut which is supposed to match
7656 % the height and the depth of a normal |\strut| minus
7657 % |\normallineskiplimit| according to M.\ Spivak.
7658 % \begin{macrocode}
7659 \newbox\eql@strutbox@
7660 \def\eql@strut@depth{.3}
7661 \def\eql@strut{\copy\eql@strutbox@}
7662 \let\eql@strut@cell\eql@strut
7663 \let\eql@strut@tag\eql@strut
7664 \def\eql@strut@make{%
7665 \setbox\eql@strutbox@\hbox{%
7666 \@tempdimb\dimexpr
7667 \eql@strut@depth\normalbaselineskip+.5\normallineskiplimit\relax
7668 \@tempdima\dimexpr
7669 \normalbaselineskip-\normallineskiplimit-\@tempdimb\relax
7670 \vrule\@height\@tempdima\@depth\@tempdimb\@width\z@
7671 }
7672 }
7673 \AtBeginDocument{\eql@strut@make}
7674 % \end{macrocode}
7675 %
7676 % \TODO describe
7677 % \TODO uses amsmath |\spread@equation|
7678 % \begin{macrocode}
7679 \def\eql@spread@set{%
7680 \ifdefined\eql@spread@reset
7681 \lineskip\normallineskip
7682 \lineskiplimit\normallineskiplimit
7683 \baselineskip\normalbaselineskip
7684 \fi
7685 \eql@spread@\dimexpr\glueexpr\eql@spread@val\relax
7686 +\normalbaselineskip-\baselineskip\relax
7687 \ifdim\eql@spread@>\z@
7688 \openup\eql@spread@
7689 \ifdefined\spread@equation
7690 \let\spread@equation\@empty
7691 \fi
7692 \fi
7693 }
7694 % \end{macrocode}
7695 %
7696 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7697 % \subsection{Entry and Exit}
7698 %
7699 % \TODO describe
7700 %
7701 % \begin{macrocode}
7702 \let\eql@beamerbasecolor@apply\@empty
7703 \let\eql@beamerbasecolor@avoid\@empty
7704 \AddToHook{package/beamerbasecolor/after}{%
7705 \def\eql@beamerbasecolor@apply{%
7706 \donotcolorouterdisplaymaths
7707 \donotcoloroutermaths
7708 \beamer@setdisplaymathcolor
7709 }%
7710 \def\eql@beamerbasecolor@avoid{\donotcoloroutermaths}%
7711 }
7712 % \end{macrocode}
7713 %
7714 % \lskip{\eql@abovespace@}
7715 % \lskip{\eql@belowspace@}
7716 % \begin{macrocode}
7717 \newskip\eql@abovespace@
7718 \newskip\eql@belowspace@
7719 % \end{macrocode}
7720 %
7721 % \macro{\eql@display@enter}
7722 % \begin{macrocode}
7723 \def\eql@display@enter{%
7724 \if@noskipsec\leavevmode\par\fi
7725 \ifvmode
7726 \eql@prevdepth@\prevdepth
7727 \nointerlineskip
7728 \noindent
7729 \else
7730 \eql@prevdepth@\maxdimen
7731 \fi
7732 \eql@beamerbasecolor@apply
7733 }
7734 % \end{macrocode}
7735 %
7736 % \macro{\eql@display@adjust}
7737 % \begin{macrocode}
7738 \def\eql@display@adjust{%
7739 \ifdefined\eql@display@linewidth
7740 \displaywidth\glueexpr\eql@display@linewidth\relax
7741 \advance\displaywidth-\displayindent
7742 \fi
7743 \ifdefined\eql@display@marginleft
7744 \advance\displaywidth\displayindent
7745 \displayindent\glueexpr\eql@display@marginleft\relax
7746 \advance\displaywidth-\displayindent
7747 \fi
7748 \ifdefined\eql@display@marginright
7749 \advance\displaywidth-\glueexpr\eql@display@marginright\relax
7750 \fi
7751 \ifdim\displaywidth<\z@
7752 \displaywidth\z@
7753 \fi
7754 }
7755 % \end{macrocode}
7756 %
7757 % \macro{\eql@display@init}
7758 % \begin{macrocode}
7759 \def\eql@display@init{%
7760 \let\eql@display@restore\eql@display@restore@active
7761 \let\displaybreak\eql@displaybreak
7762 \let\eql@vspace@org\vspace
7763 \let\vspace\eql@vspace
7764 \let\eqncontrol\eql@control
7765 \let\eql@display@injectbefore\@empty
7766 \let\eql@display@injectafter\@empty
7767 \let\eqnpunct\eql@punct@setnext
7768 \eql@spread@set
7769 \eql@strut@make
7770 \let\eql@frame@cmd\@undefined
7771 }
7772 % \end{macrocode}
7773 %
7774 % \macro{\eql@display@print}
7775 % \begin{macrocode}
7776 \def\eql@display@print{%
7777 \eql@punct@top@set
7778 \let\eql@display@container\@empty
7779 \eql@display@firstavail@\z@
7780 \eql@display@aboveextend@\z@
7781 \eql@display@belowextend@\z@
7782 \global\let\eql@interline@container\eql@interline@container@clear
7783 }
7784 % \end{macrocode}
7785 %
7786 % \macro{\eql@display@halign@init}
7787 % \TODO describe
7788 % \begin{macrocode}
7789 \def\eql@display@halign@init#1{%
7790 \eql@row@\z@
7791 \eql@prevgraf@\prevgraf
7792 \everycr{\noalign{%
7793 \global\advance\eql@row@\@ne
7794 \prevgraf\numexpr\prevgraf+\@ne\relax
7795 #1%
7796 }}%
7797 }
7798 % \end{macrocode}
7799 %
7800 % \TODO how about penalty here? not for entry into display
7801 % \begin{macrocode}
7802 \def\eql@display@halign@start{%
7803 \prevgraf\numexpr\eql@prevgraf@+\@ne\relax
7804 \ifdim\eql@prevdepth@=\maxdimen\else
7805 \prevdepth\eql@prevdepth@
7806 \fi
7807 \ifdim\prevdepth=-\@m\p@\else
7808 \ifdefined\eql@display@height
7809 \skip@\baselineskip
7810 \advance\skip@-\glueexpr\eql@display@height\relax
7811 \advance\skip@-\prevdepth\relax
7812 \ifdim\skip@<\lineskiplimit
7813 \skip@\lineskip
7814 \fi
7815 \advance\skip@-\eql@spread@\relax
7816 \vskip\skip@
7817 \nointerlineskip
7818 \else
7819 \vskip-\eql@spread@\relax
7820 \fi
7821 \fi
7822 }
7823 % \end{macrocode}
7824 %
7825 % \TODO describe
7826 % \begin{macrocode}
7827 \def\eql@display@vspace{%
7828 \advance\abovedisplayskip\eql@abovespace@
7829 \advance\belowdisplayskip\eql@belowspace@
7830 }
7831 % \end{macrocode}
7832 %
7833 % \TODO describe
7834 % \begin{macrocode}
7835 \def\eql@display@vspace@native{%
7836 \advance\abovedisplayskip\eql@abovespace@
7837 \advance\belowdisplayskip\eql@belowspace@
7838 \advance\abovedisplayshortskip\eql@abovespace@
7839 \advance\belowdisplayshortskip\eql@belowspace@
7840 }
7841 % \end{macrocode}
7842 %
7843 % \TODO describe
7844 % \begin{macrocode}
7845 \def\eql@display@penalty{%
7846 \ifnum\eql@displaybreak@postpen@=\@MM\else
7847 \postdisplaypenalty\eql@displaybreak@postpen@
7848 \fi
7849 \ifnum\eql@displaybreak@pen@=\@MM\else
7850 \postdisplaypenalty\eql@displaybreak@pen@
7851 \fi
7852 \ifnum\eql@displaybreak@prepen@=\@MM\else
7853 \predisplaypenalty\eql@displaybreak@prepen@
7854 \fi
7855 }
7856 % \end{macrocode}
7857 %
7858 % \TODO describe
7859 % \TODO issue: |\vspace*{0pt}| has some effect if page is broken here
7860 % \begin{macrocode}
7861 \def\eql@display@halign@end{%
7862 \eql@interline@container
7863 \eql@display@injectbefore
7864 \global\eql@prevgraf@\numexpr\prevgraf+\@ne\relax
7865 \ifdefined\eql@display@depth
7866 \prevdepth\glueexpr\eql@display@depth\relax
7867 \fi
7868 }
7869 % \end{macrocode}
7870 %
7871 % \macro{\eql@display@close}
7872 % \TODO there seems to be an offset of 1em in predisplaysize
7873 % towards actual content, nice.
7874 % \TODO must not use setlength or setcounter when calc is loaded
7875 % \TODO do we actually need penalty adjustments
7876 % in case of paragraphs above or below?
7877 % \begin{macrocode}
7878 \def\eql@display@close{%
7879 \eql@display@container
7880 \ifdim\eql@display@firstavail@<\z@
7881 \eql@display@firstavail@\z@
7882 \fi
7883 \eql@skip@mode@leave@\z@
7884 \ifdim\eql@prevdepth@=\maxdimen
7885 \ifdim\predisplaysize=-\maxdimen
7886 \eql@skip@mode@above@\eql@skip@mode@cont@above\relax
7887 \eql@skip@mode@below@\eql@skip@mode@cont@below\relax
7888 \else
7889 \eql@skip@mode@above@\z@
7890 \eql@skip@mode@below@\z@
7891 \advance\eql@display@firstavail@\displayindent
7892 \ifdim\eql@display@firstavail@>\predisplaysize
7893 \ifcase\eql@skip@mode@short\relax
7894 \or
7895 \eql@skip@mode@above@\@ne
7896 \or
7897 \eql@skip@mode@above@\@ne
7898 \ifnum\eql@totalrows@=\@ne
7899 \eql@skip@mode@below@\@ne
7900 \fi
7901 \or
7902 \eql@skip@mode@above@\@ne
7903 \eql@skip@mode@below@\@ne
7904 \fi
7905 \fi
7906 \fi
7907 \else
7908 \ifdim\eql@prevdepth@=-\@m\p@
7909 \eql@skip@mode@above@\eql@skip@mode@top@above\relax
7910 \eql@skip@mode@below@\eql@skip@mode@top@below\relax
7911 \else
7912 \eql@skip@mode@above@\eql@skip@mode@par@above\relax
7913 \eql@skip@mode@below@\eql@skip@mode@par@below\relax
7914 \fi
7915 \fi
7916 \ifcase\eql@skip@mode@above@
7917 \or\or\or
7918 \predisplaypenalty\z@
7919 \or
7920 \predisplaypenalty\z@
7921 \fi
7922 \ifcase\eql@skip@mode@below@
7923 \or\or\or
7924 \eql@skip@mode@leave@\@ne
7925 \or
7926 \eql@skip@mode@leave@\tw@
7927 \fi
7928 \ifdefined\eql@skip@force@above
7929 \eql@skip@mode@above@\eql@skip@force@above\relax
7930 \fi
7931 \ifdefined\eql@skip@force@below
7932 \eql@skip@mode@below@\eql@skip@force@below\relax
7933 \fi
7934 \ifdefined\eql@skip@force@leave
7935 \eql@skip@mode@leave@\eql@skip@force@leave\relax
7936 \fi
7937 \ifnum\eql@skip@mode@leave@>\z@
7938 \postdisplaypenalty\z@
7939 \fi
7940 \ifcase\eql@skip@mode@above@
7941 \abovedisplayskip\glueexpr\eql@skip@long@above\relax
7942 \or
7943 \abovedisplayskip\glueexpr\eql@skip@short@above\relax
7944 \or
7945 \abovedisplayskip\glueexpr\eql@skip@cont@above\relax
7946 \or
7947 \abovedisplayskip\glueexpr\eql@skip@par@above\relax
7948 \or
7949 \abovedisplayskip\glueexpr\eql@skip@top@above\relax
7950 \or
7951 \abovedisplayskip\z@skip
7952 \or
7953 \abovedisplayskip\glueexpr\eql@skip@med@above\relax
7954 \or
7955 \abovedisplayskip\glueexpr\eql@skip@custom@above\relax
7956 \fi
7957 \ifcase\eql@skip@mode@below@
7958 \belowdisplayskip\glueexpr\eql@skip@long@below\relax
7959 \or
7960 \belowdisplayskip\glueexpr\eql@skip@short@below\relax
7961 \or
7962 \belowdisplayskip\glueexpr\eql@skip@cont@below\relax
7963 \or
7964 \belowdisplayskip\glueexpr\eql@skip@par@below\relax
7965 \or
7966 \belowdisplayskip\glueexpr\eql@skip@top@below\relax
7967 \or
7968 \belowdisplayskip\z@skip
7969 \or
7970 \belowdisplayskip\glueexpr\eql@skip@med@below\relax
7971 \or
7972 \belowdisplayskip\glueexpr\eql@skip@custom@below\relax
7973 \fi
7974 \global\eql@skip@mode@leave@\eql@skip@mode@leave@
7975 \eql@interline@container
7976 \advance\eql@belowspace@\eql@vspaceskip@
7977 \eql@display@penalty
7978 \eql@display@vspace
7979 \skip@\glueexpr\eql@skip@tag@above\relax
7980 \ifdim\skip@>\abovedisplayskip
7981 \skip@\abovedisplayskip
7982 \fi
7983 \advance\abovedisplayskip-\eql@display@aboveextend@\relax
7984 \ifdim\abovedisplayskip<\skip@
7985 \abovedisplayskip\skip@
7986 \fi
7987 \skip@\glueexpr\eql@skip@tag@below\relax
7988 \ifdim\skip@>\belowdisplayskip
7989 \skip@\belowdisplayskip
7990 \fi
7991 \ifdim\eql@display@belowextend@>\z@
7992 \advance\belowdisplayskip-\eql@display@belowextend@\relax
7993 \ifdim\belowdisplayskip<\skip@
7994 \belowdisplayskip\skip@
7995 \fi
7996 \fi
7997 }
7998 % \end{macrocode}
7999 %
8000 % \TODO describe
8001 % \begin{macrocode}
8002 \def\eql@display@leave{%
8003 \prevgraf\eql@prevgraf@
8004 \ifcase\eql@skip@mode@leave@
8005 \or
8006 \endgraf
8007 \or
8008 \endgraf
8009 \prevdepth-\@m\p@
8010 \fi
8011 }
8012 % \end{macrocode}
8013 %
8014 % \TODO describe
8015 % \begin{macrocode}
8016 \def\eql@display@nest{%
8017 \let\displaybreak\eql@displaybreak@default
8018 \let\intertext\eql@intertext@default
8019 \let\vspace\eql@vspace@org
8020 }
8021 % \end{macrocode}
8022 %
8023 % \TODO describe
8024 % \TODO box version?! (but also consider nesting)
8025 % \begin{macrocode}
8026 \def\eql@display@restore@active{%
8027 \let\label\eql@label@org
8028 \let\tag\eql@tag@default
8029 \let\raisetag\eql@raisetag@default
8030 \let\displaybreak\eql@displaybreak@default
8031 \let\intertext\eql@intertext@default
8032 \let\vspace\eql@vspace@org
8033 \ifdefined\eql@amp@mode
8034 \let\&\eql@amp@org
8035 \fi
8036 \let\eqnpunct\eql@punct@addopt
8037 \let\eql@punct@block\@undefined
8038 \let\eql@display@restore\@empty
8039 }
8040 % \end{macrocode}
8041 %
8042 % \TODO describe
8043 % \begin{macrocode}
8044 \let\eql@display@restore\@empty
8045 \eql@append\@arrayparboxrestore{%
8046 \eql@display@restore
8047 \ifdefined\eql@ampproof@active
8048 \eql@amprevert
8049 \fi
8050 \@displayfalse
8051 }
8052 % \end{macrocode}
8053 %
8054 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8055 % \subsection{Stack}
8056 %
8057 % \TODO describe
8058 % \TODO for each global variable declare global nature at its definition!
8059 % \TODO we must be consistent about global variables vs local variables
8060 % global variables need to be saved at every level where they may be modified
8061 % (even if modified only locally)
8062 %
8063 % \begin{macrocode}
8064 \def\eql@stack@enable{%
8065 \let\eql@stack@save@equations\eql@stack@save@equations@
8066 \let\eql@stack@save@box\eql@stack@save@box@
8067 }
8068 % \end{macrocode}
8069 %
8070 % \TODO describe
8071 % \begin{macrocode}
8072 \let\eql@stack@save@equations\eql@stack@enable
8073 \let\eql@stack@save@box\eql@stack@enable
8074 \let\eql@stack@restore\@empty
8075 % \end{macrocode}
8076 %
8077 % \TODO describe
8078 % \begin{macrocode}
8079 \def\eql@stack@save@reg#1{\global#1\the#1\relax}
8080 \def\eql@stack@save@let#1#2{\global\let\noexpand#2\noexpand#1}
8081 % \end{macrocode}
8082 %
8083 % \TODO further global variables:
8084 % global registers: |\eql@nextopt|, |\eql@tags@glabel@|
8085 % used locally without possibility of change between setting and retrieving:
8086 % |\eql@prevgraf@|, |\eql@skip@mode@leave@|,
8087 % |\eql@shape@lastrow|, |\eql@frame@prevcmd|
8088 % \TODO to be reviewed: |\eql@intertext@after|, |\eql@intertext@opt|
8089 % \TODO describe
8090 % \begin{macrocode}
8091 \def\eql@stack@save@equations@{%
8092 \let\eql@stack@numbering@eqnswinit\eql@numbering@eqnswinit
8093 \let\eql@stack@cell@container\eql@cell@container
8094 \let\eql@stack@tags@container\eql@tags@container
8095 \let\eql@stack@interline@container\eql@interline@container
8096 \let\eql@stack@dimensions@tab\eql@dimensions@tab
8097 \let\eql@stack@block@container\eql@display@container
8098 \let\eql@stack@punct@top\eql@punct@top
8099 \edef\eql@stack@restore{%
8100 \global\if@eqnsw\noexpand\@eqnswtrue\else\noexpand\@eqnswfalse\fi
8101 \eql@stack@save@let\eql@stack@numbering@eqnswinit\eql@numbering@eqnswinit
8102 \eql@stack@save@let\eql@stack@cell@container\eql@cell@container
8103 \eql@stack@save@let\eql@stack@tags@container\eql@tags@container
8104 \eql@stack@save@let\eql@stack@interline@container\eql@interline@container
8105 \eql@stack@save@let\eql@stack@dimensions@tab\eql@dimensions@tab
8106 \eql@stack@save@let\eql@stack@block@container\eql@display@container
8107 \eql@stack@save@let\eql@stack@punct@top\eql@punct@top
8108 \eql@stack@save@reg\eql@column@
8109 \eql@stack@save@reg\eql@totalcolumns@
8110 \eql@stack@save@reg\eql@line@avail@
8111 \eql@stack@save@reg\eql@line@pos@
8112 \eql@stack@save@reg\eql@line@width@
8113 \eql@stack@save@reg\eql@line@depth@
8114 \eql@stack@save@reg\eql@line@height@
8115 \eql@stack@save@reg\eql@line@prevdepth@
8116 \eql@stack@save@reg\eql@line@interline@
8117 \eql@stack@save@reg\eql@totalheight@
8118 \eql@stack@save@reg\eql@tagwidth@max@
8119 \eql@stack@save@reg\eql@tagpos@row@
8120 \eql@stack@save@reg\eql@row@
8121 \eql@stack@save@reg\eql@tagrows@
8122 }%
8123 }
8124 % \end{macrocode}
8125 %
8126 % \TODO describe
8127 % \begin{macrocode}
8128 \def\eql@stack@save@box@{%
8129 \let\eql@stack@cell@container\eql@cell@container
8130 \edef\eql@stack@restore{%
8131 \eql@stack@save@let\eql@stack@cell@container\eql@cell@container
8132 \eql@stack@save@reg\eql@row@
8133 }%
8134 }
8135 % \end{macrocode}
8136 %
8137 %
8138 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8139 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8140 % \section{Multi-Line Support}
8141 %
8142 % \TODO describe
8143 %
8144 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8145 % \subsection{Measure Support}
8146 %
8147 % \TODO describe
8148 %
8149 % \begin{macrocode}
8150 \def\eql@measure@init#1#2{%
8151 \eql@dimensions@reset
8152 \let\eql@display@container\@empty
8153 \eql@numbering@measure@init
8154 \eql@row@\z@
8155 \eql@totalheight@\z@
8156 \eql@totalrows@\@M
8157 \eql@line@prevdepth@-\@m\p@
8158 \eql@line@interline@\z@
8159 \tabskip\z@skip
8160 \everycr{\noalign{%
8161 \global\advance\eql@row@\@ne
8162 #1%
8163 }}%
8164 \eql@punct@top@set
8165 \global\let\eql@interline@container\eql@interline@container@clear
8166 \eql@measure@savestate
8167 \eql@multi@cr@let{#2}%
8168 }
8169 % \end{macrocode}
8170 %
8171 % \TODO describe
8172 % \begin{macrocode}
8173 \def\eql@measure@tag{%
8174 \eql@tagwidth@\z@
8175 \ifdefined\eql@numbering@multi
8176 \if@eqnsw
8177 \eql@tags@container
8178 \eql@tagbox@make\eql@composetag@measure
8179 \ifdefined\eql@tagpos@reserve\else
8180 \eql@tagwidth@\z@
8181 \fi
8182 \fi
8183 \fi
8184 }
8185 % \end{macrocode}
8186 %
8187 % \TODO describe
8188 % \begin{macrocode}
8189 \def\eql@measure@endrow{%
8190 \ifdim\eql@line@prevdepth@=-\@m\p@\else
8191 \dimen@\dimexpr\baselineskip-\eql@line@height@-\eql@line@prevdepth@\relax
8192 \ifdim\dimen@<\lineskiplimit
8193 \dimen@\lineskip
8194 \fi
8195 \advance\eql@line@interline@\dimen@
8196 \fi
8197 \eql@dimensions@endrow
8198 \ifdim\eql@tagwidth@>\eql@tagwidth@max@
8199 \global\eql@tagwidth@max@\eql@tagwidth@
8200 \fi
8201 \ifdim\eql@tagwidth@>\z@
8202 \global\advance\eql@tagrows@\@ne
8203 \fi
8204 \global\advance\eql@totalheight@\dimexpr
8205 \eql@line@interline@+\eql@line@height@+\eql@line@depth@
8206 \global\eql@line@interline@\z@
8207 \global\eql@line@prevdepth@\eql@line@depth@
8208 }
8209 % \end{macrocode}
8210 %
8211 % \TODO describe
8212 % \begin{macrocode}
8213 \def\eql@measure@close{%
8214 \advance\eql@row@-\tw@
8215 \eql@totalrows@\eql@row@
8216 \ifnum\eql@totalrows@>\z@
8217 \eql@dimensions@get\@ne
8218 \eql@topheight@\dimexpr\eql@line@height@+\eql@line@interline@\relax
8219 \eql@dimensions@get\eql@totalrows@
8220 \eql@bottomdepth@\eql@line@depth@
8221 \fi
8222 \eql@numbering@measure@blocktag
8223 \begingroup
8224 \eql@tags@container
8225 \if@eqnsw
8226 \eql@tagbox@make\eql@composetag@measure
8227 \ifdefined\eql@tagpos@reserve\else
8228 \eql@tagwidth@\z@
8229 \fi
8230 \eql@dimensions@saveblocktag
8231 \else
8232 \eql@dimensions@savenoblocktag
8233 \eql@numbering@warnunused
8234 \fi
8235 \endgroup
8236 \eql@dimensions@get\z@
8237 \eql@measure@restorestate
8238 }
8239 % \end{macrocode}
8240 %
8241 % \macro{\eql@measure@restorestate}
8242 % \macro{\eql@measure@savestate}
8243 % \begin{macrocode}
8244 \let\eql@measure@restorestate\@empty
8245 \def\eql@measure@savestate{%
8246 \begingroup
8247 \def\@elt##1{%
8248 \global\csname c@##1\endcsname\the\csname c@##1\endcsname}%
8249 \global\edef\@gtempa{\cl@@ckpt}%
8250 \endgroup
8251 \let\eql@measure@restorestate\@gtempa
8252 }
8253 % \end{macrocode}
8254 %
8255 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8256 % \subsection{Line Breaks}
8257 %
8258 % \TODO describe
8259 %
8260 % \macro{\eql@multi@cr}
8261 % \begin{macrocode}
8262 \def\eql@multi@cr{%
8263 \let\eql@punct@term\eql@false
8264 \let\eql@class@rel@composed\@empty
8265 \eql@ampprotect\eql@multi@cr@test\eql@multi@cr@process}
8266 % \end{macrocode}
8267 %
8268 % \TODO describe
8269 % \begin{macrocode}
8270 \def\eql@multi@cr@test@setopt{%
8271 \let\eql@multi@cr@test\eql@multi@cr@testopt}
8272 \def\eql@multi@cr@test@setall{%
8273 \let\eql@multi@cr@test\eql@multi@cr@testall}
8274 % \end{macrocode}
8275 %
8276 % \macro{\eql@multi@cr@testopt}
8277 % \TODO describe
8278 % \begin{macrocode}
8279 \def\eql@multi@cr@testopt#1{\eql@teststaropt@tight
8280 {\eql@displaybreak@star\@M\eql@multi@cr@testopt@set{#1}}%
8281 {\eql@multi@cr@testopt@set{#1}}{0pt}}
8282 \def\eql@multi@cr@testopt@set#1[#2]{\eql@vspace@add{#2}#1}
8283 % \end{macrocode}
8284 %
8285 % \macro{\eql@multi@cr@testall}
8286 % \macro{\eql@multi@cr@testall@parse}
8287 % \TODO describe
8288 % \begin{macrocode}
8289 \def\eql@multi@cr@testall{\eql@parseopt@cr\eql@multi@cr@testall@parse}
8290 \def\eql@multi@cr@testall@parse{%
8291 \ifx\eql@parseopt@token[%
8292 \let\eql@parseopt@next\eql@multi@cr@parse@vspace
8293 \fi
8294 \ifx\eql@parseopt@token*%
8295 \let\eql@parseopt@next\eql@multi@cr@parse@star
8296 \fi
8297 \ifx\eql@parseopt@token.%
8298 \let\eql@parseopt@next\eql@parseopt@punctpass
8299 \fi
8300 \ifx\eql@parseopt@token,%
8301 \let\eql@parseopt@next\eql@parseopt@punctpass
8302 \fi
8303 \ifx\eql@parseopt@token~%
8304 \let\eql@parseopt@next\eql@parseopt@punctpass
8305 \fi
8306 \ifx\eql@parseopt@token`%
8307 \let\eql@parseopt@next\eql@parseopt@punctnext
8308 \fi
8309 \ifx\eql@parseopt@token!%
8310 \let\eql@parseopt@next\eql@parseopt@punctterm
8311 \fi
8312 \ifx\eql@parseopt@token/%
8313 \let\eql@parseopt@next\eql@multi@cr@parse@break
8314 \fi
8315 \ifx\eql@parseopt@token=%
8316 \let\eql@parseopt@next\eql@parseopt@relsymb
8317 \fi
8318 \ifx\eql@parseopt@token;%
8319 \let\eql@parseopt@next\eql@parseopt@relcont
8320 \fi
8321 \ifx\eql@parseopt@token:%
8322 \let\eql@parseopt@next\eql@parseopt@relstart
8323 \fi
8324 \ifx\eql@parseopt@token|%
8325 \let\eql@parseopt@next\eql@parseopt@relord
8326 \fi
8327 \ifx\eql@parseopt@token?%
8328 \let\eql@parseopt@next\eql@multi@cr@parse@rel
8329 \fi
8330 \ifx\eql@parseopt@token&%
8331 \let\eql@parseopt@next\eql@parseopt@end
8332 \fi
8333 }
8334 \def\eql@multi@cr@parse@vspace[#1]{\eql@vspace@add{#1}\eql@parseopt@peek}
8335 \def\eql@multi@cr@parse@star#1{\eql@displaybreak@star\@M\eql@parseopt@peek}
8336 \def\eql@multi@cr@parse@break{\numbernext\eql@parseopt@punctclear}
8337 \def\eql@multi@cr@parse@rel#1#2{%
8338 \def\eql@tmp{#2}%
8339 \ifx\eql@tmp\eql@relax\else
8340 \ifdefined\eql@punct@next\else
8341 \eql@punct@next@clear
8342 \fi
8343 \ifdefined\eql@multi@cr@relnext\numbernext\fi
8344 \fi
8345 \ifdefined\eql@multi@linesmode
8346 \ifx\eql@tmp\@empty
8347 \def\eql@class@rel@composed{\eql@shape@cont}%
8348 \else
8349 \def\eql@class@rel@composed{\eql@shape@rel#2}%
8350 \fi
8351 \else
8352 \def\eql@class@rel@composed{\eql@class@rel@make{#2}}%
8353 \fi
8354 \eql@parseopt@end}
8355 % \end{macrocode}
8356 %
8357 % \macro{\eql@multi@cr@process}
8358 % \begin{macrocode}
8359 \def\eql@multi@cr@process{%
8360 \ifdefined\eql@punct@term\eql@punct@apply@top\fi
8361 \edef\eql@tmp{%
8362 \unexpanded{%
8363 \eql@multi@endline
8364 \cr
8365 \eql@multi@cr@interline
8366 }%
8367 \unexpanded\expandafter{\eql@class@rel@composed}%
8368 }%
8369 \eql@tmp
8370 }
8371 % \end{macrocode}
8372 %
8373 % \begin{macrocode}
8374 \def\eql@multi@cr@interline{%
8375 \noalign{%
8376 \eql@interline@container
8377 \eql@display@injectbefore
8378 \ifnum\eql@displaybreak@pen@=\@MM
8379 \penalty\interdisplaylinepenalty
8380 \else
8381 \penalty\eql@displaybreak@pen@
8382 \fi
8383 \vskip\eql@vspaceskip@
8384 \global\advance\eql@line@interline@\eql@vspaceskip@
8385 \eql@display@injectafter
8386 \global\let\eql@interline@container\eql@interline@container@clear
8387 }%
8388 }
8389 % \end{macrocode}
8390 %
8391 % \macro{\eql@multi@cr@let}
8392 % \begin{macrocode}
8393 \def\eql@multi@cr@let#1{%
8394 \let\\\eql@multi@cr
8395 \let\eql@multi@endline#1%
8396 }
8397 % \end{macrocode}
8398 %
8399 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8400 % \subsection{Intertext}
8401 %
8402 % \TODO describe
8403 %
8404 % \TODO revert in everymath?
8405 % \begin{macrocode}
8406 \def\eql@intertext@default{\eql@error{Invalid use of \string\intertext}}
8407 \eql@amsmath@let\intertext\eql@intertext@default
8408 % \end{macrocode}
8409 %
8410 % \TODO why does it fail in measuring? total width?!
8411 % determine total width otherwise!?
8412 % \begin{macrocode}
8413 \def\eql@intertext@process{%
8414 \eql@multi@endline
8415 \cr
8416 \ifmeasuring@
8417 \expandafter\@gobble
8418 \else
8419 \expandafter\eql@intertext@print
8420 \fi
8421 }
8422 % \end{macrocode}
8423 %
8424 % \TODO describe
8425 % \TODO prevdepth
8426 % \TODO does this have to be in a vbox?
8427 % \TODO vskip and penalty opposite order
8428 % \TODO can we handle short? certainly needs two passes
8429 % \begin{macrocode}
8430 \def\eql@intertext@print#1{%
8431 \noalign{%
8432 \eql@display@halign@end
8433 \let\eql@skip@force@below\z@
8434 \let\eql@skip@force@above\z@
8435 \eql@setkeys{intertext}\eql@intertext@opt
8436 \openup-\eql@spread@
8437 \penalty\postdisplaypenalty
8438 \ifcase\eql@skip@force@below\relax
8439 \advance\eql@vspaceskip@\glueexpr\eql@skip@long@below\relax
8440 \or
8441 \advance\eql@vspaceskip@\glueexpr\eql@skip@short@below\relax
8442 \or
8443 \advance\eql@vspaceskip@\glueexpr\eql@skip@cont@below\relax
8444 \or
8445 \advance\eql@vspaceskip@\glueexpr\eql@skip@par@below\relax
8446 \or
8447 \advance\eql@vspaceskip@\glueexpr\eql@skip@top@below\relax
8448 \or
8449 \advance\eql@vspaceskip@\z@skip
8450 \or
8451 \advance\eql@vspaceskip@\glueexpr\eql@skip@med@below\relax
8452 \or
8453 \advance\eql@vspaceskip@\glueexpr\eql@skip@custom@below\relax
8454 \fi
8455 \vskip\eql@vspaceskip@
8456 \global\let\eql@interline@container\eql@interline@container@clear
8457 \vbox{%
8458 \@parboxrestore
8459 \ifdim
8460 \ifdim\@totalleftmargin=\z@\linewidth\else-\maxdimen\fi=\columnwidth
8461 \else
8462 \parshape\@ne
8463 \@totalleftmargin\linewidth
8464 \fi
8465 \noindent
8466 \prevgraf\eql@prevgraf@
8467 \ignorespaces
8468 #1%
8469 \par
8470 \global\eql@prevgraf@\prevgraf
8471 }%
8472 \penalty\predisplaypenalty
8473 \ifcase\eql@skip@force@above\relax
8474 \vskip\glueexpr\eql@skip@long@above\relax
8475 \or
8476 \vskip\glueexpr\eql@skip@short@above\relax
8477 \or
8478 \vskip\glueexpr\eql@skip@cont@above\relax
8479 \or
8480 \vskip\glueexpr\eql@skip@par@above\relax
8481 \or
8482 \vskip\glueexpr\eql@skip@top@above\relax
8483 \or
8484 \vskip\z@skip
8485 \or
8486 \vskip\glueexpr\eql@skip@med@above\relax
8487 \or
8488 \vskip\glueexpr\eql@skip@custom@above\relax
8489 \fi
8490 % \eql@prevdepth@\maxdimen
8491 \eql@prevdepth@\z@
8492 \eql@display@halign@start
8493 }
8494 }
8495 % \end{macrocode}
8496 %
8497 % \TODO describe
8498 % \begin{macrocode}
8499 \newenvironment{eql@intertext}{%
8500 \eql@testopt@tight\eql@intertext@{}%
8501 }{%
8502 \aftergroup\eql@intertext@after
8503 \ignorespacesafterend
8504 }
8505 % \end{macrocode}
8506 %
8507 % \TODO describe
8508 % \begin{macrocode}
8509 \def\eql@intertext@env{intertext}
8510 \def\eql@intertext@[#1]{%
8511 \global\def\eql@intertext@opt{#1}%
8512 \ifx\@currenvir\eql@intertext@env
8513 \def\eql@scan@call{\eql@intertext@inject\eql@scan@end}%
8514 \expandafter\eql@scan@env
8515 \else
8516 \expandafter\eql@intertext@process
8517 \fi
8518 }
8519 % \end{macrocode}
8520 %
8521 % \TODO describe
8522 % \begin{macrocode}
8523 \def\eql@intertext@inject{%
8524 \global\edef\eql@intertext@after{%
8525 \noexpand\eql@intertext@process{%
8526 \ifx\eql@scan@body\eql@scan@body@dump
8527 \eql@scan@body@dump
8528 \else
8529 \noexpand\scantokens{\eql@scan@body@dump}%
8530 \fi
8531 }%
8532 }%
8533 }
8534 % \end{macrocode}
8535 %
8536 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8537 % \subsection{Line Marks}
8538 %
8539 % \TODO describe
8540 %
8541 % \begin{macrocode}
8542 \def\eql@markline@pos@below{below}
8543 \def\eql@markline@pos@bottom{bottom}
8544 \def\eql@markline@pos@baseline{baseline}
8545 \let\eql@markline@pos\eql@markline@pos@baseline
8546 \let\eql@markline@shift\z@
8547 \def\eql@markline@qed{\ifdefined\qedsymbol\qedsymbol\else QED\fi}
8548 \def\eql@markline@symbol{}
8549 % \end{macrocode}
8550 %
8551 % \TODO describe
8552 % \begin{macrocode}
8553 \def\eql@markline@select#1{%
8554 \let\eql@markline@shift\z@
8555 \eql@setkeys{markline}{#1}%
8556 \eql@markline@print
8557 }
8558 % \end{macrocode}
8559 %
8560 % \TODO describe
8561 % \begin{macrocode}
8562 \def\eql@markline@print{%
8563 \dimen@\dimexpr\eql@markline@shift\relax
8564 \ifx\eql@markline@pos\eql@markline@pos@below
8565 \ifdim\dimen@=\z@\else
8566 \penalty\@M
8567 \vskip-\dimen@
8568 \fi
8569 \nointerlineskip
8570 \penalty\@M
8571 \vbox{\hfill\hbox{\eql@markline@symbol}}%
8572 \else
8573 \ifx\eql@markline@pos\eql@markline@pos@baseline
8574 \advance\dimen@\prevdepth
8575 \fi
8576 \setbox\z@\hbox{\raise\dimen@\hbox{\eql@markline@symbol}}%
8577 \dimen@\prevdepth
8578 \ht\z@\z@
8579 \dp\z@\z@
8580 \nointerlineskip
8581 \penalty\@M
8582 \vbox{\hfill\box\z@}%
8583 \prevdepth\dimen@
8584 \fi
8585 }
8586 % \end{macrocode}
8587 %
8588 % \TODO describe
8589 % \begin{macrocode}
8590 \def\eql@markline@inject#1{%
8591 \let\eql@markline@push\eql@false
8592 \ifx\eql@markline@pos\eql@markline@pos@below\else
8593 \ifdefined\eql@tagsleft\else
8594 \ifx\eql@equations@main\eql@multi@main
8595 \ifdefined\eql@numbering@multi
8596 \if@eqnsw
8597 \let\eql@markline@push\eql@true
8598 \fi
8599 \else
8600 \ifnum\eql@row@=\eql@tagpos@row@
8601 \let\eql@markline@push\eql@true
8602 \fi
8603 \fi
8604 \else
8605 \if@eqnsw
8606 \let\eql@markline@push\eql@true
8607 \fi
8608 \fi
8609 \fi
8610 \fi
8611 \ifdefined\eql@markline@push
8612 \global\eql@append\eql@interline@container{%
8613 \eql@append\eql@display@injectbefore{\eql@markline@select{push,#1}}}%
8614 \else
8615 \global\eql@append\eql@interline@container{%
8616 \eql@append\eql@display@injectbefore{\eql@markline@select{#1}}}%
8617 \fi
8618 }
8619 % \end{macrocode}
8620 %
8621 % \TODO describe
8622 % \begin{macrocode}
8623 \def\eql@markline@amsthm@opt[#1]{\eql@markline@inject{qed,#1}}
8624 \def\eql@markline@amsthm@staropt[#1]{\eql@markline@inject{qed,push,#1}}
8625 \def\eql@markline@amsthm@qed{\eql@teststaropt@tight
8626 \eql@markline@amsthm@staropt\eql@markline@amsthm@opt{}}
8627 \def\eql@markline@amsthm@register#1{\eql@letcs{#1@qed}\eql@markline@amsthm@qed}
8628 \def\eql@markline@amsthm@move#1#2{%
8629 \AddToHook{package/amsthm/after}{%
8630 \eql@letcs{#1@qed\expandafter}\csname#2@qed\endcsname}}
8631 % \end{macrocode}
8632 %
8633 %
8634 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8635 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8636 % \section{Column Placement}
8637 %
8638 % \TODO describe
8639 %
8640 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8641 % \subsection{Supporting Definitions}
8642 %
8643 % \ldimen{\eql@shape@pos@}
8644 % \ldimen{\eql@shape@amount@}
8645 % The registers |\eql@shape@pos@| and |\eql@shape@amount@|
8646 % specify the currently selected horizontal alignment
8647 % (|0| for left, |1| for center, |2| for right)
8648 % and the indentation amount, respectively:
8649 % \begin{macrocode}
8650 \newcount\eql@shape@pos@
8651 \newdimen\eql@shape@amount@
8652 \let\eql@shape@lastrow\eql@false
8653 % \end{macrocode}
8654 %
8655 % \ldimen{\eql@marginleft@}
8656 % \ldimen{\eql@marginleft@min@}
8657 % \ldimen{\eql@marginright@}
8658 % \ldimen{\eql@centeroffset@}
8659 % The registers |\eql@marginleft@| and |\eql@marginright@|
8660 % store the intended left and right margin for the equation lines:
8661 % \TODO update
8662 % \begin{macrocode}
8663 \newdimen\eql@marginleft@
8664 \newdimen\eql@marginright@
8665 \newdimen\eql@marginleft@min@
8666 \newdimen\eql@centeroffset@
8667 % \end{macrocode}
8668 %
8669 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8670 % \subsection{Shape Schemes}
8671 %
8672 % The horizontal alignment of each line is specified by
8673 % a shape scheme.
8674 %
8675 % \macro{\eql@shape@tab@...}
8676 % We select the scheme through a |\csname| selector
8677 % with the following names:
8678 % \begin{macrocode}
8679 \def\eql@shape@tab@default{default}
8680 \def\eql@shape@tab@left{left}
8681 \def\eql@shape@tab@center{center}
8682 \def\eql@shape@tab@right{right}
8683 \def\eql@shape@tab@first{first}
8684 \def\eql@shape@tab@hanging{hanging}
8685 \def\eql@shape@tab@steps{steps}
8686 % \end{macrocode}
8687 %
8688 % For convenience, we add further alias names for the schemes:
8689 % \begin{macrocode}
8690 \let\eql@shape@tab@def\eql@shape@tab@default
8691 \let\eql@shape@tab@\eql@shape@tab@default
8692 \let\eql@shape@tab@l\eql@shape@tab@left
8693 \let\eql@shape@tab@c\eql@shape@tab@center
8694 \let\eql@shape@tab@r\eql@shape@tab@right
8695 \let\eql@shape@tab@rc\eql@shape@tab@first
8696 \let\eql@shape@tab@indent\eql@shape@tab@first
8697 \let\eql@shape@tab@hang\eql@shape@tab@hanging
8698 \let\eql@shape@tab@lc\eql@shape@tab@hanging
8699 \let\eql@shape@tab@outdent\eql@shape@tab@hanging
8700 \let\eql@shape@tab@lcr\eql@shape@tab@steps
8701 % \end{macrocode}
8702 %
8703 % \macro{\eql@shape@mode}
8704 % The currently selected scheme is stored in |\eql@shape@mode|.
8705 % It it set to |default|:
8706 % \begin{macrocode}
8707 \let\eql@shape@mode\eql@shape@tab@default
8708 % \end{macrocode}
8709 %
8710 % \macro{\eql@shape@set}
8711 % Set the scheme via the translation table:
8712 % \begin{macrocode}
8713 \def\eql@shape@set#1{%
8714 \ifcsname eql@shape@tab@#1\endcsname
8715 \expandafter\let\expandafter\eql@shape@mode
8716 \csname eql@shape@tab@#1\endcsname
8717 \else
8718 \eql@error{shape '#1' unknown: setting to default}%
8719 \let\eql@shape@mode\eql@shape@tab@default
8720 \fi
8721 }
8722 % \end{macrocode}
8723 %
8724 % \macro{\eql@shape@layoutcenter@...}
8725 % \macro{\eql@shape@layoutleft@...}
8726 % Define the uniform shape schemes |left|, |center|, |right| and |default|
8727 % for the central and left alignment layout.
8728 % The scheme functions determine the desired alignment and indentation
8729 % for the current row:
8730 % \begin{macrocode}
8731 \def\eql@shape@layoutcenter@left{\eql@shape@pos@\z@\eql@shape@amount@\z@}
8732 \def\eql@shape@layoutcenter@center{\eql@shape@pos@\@ne\eql@shape@amount@\z@}
8733 \def\eql@shape@layoutcenter@right{\eql@shape@pos@\tw@\eql@shape@amount@\z@}
8734 \let\eql@shape@layoutcenter@default\eql@shape@layoutcenter@center
8735 \def\eql@shape@layoutleft@left{\eql@shape@pos@\z@\eql@shape@amount@\z@}
8736 \def\eql@shape@layoutleft@center{\eql@shape@pos@\@ne\eql@shape@amount@\z@}
8737 \def\eql@shape@layoutleft@right{\eql@shape@pos@\tw@\eql@shape@amount@\z@}
8738 \let\eql@shape@layoutleft@default\eql@shape@layoutleft@left
8739 % \end{macrocode}
8740 %
8741 % The |first| scheme implements left alignment with
8742 % indentation for the first line (unless there is only one line):
8743 % \begin{macrocode}
8744 \def\eql@shape@layoutcenter@first{%
8745 \eql@shape@pos@\z@
8746 \eql@shape@amount@\z@
8747 \ifnum\eql@totalrows@>\@ne
8748 \ifnum\eql@row@=\@ne
8749 \eql@shape@amount@\eql@indent@
8750 \fi
8751 \fi
8752 }
8753 \def\eql@shape@layoutleft@first{%
8754 \eql@shape@pos@\z@
8755 \eql@shape@amount@\z@
8756 \ifnum\eql@totalrows@>\@ne
8757 \ifnum\eql@row@=\@ne
8758 \eql@shape@amount@\eql@indent@
8759 \fi
8760 \fi
8761 }
8762 % \end{macrocode}
8763 %
8764 % The |hanging| scheme implements left alignment with
8765 % hanging indentation for the first line (unless there is only one line).
8766 % In centeral alignment layout all but the first line are indented
8767 % while in left aligned layout the first line has negative indentation:
8768 % \begin{macrocode}
8769 \def\eql@shape@layoutcenter@hanging{%
8770 \eql@shape@pos@\z@
8771 \eql@shape@amount@\eql@indent@
8772 \ifnum\eql@totalrows@>\@ne
8773 \ifnum\eql@row@=\@ne
8774 \eql@shape@amount@\z@
8775 \fi
8776 \fi
8777 }
8778 \def\eql@shape@layoutleft@hanging{%
8779 \eql@shape@pos@\z@
8780 \eql@shape@amount@\z@
8781 \ifnum\eql@totalrows@>\@ne
8782 \ifnum\eql@row@=\@ne
8783 \eql@shape@amount@-\eql@indent@
8784 \fi
8785 \fi
8786 }
8787 % \end{macrocode}
8788 %
8789 % The |steps| scheme implements singles out the first and last lines
8790 % which are shifted left and right, respectively.
8791 % In centeral alignment layout the shift operates on the alignment
8792 % whereas in left alignment layout the shift uses indentation:
8793 % \begin{macrocode}
8794 \def\eql@shape@layoutcenter@steps{%
8795 \eql@shape@amount@\z@
8796 \eql@shape@pos@\@ne
8797 \ifnum\eql@totalrows@>\@ne
8798 \ifnum\eql@row@=\@ne
8799 \eql@shape@pos@\z@
8800 \fi
8801 \ifnum\eql@row@=\eql@totalrows@
8802 \eql@shape@pos@\tw@
8803 \fi
8804 \fi
8805 }
8806 \def\eql@shape@layoutleft@steps{%
8807 \eql@shape@pos@\z@
8808 \eql@shape@amount@\z@
8809 \ifnum\eql@totalrows@>\@ne
8810 \ifnum\eql@row@=\@ne
8811 \eql@shape@amount@-\eql@indent@
8812 \fi
8813 \ifnum\eql@row@=\eql@totalrows@
8814 \eql@shape@amount@\eql@indent@
8815 \fi
8816 \fi
8817 }
8818 % \end{macrocode}
8819 %
8820 % \macro{\eql@shape@select}
8821 % \macro{\eql@shape@eval}
8822 % Select the shape selector function
8823 % for the currrent scheme |@\eql@shape@mode| and layout
8824 % and store it in |\eql@shape@eval|:
8825 % \begin{macrocode}
8826 \let\eql@shape@eval\@undefined
8827 \def\eql@shape@select{%
8828 \expandafter\let\expandafter\eql@shape@eval
8829 \csname eql@shape%
8830 @\ifdefined\eql@layoutleft layoutleft\else layoutcenter\fi
8831 @\eql@shape@mode\endcsname
8832 }
8833 % \end{macrocode}
8834 %
8835 % \macro{\eql@shape@alignleft}
8836 % \macro{\eql@shape@alignright}
8837 % \macro{\eql@shape@aligncenter}
8838 % Adjust the alignment of the current equation line.
8839 % The optional argument specifies the amount of indentation:
8840 % \begin{macrocode}
8841 \protected\def\eql@shape@alignleft{%
8842 \global\eql@append\eql@cell@container{\eql@shape@pos@\z@}%
8843 \eql@ampprotect\eql@shape@align@testpar\eql@shape@alignamount@opt}
8844 \protected\def\eql@shape@aligncenter{%
8845 \global\eql@append\eql@cell@container{\eql@shape@pos@\@ne}%
8846 \eql@ampprotect\eql@shape@align@testpar\eql@shape@alignamount@opt}
8847 \protected\def\eql@shape@alignright{%
8848 \global\eql@append\eql@cell@container{\eql@shape@pos@\tw@}%
8849 \eql@ampprotect\eql@shape@align@testpar\eql@shape@alignamount@opt}
8850 \def\eql@shape@align@testpar#1{%
8851 \eql@ifstar@tight{#1[\eql@indent@]}%
8852 {\eql@ifnextgobble@tight{!}{#1[-\eql@indent@]}%
8853 {\eql@testopt@tight{#1}\z@}}}
8854 \def\eql@shape@alignamount@opt[#1]{\eql@shape@alignamount@set{#1}}
8855 % \end{macrocode}
8856 %
8857 % \macro{\eql@shape@alignamount}
8858 % \TODO describe
8859 % \begin{macrocode}
8860 \protected\def\eql@shape@alignamount{%
8861 \eql@ampprotecttwo\eql@ifstar@tight
8862 \eql@shape@alignamount@set\eql@shape@alignamount@add}
8863 \def\eql@shape@alignamount@add#1{%
8864 \global\eql@appendexpand\eql@cell@container{%
8865 \advance\eql@shape@amount@\the\glueexpr#1\relax\relax}}
8866 \def\eql@shape@alignamount@set#1{%
8867 \global\eql@appendexpand\eql@cell@container{%
8868 \eql@shape@amount@\the\glueexpr#1\relax\relax}}
8869 \def\eql@shape@align@enable{%
8870 \let\shoveleft\eql@shape@alignleft
8871 \let\shovecenter\eql@shape@aligncenter
8872 \let\shoveright\eql@shape@alignright
8873 \let\shoveby\eql@shape@alignamount
8874 }
8875 % \end{macrocode}
8876 %
8877 % \TODO describe
8878 % \begin{macrocode}
8879 \protected\def\eql@shape@align@default{%
8880 \eql@warn@here{\shove...}%
8881 \eql@ampprotect\eql@shape@align@testpar\eql@gobbleopt}
8882 \protected\def\eql@shape@alignamount@default{%
8883 \eql@warn@here{\shove...}%
8884 \eql@ampprotecttwo\eql@ifstar@tight\@gobble\@gobble}
8885 \def\eql@shape@align@disable{%
8886 \let\shoveleft\eql@shape@align@default
8887 \let\shovecenter\eql@shape@align@default
8888 \let\shoveright\eql@shape@align@default
8889 \let\shoveby\eql@shape@alignamount@default
8890 }
8891 % \end{macrocode}
8892 %
8893 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8894 % \subsection{Width Data}
8895 %
8896 % \ldimen{\eql@tagwidth@block@}
8897 % \begin{macrocode}
8898 \newdimen\eql@tagwidth@block@
8899 \newdimen\eql@tagheight@block@
8900 \newdimen\eql@tagdepth@block@
8901 % \end{macrocode}
8902 %
8903 % \macro{\eql@dimensions@tab}
8904 % \TODO new
8905 % \begin{macrocode}
8906 \let\eql@dimensions@tab\@empty
8907 % \end{macrocode}
8908 %
8909 % \macro{\eql@dimensions@reset}
8910 % \begin{macrocode}
8911 \def\eql@dimensions@reset{%
8912 \let\eql@dimensions@tab\@empty
8913 \eql@tagwidth@max@\z@
8914 \eql@tagrows@\z@
8915 }
8916 % \end{macrocode}
8917 %
8918 % \macro{\eql@dimensions@add}
8919 % \begin{macrocode}
8920 \def\eql@dimensions@add#1{%
8921 \global\eql@appendexpand\eql@dimensions@tab{#1}%
8922 }
8923 % \end{macrocode}
8924 %
8925 % \macro{\eql@dimensions@addreg}
8926 % \begin{macrocode}
8927 \def\eql@dimensions@addreg#1{#1\the#1\relax}
8928 % \end{macrocode}
8929 %
8930 % \macro{\eql@dimensions@startrow}
8931 % \begin{macrocode}
8932 \def\eql@dimensions@startrow{%
8933 \eql@dimensions@add{\eql@dimensions@addreg\eql@row@}%
8934 }
8935 % \end{macrocode}
8936 %
8937 % \macro{\eql@dimensions@savecell}
8938 % \begin{macrocode}
8939 \def\eql@dimensions@savecell{%
8940 \eql@dimensions@add{%
8941 \eql@dimensions@addreg\eql@shape@pos@
8942 \eql@dimensions@addreg\eql@cellwidth@
8943 \eql@dimensions@addreg\eql@shape@amount@
8944 \noexpand\eql@dimensions@cellcall
8945 }%
8946 }
8947 % \end{macrocode}
8948 %
8949 % \macro{\eql@dimensions@savesep}
8950 % \begin{macrocode}
8951 \def\eql@dimensions@savesep{%
8952 \eql@dimensions@add{\noexpand\eql@dimensions@sepcall}%
8953 }
8954 % \end{macrocode}
8955 %
8956 % \macro{\eql@dimensions@endrow}
8957 % \begin{macrocode}
8958 \def\eql@dimensions@endrow{%
8959 \eql@dimensions@add{,%
8960 \eql@dimensions@addreg\eql@tagwidth@
8961 \eql@dimensions@addreg\eql@line@height@
8962 \eql@dimensions@addreg\eql@line@depth@
8963 \eql@dimensions@addreg\eql@line@interline@
8964 ;}%
8965 }
8966 % \end{macrocode}
8967 %
8968 % \macro{\eql@dimensions@saveblocktag}
8969 % \begin{macrocode}
8970 \def\eql@dimensions@saveblocktag{%
8971 \eql@dimensions@add{\eql@row@0\relax,%
8972 \eql@tagwidth@block@\the\eql@tagwidth@\relax
8973 \eql@tagheight@block@\the\ht\eql@tagbox@\relax
8974 \eql@tagdepth@block@\the\dp\eql@tagbox@\relax
8975 \eql@dimensions@addreg\eql@tagpos@shift@
8976 \let\noexpand\eql@tagpos@reserve\ifdefined\eql@tagpos@reserve
8977 \noexpand\eql@true\else\noexpand\eql@false\fi
8978 ;}%
8979 \global\eql@tagwidth@max@\eql@tagwidth@
8980 \global\eql@tagrows@\@ne
8981 }
8982 % \end{macrocode}
8983 %
8984 % \macro{\eql@dimensions@savenoblocktag}
8985 % \begin{macrocode}
8986 \def\eql@dimensions@savenoblocktag{%
8987 \eql@dimensions@add{\eql@row@0\relax,;}%
8988 }
8989 % \end{macrocode}
8990 %
8991 % \macro{\eql@dimensions@for}
8992 % \begin{macrocode}
8993 \def\eql@dimensions@for#1{%
8994 \def\eql@dimensions@forcall{#1}%
8995 \expandafter\eql@dimensions@forstep\eql@dimensions@tab
8996 }
8997 % \end{macrocode}
8998 %
8999 % \macro{\eql@dimensions@forstep}
9000 % \begin{macrocode}
9001 \def\eql@dimensions@forstep\eql@row@#1\relax#2,#3;{%
9002 \eql@row@#1\relax
9003 \ifnum\eql@row@=\z@\else
9004 #3%
9005 \def\eql@dimensions@cells{#2}%
9006 \eql@dimensions@forcall
9007 \expandafter\eql@dimensions@forstep
9008 \fi
9009 }
9010 % \end{macrocode}
9011 %
9012 % \macro{\eql@dimensions@get}
9013 % \begin{macrocode}
9014 \def\eql@dimensions@get#1{%
9015 \eql@row@#1\relax
9016 \expandafter\eql@dimensions@getdef\expandafter{\the\eql@row@}%
9017 \expandafter\eql@dimensions@getparse\eql@dimensions@tab\@nil
9018 }
9019 % \end{macrocode}
9020 %
9021 % \macro{\eql@dimensions@getdef}
9022 % \begin{macrocode}
9023 \def\eql@dimensions@getdef#1{%
9024 \def\eql@dimensions@getparse
9025 ##1\eql@row@#1\relax##2,##3;##4\@nil{%
9026 ##3%
9027 \def\eql@dimensions@cells{##2}%
9028 }%
9029 }
9030 % \end{macrocode}
9031 %
9032 % \macro{\eql@colwidth@tab}
9033 % \begin{macrocode}
9034 \let\eql@colwidth@tab\@empty
9035 % \end{macrocode}
9036 %
9037 % \macro{\eql@colwidth@get}
9038 % \begin{macrocode}
9039 \def\eql@colwidth@get#1{%
9040 \ifcase\expandafter#1\eql@colwidth@tab\else\z@\fi
9041 }
9042 % \end{macrocode}
9043 %
9044 % \macro{\eql@colwidth@save}
9045 % \begin{macrocode}
9046 \def\eql@colwidth@save#1{%
9047 \edef\eql@colwidth@tab{%
9048 \noexpand\or\the#1%
9049 \unexpanded\expandafter{\eql@colwidth@tab}%
9050 }%
9051 }
9052 % \end{macrocode}
9053 %
9054 % \macro{\eql@dimensions@calc}
9055 % Compute the space that is available at the beginning and at the end
9056 % of the row stored in |\eql@dimensions@cells|.
9057 % The space available at the beginning is returned in |\eql@line@avail@|.
9058 % and |\eql@line@availsep@| describes
9059 % the number of unused intercolumn separations.
9060 % The total used width is returned in |\eql@line@width@|
9061 % and |\eql@line@widthsep@| describes
9062 % the number of used intercolumn separations.
9063 % The available space at the end of the row is given as the difference
9064 % to |\eql@totalwidth@|:
9065 % \begin{macrocode}
9066 \def\eql@dimensions@calc{%
9067 \eql@column@\z@
9068 \eql@line@pos@\z@
9069 \eql@line@possep@\z@
9070 \eql@line@avail@\eql@totalwidth@
9071 \eql@line@availsep@\eql@intercolumns@
9072 \eql@line@width@\z@
9073 \eql@line@widthsep@\z@
9074 \let\eql@dimensions@cellcall\eql@dimensions@calc@call
9075 \let\eql@dimensions@sepcall\eql@dimensions@calc@callsep
9076 \eql@dimensions@cells
9077 }
9078 % \end{macrocode}
9079 %
9080 % \macro{\eql@dimensions@calc@callsep}
9081 % Callback for each intercolumn space.
9082 % \begin{macrocode}
9083 \def\eql@dimensions@calc@callsep{%
9084 \advance\eql@line@possep@\@ne
9085 }%
9086 % \end{macrocode}
9087 %
9088 % \macro{\eql@dimensions@calc@call}
9089 % Callback for each column.
9090 % When a non-blank cell is encountered,
9091 % the available space on the left will be fixed if it is still undetermined,
9092 % and the total width is updated to the current position:
9093 % \TODO implement an offset for central alignment (global?!)
9094 % \begin{macrocode}
9095 \def\eql@dimensions@calc@call{%
9096 \advance\eql@column@\@ne
9097 \ifnum\eql@totalcolumns@=\@ne
9098 \dimen@\eql@totalwidth@
9099 \else
9100 \dimen@\eql@colwidth@get\eql@column@\relax
9101 \fi
9102 \ifdim\eql@cellwidth@>\z@
9103 \ifdim\eql@line@width@=\z@
9104 \eql@line@avail@\eql@line@pos@
9105 \eql@line@availsep@\eql@line@possep@
9106 \ifcase\eql@shape@pos@
9107 \or
9108 \advance\eql@line@avail@\dimexpr
9109 (\dimen@-\eql@cellwidth@+\eql@centeroffset@)/\tw@\relax
9110 \or
9111 \advance\eql@line@avail@\dimexpr\dimen@-\eql@cellwidth@\relax
9112 \fi
9113 \advance\eql@line@avail@\eql@shape@amount@
9114 \fi
9115 \eql@line@width@\eql@line@pos@
9116 \eql@line@widthsep@\eql@line@possep@
9117 \ifcase\eql@shape@pos@
9118 \advance\eql@line@width@\eql@cellwidth@
9119 \or
9120 \advance\eql@line@width@\dimexpr
9121 (\dimen@+\eql@cellwidth@+\eql@centeroffset@)/\tw@\relax
9122 \or
9123 \advance\eql@line@width@\dimen@
9124 \fi
9125 \advance\eql@line@width@\eql@shape@amount@
9126 \fi
9127 \advance\eql@line@pos@\dimen@
9128 }
9129 % \end{macrocode}
9130 %
9131 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9132 % \subsection{Best Line Selection}
9133 %
9134 % \macro{\eql@numbering@best@auto}
9135 % \TODO describe
9136 % \begin{macrocode}
9137 \let\eql@numbering@best@auto\eql@false
9138 % \end{macrocode}
9139 %
9140 % \tcounter{\eql@numbering@best@row@}
9141 % \ldimen{\eql@numbering@best@space@}
9142 % \ebool{\eql@numbering@best@use}
9143 % \begin{macrocode}
9144 \newcount\eql@numbering@best@row@
9145 \newdimen\eql@numbering@best@space@
9146 \let\eql@numbering@best@use\eql@false
9147 % \end{macrocode}
9148 %
9149 % \macro{\eql@numbering@best@find}
9150 % Determine the row with the largest available space
9151 % on the side of the tags:
9152 % \begin{macrocode}
9153 \def\eql@numbering@best@find{%
9154 \eql@numbering@best@row@\z@
9155 \eql@numbering@best@space@\z@
9156 \eql@dimensions@for{%
9157 \eql@dimensions@calc
9158 \ifdefined\eql@tagsleft
9159 \dimen@\eql@line@avail@
9160 \else
9161 \dimen@\dimexpr\eql@totalwidth@-\eql@line@width@\relax
9162 \fi
9163 \ifdim\dimen@>\eql@numbering@best@space@
9164 \eql@numbering@best@row@\eql@row@
9165 \eql@numbering@best@space@\dimen@
9166 \fi
9167 }%
9168 \ifnum\eql@numbering@best@row@>\z@
9169 \eql@tagpos@row@\eql@numbering@best@row@
9170 \let\eql@tagpos@continuous\eql@false
9171 \eql@tagpos@prevrow@\z@
9172 \fi
9173 }
9174 % \end{macrocode}
9175 %
9176 % \macro{\eql@numbering@best@test}
9177 % \TODO describe
9178 % \begin{macrocode}
9179 \def\eql@numbering@best@test#1{%
9180 \eql@dimensions@get#1%
9181 \eql@dimensions@calc
9182 \ifdefined\eql@tagsleft
9183 \dimen@\dimexpr\eql@line@avail@
9184 +\eql@marginleft@+\eql@line@availsep@\eql@colsep@\relax
9185 \else
9186 \dimen@\dimexpr\displaywidth-\eql@line@width@
9187 -\eql@marginleft@-\eql@line@widthsep@\eql@colsep@\relax
9188 \fi
9189 \ifdim\dimen@<\eql@tagwidth@block@
9190 \let\eql@numbering@best@use\eql@true
9191 \fi
9192 }
9193 % \end{macrocode}
9194 %
9195 % \macro{\eql@numbering@best@eval}
9196 % \TODO describe
9197 % \TODO to test both lines individually may cause undesired effects
9198 % \begin{macrocode}
9199 \def\eql@numbering@best@eval{%
9200 \ifdefined\eql@numbering@best@auto
9201 \ifdefined\eql@numbering@best@use\else
9202 \ifdefined\eql@numbering@multi\else
9203 \ifnum\eql@tagpos@row@>\z@
9204 \eql@numbering@best@test\eql@tagpos@row@
9205 \fi
9206 \ifnum\eql@tagpos@prevrow@>\z@
9207 \eql@numbering@best@test\eql@tagpos@prevrow@
9208 \fi
9209 \fi
9210 \fi
9211 \fi
9212 \ifdefined\eql@numbering@best@use
9213 \eql@numbering@best@find
9214 \fi
9215 }
9216 % \end{macrocode}
9217 %
9218 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9219 % \subsection{Tag Margin}
9220 %
9221 % \TODO describe
9222 % \TODO if a tag margin is installed for a single line,
9223 % it will shift the center even if there is no tag
9224 % or importantly if a tag has been raised.
9225 %
9226 % \macro{\eql@adjust@calc@tagmargin}
9227 % \begin{macrocode}
9228 \def\eql@adjust@calc@tagmargin{%
9229 \ifdefined\eql@tagmargin@val
9230 \eql@tagmargin@\glueexpr\eql@tagmargin@val\relax
9231 \else
9232 \eql@tagmargin@\eql@tagwidth@max@
9233 \ifdim\eql@tagmargin@>\z@
9234 \advance\eql@tagmargin@-\eql@tagsepmin@
9235 \fi
9236 \fi
9237 % \end{macrocode}
9238 %
9239 % \begin{macrocode}
9240 \dimen@\eql@tagrows@\p@
9241 \ifnum\eql@totalrows@=\@ne
9242 \ifnum\eql@tagrows@=\@ne
9243 \advance\dimen@1sp\relax
9244 \fi
9245 \fi
9246 \ifdim\dimen@>\eql@totalrows@\eql@tagmargin@ratio@\else
9247 \eql@tagmargin@\z@
9248 \fi
9249 % \end{macrocode}
9250 %
9251 % \begin{macrocode}
9252 \@tempdima\dimexpr\displaywidth
9253 -\eql@totalwidth@-\eql@intercolumns@\eql@colsepmin@\relax
9254 \@tempdimb\dimexpr\@tempdima-\tw@\eql@tagmargin@\relax
9255 \ifdim\@tempdimb>\z@
9256 \ifdim\eql@tagmargin@threshold\@tempdima<\@tempdimb
9257 \eql@tagmargin@\z@
9258 \fi
9259 \fi
9260 }
9261 % \end{macrocode}
9262 %
9263 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9264 % \subsection{Single Column}
9265 %
9266 % \macro{\eql@adjust@calc@lines}
9267 % \begin{macrocode}
9268 \def\eql@adjust@calc@lines{%
9269 \eql@totalcolumns@\@ne
9270 \eql@intercolumns@\z@
9271 \eql@colsep@\z@
9272 \ifdefined\eql@layoutleft
9273 \eql@marginleft@\glueexpr\eql@layoutleftmargin\relax
9274 \eql@marginleft@min@\glueexpr\eql@layoutleftmarginmin\relax
9275 \ifdim\eql@marginleft@<\eql@marginleft@min@
9276 \eql@marginleft@\eql@marginleft@min@
9277 \fi
9278 \dimen@\glueexpr\eql@layoutleftmarginmax\relax
9279 \ifdim\eql@marginleft@>\dimen@
9280 \eql@marginleft@\dimen@
9281 \fi
9282 \eql@marginright@\z@
9283 \eql@centeroffset@\z@
9284 \else
9285 \eql@adjust@calc@tagmargin
9286 \ifdefined\eql@paddingleft@val
9287 \eql@marginleft@\dimexpr
9288 (\displaywidth-\eql@totalwidth@-\eql@tagmargin@)/\tw@
9289 -\glueexpr\eql@paddingleft@val\relax\relax
9290 \ifdim\eql@marginleft@<\z@
9291 \eql@marginleft@\z@
9292 \fi
9293 \else
9294 \eql@marginleft@\z@
9295 \fi
9296 \ifdefined\eql@paddingright@val
9297 \eql@marginright@\dimexpr
9298 (\displaywidth-\eql@totalwidth@-\eql@tagmargin@)/\tw@
9299 -\glueexpr\eql@paddingright@val\relax\relax
9300 \ifdim\eql@marginright@<\z@
9301 \eql@marginright@\z@
9302 \fi
9303 \else
9304 \eql@marginright@\z@
9305 \fi
9306 \ifdim\eql@tagmargin@>\z@
9307 \ifdefined\eql@tagsleft
9308 \ifdim\eql@marginleft@<\eql@tagsepmin@
9309 \eql@marginleft@\eql@tagsepmin@
9310 \fi
9311 \advance\eql@marginleft@\eql@tagmargin@
9312 \advance\eql@centeroffset@\eql@tagmargin@
9313 \else
9314 \ifdim\eql@marginright@<\eql@tagsepmin@
9315 \eql@marginright@\eql@tagsepmin@
9316 \fi
9317 \advance\eql@marginright@\eql@tagmargin@
9318 \advance\eql@centeroffset@-\eql@tagmargin@
9319 \fi
9320 \fi
9321 \eql@marginleft@min@\z@
9322 \eql@centeroffset@\dimexpr\eql@marginright@-\eql@marginleft@
9323 \ifdefined\eql@tagsleft+\else-\fi\eql@tagmargin@\relax
9324 \fi
9325 % \end{macrocode}
9326 %
9327 % \begin{macrocode}
9328 \eql@totalwidth@\dimexpr\displaywidth
9329 -\eql@marginleft@-\eql@marginright@\relax
9330 }
9331 % \end{macrocode}
9332 %
9333 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9334 % \subsection{Multiple Columns}
9335 %
9336 % The following code computes the horizontal placement of columns.
9337 % It distributes the columns evenly according to the layout presets
9338 % and then determines
9339 % whether there is enough space to place an equation tag on each line.
9340 % If not, the intercolumn spacing and the space at the opposite margin
9341 % can be reduced.
9342 %
9343 % \macro{\eql@adjust@calc@columns}
9344 % Main method to adjust column placement and spacing:
9345 % \begin{macrocode}
9346 \def\eql@adjust@calc@columns{%
9347 % \end{macrocode}
9348 % If there is just a single alignment stucture,
9349 % there will be no intercolumn space that might stretch
9350 % to adjust the columns to the margins.
9351 % We disable fulllength to avoid a division by zero.
9352 % Also guard against no columns at all (empty body), just in case:
9353 % \begin{macrocode}
9354 \ifnum\eql@totalcolumns@<\thr@@
9355 \eql@totalcolumns@\tw@
9356 \let\eql@columns@fulllength\eql@false
9357 \fi
9358 % \end{macrocode}
9359 % Determine the number of intercolumn spaces |\eql@intercolumns@|:
9360 % \begin{macrocode}
9361 \eql@intercolumns@\numexpr(\eql@totalcolumns@-\tw@)/\tw@\relax
9362 % \end{macrocode}
9363 % Evaluate the minimum intercolumn space which we will need often:
9364 % \begin{macrocode}
9365 \eql@colsepmin@\glueexpr\eql@colsepmin@val\relax
9366 % \end{macrocode}
9367 % Determine the left or target margin width depending on the layout:
9368 % \begin{macrocode}
9369 \ifdefined\eql@layoutleft
9370 \eql@marginleft@\glueexpr\eql@layoutleftmargin\relax
9371 \eql@marginleft@min@\glueexpr\eql@layoutleftmarginmin\relax
9372 \ifdim\eql@marginleft@<\eql@marginleft@min@
9373 \eql@marginleft@\eql@marginleft@min@
9374 \fi
9375 \else
9376 % \end{macrocode}
9377 % Get the desired tag margin, increase by minimum tag separation
9378 % if columns are aligned to the margins. Cancel tag margin if too wide:
9379 % \begin{macrocode}
9380 \eql@adjust@calc@tagmargin
9381 \ifdefined\eql@columns@fulllength
9382 \ifdim\eql@tagmargin@>\z@
9383 \advance\eql@tagmargin@\eql@tagsepmin@
9384 \fi
9385 \fi
9386 \ifdim\eql@tagmargin@>\dimexpr\displaywidth-\eql@totalwidth@
9387 -\eql@intercolumns@\eql@colsepmin@\relax
9388 \eql@tagmargin@\z@
9389 \fi
9390 \eql@marginleft@min@\z@
9391 \fi
9392 % \end{macrocode}
9393 % Compute the intercolumn space |\eql@colsep@|:
9394 % \begin{macrocode}
9395 \ifnum\eql@intercolumns@>\z@
9396 % \end{macrocode}
9397 % Distribute the available horizontal space
9398 % evenly onto the intercolumn spaces and the margins.
9399 % Unless the columns are aligned to the margins,
9400 % there are two margins in central alignment layout
9401 % but only the right margin in left alignment layout:
9402 % \begin{macrocode}
9403 \eql@colsep@\dimexpr\displaywidth-\eql@totalwidth@\relax
9404 \ifdefined\eql@layoutleft
9405 \advance\eql@colsep@-\eql@marginleft@
9406 \else
9407 \advance\eql@colsep@-\eql@tagmargin@
9408 \fi
9409 \count@\eql@intercolumns@
9410 \ifdefined\eql@columns@fulllength\else
9411 \ifdefined\eql@layoutleft
9412 \advance\count@\@ne
9413 \else
9414 \advance\count@\tw@
9415 \fi
9416 \fi
9417 \divide\eql@colsep@\count@
9418 % \end{macrocode}
9419 % Ensure that the intercolumn separation is within the specified bounds.
9420 % Disable the upper bound if columns are to be aligned to the margins:
9421 % \begin{macrocode}
9422 \ifdim\eql@colsep@<\eql@colsepmin@
9423 \eql@colsep@\eql@colsepmin@
9424 \else
9425 \ifdefined\eql@columns@fulllength\else
9426 \dimen@\glueexpr\eql@colsepmax@val\relax
9427 \ifdim\eql@colsep@>\dimen@
9428 \eql@colsep@\dimen@
9429 \fi
9430 \fi
9431 \fi
9432 \else
9433 % \end{macrocode}
9434 % For a single column, set the column separation to the minimum amount:
9435 % \begin{macrocode}
9436 \eql@colsep@\eql@colsepmin@
9437 \fi
9438 % \end{macrocode}
9439 % Compute the left margin |\eql@marginleft@| depending on the layout:
9440 % \begin{macrocode}
9441 \ifdefined\eql@layoutleft
9442 % \end{macrocode}
9443 % Set the default value:
9444 % \begin{macrocode}
9445 \ifdim\eql@colsep@=\eql@colsepmin@
9446 % \end{macrocode}
9447 % If in left alignment layout the intercolumn space has been adjusted,
9448 % compute the available space, determine left margin
9449 % and make sure it is between the minimum and the default value:
9450 % \begin{macrocode}
9451 \dimen@\dimexpr\displaywidth-\eql@totalwidth@
9452 -\eql@intercolumns@\eql@colsep@\relax
9453 \ifdim\dimen@<\eql@marginleft@
9454 \ifdim\dimen@<\eql@marginleft@min@
9455 \eql@marginleft@\eql@marginleft@min@
9456 \else
9457 \eql@marginleft@\dimen@
9458 \fi
9459 \fi
9460 \fi
9461 \else
9462 % \end{macrocode}
9463 % In central alignment mode with column aligned to the margins,
9464 % set margin to zero:
9465 % \begin{macrocode}
9466 \ifdefined\eql@columns@fulllength
9467 \eql@marginleft@\z@
9468 % \end{macrocode}
9469 % In central alignment mode with margins,
9470 % distribute the available space equally to both margins,
9471 % or remove the left margin if insufficient:
9472 % \begin{macrocode}
9473 \else
9474 \eql@marginleft@\dimexpr(\displaywidth-\eql@totalwidth@
9475 -\eql@intercolumns@\eql@colsep@-\eql@tagmargin@)/\tw@\relax
9476 \ifdim\eql@marginleft@<\z@
9477 \eql@marginleft@\z@
9478 \fi
9479 \fi
9480 % \end{macrocode}
9481 % Add tag margin in case of left tags:
9482 % \begin{macrocode}
9483 \ifdefined\eql@tagsleft
9484 \advance\eql@marginleft@\eql@tagmargin@
9485 \fi
9486 \fi
9487 % \end{macrocode}
9488 % Find the best row for tag placement:
9489 % \begin{macrocode}
9490 \eql@numbering@best@eval
9491 % \end{macrocode}
9492 % Next consider all rows with tags
9493 % and adjust the intercolumn and margin space
9494 % to make the tags fit into the available space
9495 % at the corresponding side as far as possible.
9496 % First, select code depending on tag placement:
9497 % \begin{macrocode}
9498 \ifdefined\eql@tagsleft
9499 \let\eql@adjust@columns@test\eql@adjust@columns@test@tagsleft
9500 \else
9501 \let\eql@adjust@columns@test\eql@adjust@columns@test@tagsright
9502 \fi
9503 % \end{macrocode}
9504 % Loop over all rows or select the single row containing the tag.
9505 % Fetch the width data for the current row.
9506 % If a tag is present, compute the available space and try
9507 % to adjust spaces if needed:
9508 % \TODO complete for prevrow, ideally join treatment
9509 % \begin{macrocode}
9510 \ifdefined\eql@numbering@multi
9511 \eql@dimensions@for{%
9512 \ifdim\eql@tagwidth@>\z@
9513 \eql@dimensions@calc
9514 \eql@adjust@columns@test
9515 \fi
9516 }%
9517 \else
9518 \ifnum\eql@tagpos@row@>\z@
9519 \ifnum\eql@tagpos@row@>\eql@totalrows@\else
9520 \eql@dimensions@get\eql@tagpos@row@
9521 \eql@tagwidth@\eql@tagwidth@block@
9522 \eql@dimensions@calc
9523 \eql@adjust@columns@test
9524 \fi
9525 \fi
9526 \ifnum\eql@tagpos@prevrow@>\z@
9527 \eql@dimensions@get\eql@tagpos@prevrow@
9528 \eql@tagwidth@\eql@tagwidth@block@
9529 \eql@dimensions@calc
9530 \eql@adjust@columns@test
9531 \fi
9532 \fi
9533 % \end{macrocode}
9534 % From now on |\eql@totalwidth@| will include
9535 % the left margin and the total intercolumn separation:
9536 % \begin{macrocode}
9537 \advance\eql@totalwidth@\dimexpr
9538 \eql@intercolumns@\eql@colsep@+\eql@marginleft@\relax
9539 }
9540 % \end{macrocode}
9541 %
9542 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9543 % \paragraph{Placement for Right Tags.}
9544 %
9545 % \macro{\eql@adjust@columns@test@tagsright}
9546 % Test whether the spacing can be adjusted to make the current row fit:
9547 % \begin{macrocode}
9548 \def\eql@adjust@columns@test@tagsright{%
9549 % \end{macrocode}
9550 % The register |\@tempdima| will hold the amount of available space.
9551 % \TODO does this apply equally to left alignment layout?
9552 % \begin{macrocode}
9553 \@tempdima\dimexpr\displaywidth-\eql@line@width@-\eql@tagwidth@\relax
9554 % \end{macrocode}
9555 % Test whether the space at the end of the row
9556 % is sufficient to hold the tag with the current settings.
9557 % \begin{macrocode}
9558 \ifdim\@tempdima<\dimexpr
9559 \eql@marginleft@+\eql@line@widthsep@\eql@colsep@\relax
9560 % \end{macrocode}
9561 % If not, determine whether the row and tag may at all
9562 % fit into the available space with minimal intercolumn spaces
9563 % and minimal left margin (in left alignment layout).
9564 % \begin{macrocode}
9565 \ifdim\@tempdima<\dimexpr
9566 \eql@marginleft@min@+\eql@line@widthsep@\eql@colsepmin@\relax\else
9567 % \end{macrocode}
9568 % If so, hand over to |\eql@adjust@columns@modify@tagsright|.
9569 % \begin{macrocode}
9570 \eql@adjust@columns@modify@tagsright
9571 \fi
9572 \fi
9573 }
9574 % \end{macrocode}
9575 %
9576 % \macro{\eql@adjust@columns@modify@tagsright}
9577 % Adjust the intercolumn space and left margin to make the row fit.
9578 % \begin{macrocode}
9579 \def\eql@adjust@columns@modify@tagsright{%
9580 % \end{macrocode}
9581 % If there are any intercolumn spaces that contribute to the available space,
9582 % determine how much intercolumn separation would be needed
9583 % while keeping the current left margin fixed (in left alignment layout).
9584 % In central alignment layout,
9585 % assume that the left margin will be adjusted
9586 % to match the intercolumn separation
9587 % by stepping the number of columns to divide by.
9588 % \begin{macrocode}
9589 \ifnum\eql@line@widthsep@>\z@
9590 \dimen@\@tempdima
9591 \count@\eql@line@widthsep@
9592 \ifdefined\eql@layoutleft
9593 \advance\dimen@-\eql@marginleft@
9594 \else
9595 \ifdefined\eql@columns@fulllength\else
9596 \advance\count@\@ne
9597 \fi
9598 \fi
9599 \divide\dimen@\count@
9600 % \end{macrocode}
9601 % If smaller, reduce the intercolumn separation,
9602 % but make sure to not exceed the minumum allowed value.
9603 % \begin{macrocode}
9604 \ifdim\dimen@<\eql@colsep@
9605 \ifdim\dimen@<\eql@colsepmin@
9606 \eql@colsep@\eql@colsepmin@
9607 \else
9608 \eql@colsep@\dimen@
9609 \fi
9610 \fi
9611 \fi
9612 % \end{macrocode}
9613 % Now adjust the left margin as much as needed
9614 % to fit the contents.
9615 % \begin{macrocode}
9616 \dimen@\dimexpr\@tempdima-\eql@line@widthsep@\eql@colsep@\relax
9617 \ifdim\eql@marginleft@>\dimen@
9618 \eql@marginleft@\dimen@
9619 \fi
9620 }
9621 % \end{macrocode}
9622 %
9623 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9624 % \paragraph{Placement for Left Tags.}
9625 %
9626 % \macro{\eql@adjust@columns@test@tagsleft}
9627 % Test whether the spacing can be adjusted to make the current row fit:
9628 % \begin{macrocode}
9629 \def\eql@adjust@columns@test@tagsleft{%
9630 % \end{macrocode}
9631 % The register |\@tempdima| will hold the deficit amount of space
9632 % at the beginning of the row without adjustable space,
9633 % and the register |\count@| will hold the number of
9634 % intercolumn spaces that would contribute to space adjustments.
9635 % \begin{macrocode}
9636 \count@\numexpr\eql@intercolumns@-\eql@line@availsep@\relax
9637 \@tempdima\dimexpr\eql@tagwidth@-\eql@line@avail@\relax
9638 % \end{macrocode}
9639 % Test whether the space at the beginning of the row
9640 % is sufficient to hold the tag with the current settings.
9641 % \begin{macrocode}
9642 \ifdim\@tempdima>\dimexpr
9643 \eql@marginleft@+\eql@line@availsep@\eql@colsep@\relax
9644 % \end{macrocode}
9645 % If not, first verify that the tag will fit the line
9646 % (or the maxumal left margin in left alignment layout).
9647 % \begin{macrocode}
9648 \ifdim\eql@tagwidth@<%
9649 \ifdefined\eql@layoutleft
9650 \glueexpr\eql@layoutleftmarginmax\relax
9651 \else
9652 \displaywidth
9653 \fi
9654 % \end{macrocode}
9655 % If so, determine whether the row and tag may at all
9656 % fit into the available space with minimal intercolumn spaces.
9657 % \begin{macrocode}
9658 \ifdim\@tempdima>\dimexpr
9659 \displaywidth-\eql@totalwidth@-\count@\eql@colsepmin@\relax\else
9660 % \end{macrocode}
9661 % If so, hand over to |\eql@adjust@columns@modify@tagsleft|.
9662 % \begin{macrocode}
9663 \eql@adjust@columns@modify@tagsleft
9664 \fi
9665 \fi
9666 \fi
9667 }
9668 % \end{macrocode}
9669 %
9670 % \macro{\eql@adjust@columns@modify@tagsleft}
9671 % Adjust the intercolumn space and left margin to make the row fit.
9672 % \begin{macrocode}
9673 \def\eql@adjust@columns@modify@tagsleft{%
9674 % \end{macrocode}
9675 % If there are any intercolumn spaces that contribute to the available space,
9676 % determine how much intercolumn separation would be needed
9677 % while keeping the current right margin fixed.
9678 % In central alignment layout,
9679 % assume that the right margin will be adjusted
9680 % to match the intercolumn separation
9681 % by stepping the number of columns to divide by.
9682 % \begin{macrocode}
9683 \ifnum\count@>\z@
9684 \dimen@\dimexpr\displaywidth-\eql@totalwidth@-\@tempdima\relax
9685 \ifdefined\eql@columns@fulllength\else
9686 \advance\count@\@ne
9687 \fi
9688 \divide\dimen@\count@
9689 % \end{macrocode}
9690 % If smaller, reduce the intercolumn separation,
9691 % but make sure to not exceed the minumum allowed value.
9692 % Also adjust the left margin to keep the right margin fixed.
9693 % \begin{macrocode}
9694 \ifdim\dimen@<\eql@colsep@
9695 \ifdim\dimen@<\eql@colsepmin@
9696 \dimen@\eql@colsepmin@
9697 \fi
9698 \advance\dimen@-\eql@colsep@
9699 \advance\eql@marginleft@-\eql@intercolumns@\dimen@
9700 \advance\eql@colsep@\dimen@
9701 \fi
9702 \fi
9703 % \end{macrocode}
9704 % Now adjust the left margin as much as needed
9705 % to fit the contents.
9706 % \begin{macrocode}
9707 \dimen@\dimexpr\@tempdima-\eql@line@availsep@\eql@colsep@\relax
9708 \ifdim\eql@marginleft@<\dimen@
9709 \eql@marginleft@\dimen@
9710 \fi
9711 }
9712 % \end{macrocode}
9713 %
9714 %
9715 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9716 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9717 % \section{Single Column Arrangement}
9718 %
9719 % The following code adjusts individual lines of equations
9720 % for the equation and lines mode
9721 % according to the selected layout and shape.
9722 %
9723 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9724 % \subsection{Supporting Definitions}
9725 %
9726 % \macro{\inf@bad}
9727 % The |\inf@bad| constant is for testing overfull boxes:
9728 % \begin{macrocode}
9729 \ifdefined\inf@bad\else%
9730 \newcount\inf@bad
9731 \inf@bad1000000\relax
9732 \fi
9733 % \end{macrocode}
9734 %
9735 % \macro{\eql@restore@hfuzz}
9736 % \macro{\eql@save@hfuzz}
9737 % We need to change the value of |\hfuzz| temporarily.
9738 % The method |\eql@save@hfuzz| stores the value
9739 % for recovery through |\eql@restore@hfuzz|:
9740 % \begin{macrocode}
9741 \let\eql@restore@hfuzz\@empty
9742 \def\eql@save@hfuzz{\edef\eql@restore@hfuzz{\hfuzz\the\hfuzz\relax}}
9743 % \end{macrocode}
9744 %
9745 % \macro{\eql@alignbadness@}
9746 % \macro{\eql@tagbadness@}
9747 % The registers |\eql@alignbadness@| and |\eql@tagbadness@|
9748 % store the allowable badness threshold for shrinking equation lines
9749 % to the intended margin or to fit into the line at all
9750 % before the tag is raised or lowered:
9751 % \begin{macrocode}
9752 \newcount\eql@alignbadness@
9753 \newcount\eql@tagbadness@
9754 \newcount\eql@arrange@badness@
9755 \eql@alignbadness@\inf@bad
9756 \eql@tagbadness@\inf@bad
9757 % \end{macrocode}
9758 %
9759 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9760 % \subsection{Arrangement Methods}
9761 %
9762 % \macro{\eql@arrange@try}
9763 % Try to fit the current equation line in the available space.
9764 % Argument |#1| specifies the amount of reserved space.
9765 % Unpack the box |\eql@cellbox@|, replace the previous kerning
9766 % with the new reserved space, and save the box back into |\eql@cellbox@|:
9767 % \begin{macrocode}
9768 \def\eql@arrange@try#1{%
9769 \ifdim#1>\dimexpr\displaywidth-\eql@cellwidth@\relax
9770 \setbox\eql@cellbox@\hbox to\displaywidth{%
9771 \unhbox\eql@cellbox@\unkern\kern#1}%
9772 \eql@arrange@badness@\badness
9773 \else
9774 \eql@arrange@badness@\m@ne
9775 \fi
9776 }
9777 % \end{macrocode}
9778 %
9779 % \macro{\eql@arrange@print}
9780 % We have found the final adjustment of the current line,
9781 % so we typeset it with initial and final space adjustments |#1| and |#2|,
9782 % respectively. Restore the original value for |\hfuzz|:
9783 % \TODO adjust
9784 % \begin{macrocode}
9785 \def\eql@arrange@print#1#2{%
9786 \eql@restore@hfuzz
9787 \if@eqnsw
9788 \ifdefined\eql@tagsleft
9789 \eql@tagbox@print@tagsleft
9790 \fi
9791 \fi
9792 \hbox to\displaywidth{%
9793 #1%
9794 \unhbox\eql@cellbox@\unkern
9795 #2%
9796 \eql@tagging@mathaddlast
9797 }%
9798 \if@eqnsw
9799 \ifdefined\eql@tagsleft\else
9800 \eql@tagbox@print@tagsright
9801 \fi
9802 \fi
9803 }
9804 % \end{macrocode}
9805 %
9806 % \macro{\eql@arrange@print@alignleft}
9807 % \macro{\eql@arrange@print@aligncenter}
9808 % \macro{\eql@arrange@print@alignright}
9809 % Fit the current equation line with the selected alignment
9810 % within a given left and right margins |#1| and |#2|.
9811 % If we're on the first line,
9812 % adjust |\eql@display@firstavail@|
9813 % to the mininum left available space we can guarantee:
9814 % \begin{macrocode}
9815 \def\eql@arrange@print@alignleft#1#2{%
9816 \eql@display@firstavail@set{\dimexpr#1\relax}%
9817 \eql@arrange@print{\kern#1}{\kern#2}%
9818 }
9819 % \end{macrocode}
9820 %
9821 % \begin{macrocode}
9822 \def\eql@arrange@print@alignright#1#2{%
9823 \eql@display@firstavail@set{\dimexpr\displaywidth-\eql@cellwidth@-#2\relax}%
9824 \eql@arrange@print{\kern#1\hfil}{\unskip\kern#2}%
9825 }
9826 % \end{macrocode}
9827 %
9828 % \begin{macrocode}
9829 \def\eql@arrange@print@aligncenter#1{%
9830 \eql@display@firstavail@set{\dimexpr
9831 (\displaywidth-\eql@cellwidth@+#1)/\tw@\relax}%
9832 \ifdim#1>\z@
9833 \eql@arrange@print{\kern#1\hfil}{}%
9834 \else
9835 \eql@arrange@print{\hfil}{\kern-#1}%
9836 \fi
9837 }
9838 % \end{macrocode}
9839 %
9840 % \macro{\eql@arrange@init}
9841 % Initialise the horizontal adjustment framework.
9842 % Turn off overfull box messages temporarily -- otherwise there
9843 % would be unwanted extra ones emitted during our measuring operations.
9844 % Select the shape scheme:
9845 % \begin{macrocode}
9846 \def\eql@arrange@init{%
9847 \eql@save@hfuzz
9848 \hfuzz\maxdimen
9849 \eql@shape@select
9850 }
9851 % \end{macrocode}
9852 %
9853 % \macro{\eql@arrange@print@line}
9854 % Select the appropriate adjustment method depending
9855 % on the current alignment position,
9856 % the selected tag placement if any:
9857 % \TODO adjust
9858 % \begin{macrocode}
9859 \def\eql@arrange@print@line{%
9860 \eql@tagging@tagaddbox
9861 \csname eql@arrange%
9862 @\ifcase\eql@shape@pos@ alignleft\or aligncenter\or alignright\fi
9863 @init\endcsname
9864 \csname eql@arrange%
9865 @\ifcase\eql@shape@pos@ alignleft\or aligncenter\or alignright\fi
9866 @\ifdefined\eql@tagpos@reserve
9867 \ifdefined\eql@tagsleft tagsleft\else tagsright\fi\else
9868 notag\fi\endcsname
9869 }
9870 % \end{macrocode}
9871 %
9872 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9873 % \subsection{Central Alignment}
9874 %
9875 % \TODO describe
9876 % \begin{macrocode}
9877 \def\eql@arrange@aligncenter@init{%
9878 \eql@tagging@aligncenter
9879 \eql@line@offset@\dimexpr\tw@\eql@shape@amount@
9880 +\eql@marginleft@-\eql@marginright@+\eql@centeroffset@\relax
9881 }
9882 % \end{macrocode}
9883 %
9884 % \TODO describe
9885 % \begin{macrocode}
9886 \def\eql@arrange@aligncenter@notag{%
9887 \ifdim\dimexpr\displaywidth-\eql@cellwidth@\relax>%
9888 \ifdim\eql@line@offset@<\eql@marginleft@min@
9889 \dimexpr\tw@\eql@marginleft@min@-\eql@line@offset@\relax
9890 \else
9891 \eql@line@offset@
9892 \fi
9893 \eql@arrange@print@aligncenter\eql@line@offset@
9894 \else
9895 \ifdim\eql@line@offset@<\eql@marginleft@min@
9896 \eql@arrange@print@alignleft\eql@marginleft@min@\z@
9897 \else
9898 \eql@arrange@print@alignright\eql@marginleft@min@\z@
9899 \fi
9900 \fi
9901 }
9902 % \end{macrocode}
9903 %
9904 % \TODO describe
9905 % \begin{macrocode}
9906 \def\eql@arrange@aligncenter@tagsright{%
9907 \ifdim\dimexpr\displaywidth-\eql@cellwidth@\relax>%
9908 \ifdim\eql@line@offset@<\dimexpr\eql@marginleft@min@-\eql@tagwidth@\relax
9909 \dimexpr\tw@\eql@marginleft@min@-\eql@line@offset@\relax
9910 \else
9911 \dimexpr\tw@\eql@tagwidth@+\eql@line@offset@\relax
9912 \fi
9913 \eql@arrange@print@aligncenter\eql@line@offset@
9914 \else
9915 \eql@arrange@try{\dimexpr\eql@tagwidth@+\eql@marginleft@min@\relax}%
9916 \ifnum\eql@arrange@badness@<\eql@tagbadness@
9917 \ifdim\eql@line@offset@<\dimexpr\eql@marginleft@min@-\eql@tagwidth@\relax
9918 \eql@arrange@print@alignleft\eql@marginleft@min@\eql@tagwidth@
9919 \else
9920 \eql@arrange@print@alignright\eql@marginleft@min@\eql@tagwidth@
9921 \fi
9922 \else
9923 \let\eql@tagpos@reserve\eql@false
9924 \eql@arrange@aligncenter@notag
9925 \fi
9926 \fi
9927 }
9928 % \end{macrocode}
9929 %
9930 % \begin{macrocode}
9931 \def\eql@arrange@aligncenter@tagsleft{%
9932 \ifdim\eql@tagwidth@>\eql@marginleft@min@
9933 \ifdim\dimexpr\displaywidth-\eql@cellwidth@\relax>%
9934 \ifdim\eql@line@offset@<\eql@tagwidth@
9935 \dimexpr\tw@\eql@tagwidth@-\eql@line@offset@\relax
9936 \else
9937 \eql@line@offset@
9938 \fi
9939 \eql@arrange@print@aligncenter\eql@line@offset@
9940 \else
9941 \eql@arrange@try\eql@tagwidth@
9942 \ifnum\eql@arrange@badness@<\eql@tagbadness@
9943 \ifdim\eql@line@offset@<\eql@tagwidth@
9944 \eql@arrange@print@alignleft\eql@tagwidth@\z@
9945 \else
9946 \eql@arrange@print@alignright\eql@tagwidth@\z@
9947 \fi
9948 \else
9949 \let\eql@tagpos@reserve\eql@false
9950 \eql@arrange@aligncenter@notag
9951 \fi
9952 \fi
9953 \else
9954 \eql@arrange@aligncenter@notag
9955 \fi
9956 }
9957 % \end{macrocode}
9958 %
9959 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9960 % \subsection{Left Alignment}
9961 %
9962 % \begin{macrocode}
9963 \def\eql@arrange@alignleft@init{%
9964 \eql@tagging@alignleft
9965 \eql@line@offset@\dimexpr\eql@marginleft@+\eql@shape@amount@\relax
9966 \ifdim\eql@line@offset@<\eql@marginleft@min@
9967 \eql@line@offset@\eql@marginleft@min@
9968 \fi
9969 }
9970 % \end{macrocode}
9971 %
9972 % \begin{macrocode}
9973 \def\eql@arrange@alignleft@notag{%
9974 \ifdim\eql@line@offset@>\eql@marginleft@min@
9975 \eql@arrange@try\eql@line@offset@
9976 \ifnum\eql@arrange@badness@<\eql@alignbadness@
9977 \eql@arrange@print@alignleft\eql@line@offset@\z@
9978 \else
9979 \eql@arrange@print@alignright\eql@marginleft@min@\z@
9980 \fi
9981 \else
9982 \eql@arrange@print@alignleft\eql@marginleft@min@\z@
9983 \fi
9984 }
9985 % \end{macrocode}
9986 %
9987 % \begin{macrocode}
9988 \def\eql@arrange@alignleft@tagsright{%
9989 \eql@arrange@try{\dimexpr\eql@line@offset@+\eql@tagwidth@\relax}%
9990 \ifnum\eql@arrange@badness@<\eql@alignbadness@
9991 \eql@arrange@print@alignleft\eql@line@offset@\eql@tagwidth@
9992 \else
9993 \ifdim\eql@line@offset@>\eql@marginleft@min@
9994 \eql@arrange@try{\dimexpr\eql@marginleft@min@+\eql@tagwidth@\relax}%
9995 \fi
9996 \ifnum\eql@arrange@badness@<\eql@tagbadness@
9997 \eql@arrange@print@alignright\eql@marginleft@min@\eql@tagwidth@
9998 \else
9999 \let\eql@tagpos@reserve\eql@false
10000 \eql@arrange@alignleft@notag
10001 \fi
10002 \fi
10003 }
10004 % \end{macrocode}
10005 %
10006 % \begin{macrocode}
10007 \def\eql@arrange@alignleft@tagsleft{%
10008 \ifdim\eql@tagwidth@>\eql@marginleft@min@
10009 \ifdim\eql@line@offset@>\eql@tagwidth@
10010 \eql@arrange@try\eql@line@offset@
10011 \ifnum\eql@arrange@badness@<\eql@alignbadness@
10012 \eql@arrange@print@alignleft\eql@line@offset@\z@
10013 \else
10014 \eql@arrange@try\eql@tagwidth@
10015 \ifnum\eql@arrange@badness@<\eql@tagbadness@
10016 \eql@arrange@print@alignright\eql@tagwidth@\z@
10017 \else
10018 \let\eql@tagpos@reserve\eql@false
10019 \eql@arrange@print@alignright\eql@marginleft@min@\z@
10020 \fi
10021 \fi
10022 \else
10023 \eql@arrange@try\eql@tagwidth@
10024 \ifnum\eql@arrange@badness@<\eql@tagbadness@
10025 \eql@arrange@print@alignleft\eql@tagwidth@\z@
10026 \else
10027 \let\eql@tagpos@reserve\eql@false
10028 \eql@arrange@alignleft@notag
10029 \fi
10030 \fi
10031 \else
10032 \eql@arrange@alignleft@notag
10033 \fi
10034 }
10035 % \end{macrocode}
10036 %
10037 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10038 % \subsection{Right Alignment}
10039 %
10040 % \begin{macrocode}
10041 \def\eql@arrange@alignright@init{%
10042 \eql@tagging@alignright
10043 \eql@line@offset@\dimexpr\eql@marginright@-\eql@shape@amount@\relax
10044 \ifdim\eql@line@offset@<\z@
10045 \eql@line@offset@\z@
10046 \fi
10047 }
10048 % \end{macrocode}
10049 %
10050 % \TODO describe
10051 % \begin{macrocode}
10052 \def\eql@arrange@alignright@notag{%
10053 \ifdim\eql@line@offset@>\z@
10054 \eql@arrange@try{\dimexpr\eql@marginleft@min@+\eql@line@offset@\relax}%
10055 \ifnum\eql@arrange@badness@<\eql@alignbadness@
10056 \eql@arrange@print@alignright\eql@marginleft@min@\eql@line@offset@
10057 \else
10058 \eql@arrange@print@alignleft\eql@marginleft@min@\z@
10059 \fi
10060 \else
10061 \eql@arrange@print@alignright\eql@marginleft@min@\z@
10062 \fi
10063 }
10064 % \end{macrocode}
10065 %
10066 % \TODO describe
10067 % \begin{macrocode}
10068 \def\eql@arrange@alignright@tagsright{%
10069 \ifdim\eql@line@offset@>\eql@tagwidth@
10070 \eql@arrange@try{\dimexpr\eql@marginleft@min@+\eql@line@offset@\relax}%
10071 \ifnum\eql@arrange@badness@<\eql@alignbadness@
10072 \eql@arrange@print@alignright\eql@marginleft@min@\eql@line@offset@
10073 \else
10074 \eql@arrange@try{\dimexpr\eql@marginleft@min@+\eql@tagwidth@\relax}%
10075 \ifnum\eql@arrange@badness@<\eql@tagbadness@
10076 \eql@arrange@print@alignleft\eql@marginleft@min@\eql@tagwidth@
10077 \else
10078 \let\eql@tagpos@reserve\eql@false
10079 \eql@arrange@print@alignleft\eql@marginleft@min@\z@
10080 \fi
10081 \fi
10082 \else
10083 \eql@arrange@try{\dimexpr\eql@marginleft@min@+\eql@tagwidth@\relax}%
10084 \ifnum\eql@arrange@badness@<\eql@tagbadness@
10085 \eql@arrange@print@alignright\eql@marginleft@min@\eql@tagwidth@
10086 \else
10087 \let\eql@tagpos@reserve\eql@false
10088 \eql@arrange@alignright@notag
10089 \fi
10090 \fi
10091 }
10092 % \end{macrocode}
10093 %
10094 % \TODO describe
10095 % \begin{macrocode}
10096 \def\eql@arrange@alignright@tagsleft{%
10097 \ifdim\eql@tagwidth@>\eql@marginleft@min@
10098 \eql@arrange@try{\dimexpr\eql@line@offset@+\eql@tagwidth@\relax}%
10099 \ifnum\eql@arrange@badness@<\eql@alignbadness@
10100 \eql@arrange@print@alignright\eql@tagwidth@\eql@line@offset@
10101 \else
10102 \ifdim\eql@line@offset@>\z@
10103 \eql@arrange@try\eql@tagwidth@
10104 \fi
10105 \ifnum\eql@arrange@badness@<\eql@tagbadness@
10106 \eql@arrange@print@alignleft\eql@tagwidth@\z@
10107 \else
10108 \let\eql@tagpos@reserve\eql@false
10109 \eql@arrange@alignright@notag
10110 \fi
10111 \fi
10112 \else
10113 \eql@arrange@alignright@notag
10114 \fi
10115 }
10116 % \end{macrocode}
10117 %
10118 %
10119 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10120 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10121 % \section{Equations Box Environment}
10122 %
10123 % \TODO outline sequence of calls
10124 %
10125 % \TODO describe
10126 %
10127 % \TODO fixed width version (works only towards intercolumn stretch)?
10128 %
10129 % \TODO vspace?!
10130 %
10131 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10132 % \subsection{Line Breaks}
10133 %
10134 % \TODO describe
10135 %
10136 % \macro{\eql@box@cr}
10137 % \begin{macrocode}
10138 \def\eql@box@cr{%
10139 \ifmmode\else\unskip\fi
10140 \eql@vspaceskip@\z@skip
10141 \let\eql@punct@term\eql@false
10142 \let\eql@class@rel@composed\@empty
10143 \eql@ampprotect\eql@box@cr@test\eql@box@cr@process
10144 }
10145 % \end{macrocode}
10146 %
10147 % \TODO describe
10148 % \begin{macrocode}
10149 \def\eql@box@cr@test@setopt{\let\eql@box@cr@test\eql@box@cr@testopt}
10150 \def\eql@box@cr@test@setall{\let\eql@box@cr@test\eql@box@cr@testall}
10151 % \end{macrocode}
10152 %
10153 % \macro{\eql@box@cr@testopt}
10154 % \TODO describe
10155 % \begin{macrocode}
10156 \def\eql@box@cr@testopt#1{\eql@teststaropt@tight
10157 {\eql@box@cr@testopt@set{#1}}{\eql@box@cr@testopt@set{#1}}{0pt}}
10158 \def\eql@box@cr@testopt@set#1[#2]{\advance\eql@vspaceskip@\glueexpr#2\relax#1}
10159 % \end{macrocode}
10160 %
10161 % \macro{\eql@box@cr@testall}
10162 % \macro{\eql@box@cr@testall@parse}
10163 % \TODO describe
10164 % \begin{macrocode}
10165 \def\eql@box@cr@testall{\eql@parseopt@cr\eql@box@cr@testall@parse}
10166 \def\eql@box@cr@testall@parse{%
10167 \ifx\eql@parseopt@token[%
10168 \let\eql@parseopt@next\eql@parseopt@vspace
10169 \fi
10170 \ifx\eql@parseopt@token*%
10171 \let\eql@parseopt@next\eql@parseopt@gobble
10172 \fi
10173 \ifx\eql@parseopt@token.%
10174 \let\eql@parseopt@next\eql@parseopt@punctpass
10175 \fi
10176 \ifx\eql@parseopt@token,%
10177 \let\eql@parseopt@next\eql@parseopt@punctpass
10178 \fi
10179 \ifx\eql@parseopt@token~%
10180 \let\eql@parseopt@next\eql@parseopt@punctpass
10181 \fi
10182 \ifx\eql@parseopt@token`%
10183 \let\eql@parseopt@next\eql@parseopt@punctnext
10184 \fi
10185 \ifx\eql@parseopt@token!%
10186 \let\eql@parseopt@next\eql@parseopt@punctterm
10187 \fi
10188 \ifx\eql@parseopt@token/%
10189 \let\eql@parseopt@next\eql@parseopt@punctclear
10190 \fi
10191 \ifx\eql@parseopt@token=%
10192 \let\eql@parseopt@next\eql@parseopt@relsymb
10193 \fi
10194 \ifx\eql@parseopt@token;%
10195 \let\eql@parseopt@next\eql@parseopt@relcont
10196 \fi
10197 \ifx\eql@parseopt@token:%
10198 \let\eql@parseopt@next\eql@parseopt@relstart
10199 \fi
10200 \ifx\eql@parseopt@token|%
10201 \let\eql@parseopt@next\eql@parseopt@relord
10202 \fi
10203 \ifx\eql@parseopt@token?%
10204 \let\eql@parseopt@next\eql@box@cr@parse@rel
10205 \fi
10206 \ifx\eql@parseopt@token&%
10207 \let\eql@parseopt@next\eql@parseopt@end
10208 \fi
10209 }
10210 \def\eql@box@cr@parse@rel#1#2{%
10211 \def\eql@tmp{#2}%
10212 \ifx\eql@tmp\eql@relax\else
10213 \ifdefined\eql@punct@next\else
10214 \eql@punct@next@clear
10215 \fi
10216 \fi
10217 \ifx\eql@box@open\eql@box@lines@open
10218 \ifx\eql@tmp\@empty
10219 \def\eql@class@rel@composed{\eql@shape@cont}%
10220 \else
10221 \def\eql@class@rel@composed{\eql@shape@rel#2}%
10222 \fi
10223 \fi
10224 \ifx\eql@box@open\eql@box@columns@open
10225 \def\eql@class@rel@composed{\eql@class@rel@make{#2}}%
10226 \fi
10227 \ifx\eql@box@open\eql@box@cases@open
10228 \def\eql@class@rel@composed{&#2}%
10229 \fi
10230 \eql@parseopt@end}
10231 % \end{macrocode}
10232 %
10233 % \macro{\eql@box@cr@process}
10234 % \begin{macrocode}
10235 \def\eql@box@cr@process{%
10236 \ifdefined\eql@punct@term\eql@punct@apply@top\fi
10237 \edef\eql@tmp{%
10238 \unexpanded{%
10239 \eql@box@endline
10240 \eql@box@lastcell
10241 \cr
10242 }%
10243 \noalign{%
10244 \vskip\the\eql@vspaceskip@\relax
10245 }%
10246 \unexpanded\expandafter{\eql@class@rel@composed}%
10247 }%
10248 \eql@tmp
10249 }
10250 % \end{macrocode}
10251 %
10252 % \macro{\eql@box@endline}
10253 % \begin{macrocode}
10254 \def\eql@box@endline{%
10255 \eql@punct@apply@line
10256 \eql@hook@lineout
10257 }
10258 % \end{macrocode}
10259 %
10260 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10261 % \subsection{Column Breaks}
10262 %
10263 % \TODO describe
10264 %
10265 % \begin{macrocode}
10266 \def\eql@box@amp{%
10267 \eql@ampprotecttwo\eql@box@amp@testescape\eql@amp@org
10268 \eql@box@amp@process}
10269 \def\eql@box@amp@testescape#1#2{\eql@ifnextgobble@tight/{#1}{%
10270 \relax
10271 \let\eql@punct@term\eql@false
10272 \let\eql@class@rel@composed\@empty
10273 \eql@box@amp@test{#2}}}
10274 % \end{macrocode}
10275 %
10276 % \TODO describe
10277 % \begin{macrocode}
10278 \def\eql@box@amp@test@setopt{%
10279 \let\eql@box@amp@test\eql@box@amp@testopt}
10280 \def\eql@box@amp@test@setall{%
10281 \let\eql@box@amp@test\eql@box@amp@testall}
10282 % \end{macrocode}
10283 %
10284 % \macro{\eql@box@amp@testopt}
10285 % \TODO describe
10286 % \begin{macrocode}
10287 \let\eql@box@amp@testopt\@empty
10288 % \end{macrocode}
10289 %
10290 % \macro{\eql@box@amp@testall}
10291 % \macro{\eql@box@amp@testall@parse}
10292 % \TODO describe
10293 % \begin{macrocode}
10294 \def\eql@box@amp@testall{\eql@parseopt@cr\eql@box@amp@testall@parse}
10295 \def\eql@box@amp@testall@parse{%
10296 \ifx\eql@parseopt@token.%
10297 \let\eql@parseopt@next\eql@parseopt@punctpass
10298 \fi
10299 \ifx\eql@parseopt@token,%
10300 \let\eql@parseopt@next\eql@parseopt@punctpass
10301 \fi
10302 \ifx\eql@parseopt@token~%
10303 \let\eql@parseopt@next\eql@parseopt@punctpass
10304 \fi
10305 \ifx\eql@parseopt@token`%
10306 \let\eql@parseopt@next\eql@parseopt@punctnext
10307 \fi
10308 \ifx\eql@parseopt@token!%
10309 \let\eql@parseopt@next\eql@parseopt@punctterm
10310 \fi
10311 \ifx\eql@parseopt@token=%
10312 \let\eql@parseopt@next\eql@parseopt@relsymb
10313 \fi
10314 \ifx\eql@parseopt@token;%
10315 \let\eql@parseopt@next\eql@parseopt@relcont
10316 \fi
10317 \ifx\eql@parseopt@token:%
10318 \let\eql@parseopt@next\eql@parseopt@relstart
10319 \fi
10320 \ifx\eql@parseopt@token|%
10321 \let\eql@parseopt@next\eql@parseopt@relord
10322 \fi
10323 \ifx\eql@parseopt@token?%
10324 \let\eql@parseopt@next\eql@box@amp@parse@rel
10325 \fi
10326 \ifx\eql@parseopt@token&%
10327 \let\eql@parseopt@next\eql@parseopt@end
10328 \fi
10329 }
10330 \def\eql@box@amp@parse@rel#1#2{%
10331 \ifx\eql@box@open\eql@box@columns@open
10332 \def\eql@class@rel@composed{\eql@class@rel@make{#2}}%
10333 \else
10334 \def\eql@class@rel@composed{#2}%
10335 \fi
10336 \eql@parseopt@end}
10337 % \end{macrocode}
10338 %
10339 % \macro{\eql@box@amp@process}
10340 % \begin{macrocode}
10341 \def\eql@box@amp@process{%
10342 \ifdefined\eql@punct@term\eql@punct@apply@top\fi
10343 \ifx\eql@box@open\eql@box@columns@open
10344 \edef\eql@tmp{%
10345 \ifx\eql@class@rel@composed\@empty
10346 \ifx\eql@box@lastcell\eql@box@columns@lastcell@odd
10347 &\noexpand\eql@punct@next@clear\fi&%
10348 \else
10349 \ifx\eql@box@lastcell\eql@box@columns@lastcell@even&\fi%
10350 \unexpanded\expandafter{\eql@class@rel@composed}%
10351 \fi
10352 }%
10353 \else
10354 \edef\eql@tmp{%
10355 \ifx\eql@class@rel@composed\@empty
10356 &%
10357 \else
10358 \unexpanded\expandafter{\eql@class@rel@composed}%
10359 \fi
10360 }%
10361 \fi
10362 \eql@tmp
10363 }
10364 % \end{macrocode}
10365 %
10366 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10367 % \subsection{Lines Mode}
10368 %
10369 % \begin{macrocode}
10370 \def\eql@box@lines@lastcell{&\omit\kern-2\eql@colsep@}
10371 % \end{macrocode}
10372 %
10373 % \TODO templates
10374 % \begin{macrocode}
10375 \def\eql@box@lines@open{%
10376 \eql@shape@align@enable
10377 \let\eql@box@lastcell\eql@box@lines@lastcell
10378 \everycr{\noalign{%
10379 \eql@verbose@info\eql@verbose@msg@startline@number
10380 \global\advance\eql@row@\@ne
10381 }}%
10382 \tabskip\z@skip
10383 \halign\bgroup
10384 &%
10385 \global\let\eql@cell@container\@empty
10386 \setbox\eql@cellbox@\hbox{%
10387 \eql@strut@cell
10388 \@lign
10389 $\m@th\eql@mathstyle
10390 \eql@hook@colin
10391 ##%
10392 \eql@punct@apply@col
10393 \eql@hook@colout
10394 \eql@tagging@mathsave
10395 $%
10396 \eql@tagging@mathaddlast
10397 }%
10398 \ifdefined\eql@shape@lastrow
10399 \eql@totalrows@\eql@row@
10400 \fi
10401 \eql@shape@eval
10402 \eql@cell@container
10403 \ifdefined\eql@frame@cmd
10404 \ifcase\eql@shape@pos@
10405 \eql@frame@measure
10406 \advance\eql@shape@amount@-\eql@frame@margin@
10407 \or\or
10408 \eql@frame@measure
10409 \advance\eql@shape@amount@+\eql@frame@margin@
10410 \fi
10411 \eql@frame@print
10412 \fi
10413 \ifcase\eql@shape@pos@
10414 \kern\eql@shape@amount@
10415 \box\eql@cellbox@
10416 \hskip\glueexpr\eql@paddingleft@+\eql@paddingright@
10417 -\eql@shape@amount@+\@flushglue\relax
10418 \eql@tagging@alignleft
10419 \or
10420 \hskip\glueexpr\eql@paddingleft@+\eql@shape@amount@+\@flushglue\relax
10421 \box\eql@cellbox@
10422 \hskip\glueexpr\eql@paddingright@-\eql@shape@amount@+\@flushglue\relax
10423 \eql@tagging@aligncenter
10424 \or
10425 \hskip\glueexpr\eql@paddingleft@+\eql@paddingright@
10426 +\eql@shape@amount@+\@flushglue\relax
10427 \box\eql@cellbox@
10428 \kern-\eql@shape@amount@
10429 \eql@tagging@alignright
10430 \fi
10431 \tabskip\eql@colsep@\relax
10432 \crcr
10433 \noalign{%
10434 \global\let\eql@shape@lastrow\eql@false
10435 \eql@hook@blockbefore
10436 }%
10437 \eql@hook@blockin
10438 }
10439 % \end{macrocode}
10440 %
10441 % \begin{macrocode}
10442 \def\eql@box@lines@set{\let\eql@box@open\eql@box@lines@open}
10443 % \end{macrocode}
10444 %
10445 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10446 % \subsection{Columns Mode}
10447 %
10448 % \begin{macrocode}
10449 \def\eql@box@columns@lastcell@odd{%
10450 &\omit
10451 \eql@prevwidth@\wd\eql@cellbox@
10452 \let\eql@frame@cmd\eql@frame@prevcmd
10453 \ifdefined\eql@frame@cmd
10454 \eql@frame@measure
10455 \advance\eql@prevwidth@\eql@frame@margin@
10456 \eql@frame@print
10457 \fi
10458 \kern-\eql@prevwidth@
10459 \unhbox\eql@cellbox@
10460 \hfil
10461 &\omit\kern-\eql@colsep@
10462 }%
10463 \def\eql@box@columns@lastcell@even{&\omit\kern-\eql@colsep@}
10464 % \end{macrocode}
10465 %
10466 % \begin{macrocode}
10467 \def\eql@box@columns@open{%
10468 % \TODO templates
10469 \eql@shape@align@disable
10470 \let\eql@box@lastcell\@empty
10471 \everycr{\noalign{%
10472 \eql@verbose@info\eql@verbose@msg@startline@new
10473 }}%
10474 \tabskip\z@skip
10475 \halign\bgroup
10476 &%
10477 \let\eql@box@lastcell\eql@box@columns@lastcell@odd
10478 \global\let\eql@cell@container\@empty
10479 \global\setbox\eql@cellbox@\hbox{%
10480 \eql@strut@cell
10481 \@lign
10482 $\m@th\eql@mathstyle
10483 \eql@hook@colin
10484 ##%
10485 \eql@punct@apply@next
10486 \eql@class@innerleft
10487 \eql@hook@innerleft
10488 \eql@tagging@mathsave
10489 $%
10490 \eql@tagging@mathaddlast
10491 }%
10492 \eql@cell@container
10493 \hfil
10494 \kern\wd\eql@cellbox@
10495 \ifdefined\eql@frame@cmd
10496 \eql@frame@measure
10497 \kern\eql@frame@margin@
10498 \fi
10499 \global\let\eql@frame@prevcmd\eql@frame@cmd
10500 \tabskip\z@skip
10501 &%
10502 \eql@prevwidth@\wd\eql@cellbox@
10503 \let\eql@box@lastcell\eql@box@columns@lastcell@even
10504 \let\eql@frame@cmd\eql@frame@prevcmd
10505 \global\let\eql@cell@container\@empty
10506 \setbox\eql@cellbox@\hbox{%
10507 \unhbox\eql@cellbox@
10508 \eql@strut@cell
10509 \@lign
10510 $\m@th\eql@mathstyle
10511 \eql@hook@innerright
10512 \eql@class@innerright@sel
10513 ##%
10514 \eql@punct@apply@col
10515 \eql@hook@colout
10516 \eql@tagging@mathsave
10517 $%
10518 \eql@tagging@mathaddlast
10519 }%
10520 \eql@cell@container
10521 \ifdefined\eql@frame@cmd
10522 \eql@frame@measure
10523 \advance\eql@prevwidth@\eql@frame@margin@
10524 \eql@frame@print
10525 \fi
10526 \kern-\eql@prevwidth@
10527 \unhbox\eql@cellbox@
10528 \hfil
10529 \tabskip\eql@colsep@\relax
10530 \crcr
10531 \noalign{%
10532 \eql@hook@blockbefore
10533 }%
10534 \eql@hook@blockin
10535 }
10536 % \end{macrocode}
10537 %
10538 % \begin{macrocode}
10539 \def\eql@box@columns@set{\let\eql@box@open\eql@box@columns@open}
10540 % \end{macrocode}
10541 %
10542 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10543 % \subsection{Cases Mode}
10544 %
10545 % \TODO describe
10546 %
10547 % \TODO how to get proper height in tagging (and avoid nulldelimiterspace)
10548 % \TODO add alignment?
10549 %
10550 % \begin{macrocode}
10551 \def\eql@box@cases@lastcell{&}%
10552 % \end{macrocode}
10553 %
10554 % \begin{macrocode}
10555 \let\eql@box@cases@condtext\eql@false
10556 \let\eql@box@cases@condintro\@empty
10557 % \end{macrocode}
10558 %
10559 % \begin{macrocode}
10560 \def\eql@box@cases@open{%
10561 \eql@shape@align@disable
10562 \let\eql@box@lastcell\@empty
10563 \everycr{\noalign{%
10564 \eql@verbose@info\eql@verbose@msg@startline@new
10565 }}%
10566 \tabskip\z@skip
10567 \halign\bgroup
10568 \let\eql@box@lastcell\eql@box@cases@lastcell
10569 \global\let\eql@cell@container\@empty
10570 \global\setbox\eql@cellbox@\hbox{%
10571 \eql@strut@cell
10572 \@lign
10573 $\m@th\eql@mathstyle
10574 \eql@hook@colin
10575 ##%
10576 \eql@punct@apply@col
10577 \eql@tagging@mathsave
10578 $%
10579 \eql@tagging@mathaddlast
10580 }%
10581 \eql@cell@container
10582 \unhbox\eql@cellbox@
10583 \hfil
10584 \eql@tagging@alignleft
10585 \tabskip\eql@colsep@\relax
10586 &%
10587 \let\eql@box@lastcell\@empty
10588 \global\let\eql@cell@container\@empty
10589 \setbox\eql@cellbox@\hbox{%
10590 \unhbox\eql@cellbox@
10591 \eql@strut@cell
10592 \@lign
10593 $\m@th\eql@mathstyle
10594 \ifdefined\eql@box@cases@condtext
10595 \expandafter\hbox\else\expandafter\@firstofone\fi\bgroup
10596 \eql@box@cases@condintro
10597 ##%
10598 \eql@punct@apply@col
10599 \egroup
10600 \eql@hook@colout
10601 \eql@tagging@mathsave
10602 $%
10603 \eql@tagging@mathaddlast
10604 }%
10605 \eql@cell@container
10606 \unhbox\eql@cellbox@
10607 \hfil
10608 \eql@tagging@alignleft
10609 \tabskip\z@skip
10610 \crcr
10611 \noalign{%
10612 \eql@hook@blockbefore
10613 }%
10614 \eql@hook@blockin
10615 }
10616 % \end{macrocode}
10617 %
10618 % \begin{macrocode}
10619 \def\eql@box@cases@set{%
10620 \ifdefined\eql@cases@mathstyle\let\eql@mathstyle\eql@cases@mathstyle\fi
10621 \ifdefined\eql@punct@cases\let\eql@punct@col\eql@punct@cases\fi
10622 \let\eql@box@open\eql@box@cases@open}
10623 % \end{macrocode}
10624 %
10625 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10626 % \subsection{Main}
10627 %
10628 % \begin{macrocode}
10629 \let\eql@box@box\vcenter
10630 \let\eql@box@open\@undefined
10631 \let\eql@box@frame\@firstofone
10632 \def\eql@box@wrap#1#2{\def\eql@box@frame##1{#1##1#2}}
10633 % \end{macrocode}
10634 %
10635 % \begin{macrocode}
10636 \def\eql@box@delim#1#2{\def\eql@box@frame##1{\mathopen{}\mathclose{%
10637 \left#1##1\right#2}}}
10638 \def\eql@box@getdim{\setbox\@ne\null\ht\@ne\ht\z@\dp\@ne\dp\z@}
10639 \def\eql@box@deldim#1{\hbox{$\m@th\nulldelimiterspace\z@\left#1%
10640 \ifx\eql@box@box\vcenter\vcenter{\box\@ne}\else\box\@ne\fi\right.$}}
10641 \def\eql@box@ldelim#1{\def\eql@box@frame##1{\mathopen{}\mathclose{%
10642 \eql@box@getdim\eql@box@deldim#1##1}}}
10643 \def\eql@box@rdelim#1{\def\eql@box@frame##1{\mathopen{}\mathclose{%
10644 \eql@box@getdim##1\eql@box@deldim#1}}}
10645 % \end{macrocode}
10646 %
10647 % \TODO can we avoid setting |\eql@totalrows@| globally here?
10648 % \TODO this is needed for escaping the box and then set the alignment
10649 % \TODO maybe determine alignment within inner math?!
10650 % \TODO difficulty: last line being known (for steps) only after
10651 % all cells have been processed.
10652 % Note: only works for single column anyway! we do not have to cater for more!
10653 % \begin{macrocode}
10654 \def\eql@box@close{%
10655 \ifvmode\else
10656 \ifmmode\else\unskip\fi
10657 \global\let\eql@shape@lastrow\eql@true
10658 \eql@punct@apply@block
10659 \ifdefined\eql@box@punct@term
10660 \eql@punct@apply@top
10661 \fi
10662 \eql@box@endline
10663 \eql@box@lastcell
10664 \cr
10665 \fi
10666 \noalign{%
10667 \eql@hook@blockafter
10668 \global\let\eql@shape@lastrow\eql@false
10669 }%
10670 \eql@tagging@tablesaveinner
10671 \egroup
10672 }
10673 % \end{macrocode}
10674 %
10675 % \macro{\eql@box@vcenter}
10676 % \begin{macrocode}
10677 \def\eql@box@vcenter#1{%
10678 \ifmmode
10679 \vcenter{#1}%
10680 \else
10681 $\m@th\vcenter{#1}$%
10682 \fi
10683 }
10684 % \end{macrocode}
10685 %
10686 % \macro{\eql@box@start}
10687 % \begin{macrocode}
10688 \let\eql@box@endmath\eql@false
10689 \def\eql@box@start{%
10690 \relax
10691 \ifmmode
10692 \let\eql@box@endmath\eql@false
10693 \else
10694 \let\eql@box@endmath\eql@true
10695 \expandafter$%$
10696 \fi
10697 \eql@beamerbasecolor@avoid
10698 \eql@stack@save@box
10699 \let\eql@frame@cmd\@undefined
10700 \let\eql@layoutleft\eql@false
10701 \eql@row@\z@
10702 \eql@totalrows@\@M
10703 \eql@shape@select
10704 \setbox\z@\ifx\eql@box@box\vcenter
10705 \expandafter\vbox
10706 \else
10707 \expandafter\eql@box@box
10708 \fi\bgroup
10709 \let\eqnpunct\eql@punct@setnext
10710 \eql@display@nest
10711 \let\\\eql@box@cr
10712 \ifdefined\eql@amp@mode
10713 \let\&\eql@box@amp
10714 \fi
10715 \eql@spread@set
10716 \eql@strut@make
10717 \eql@box@open
10718 }
10719 % \end{macrocode}
10720 %
10721 % \macro{\eql@box@end}
10722 % \begin{macrocode}
10723 \def\eql@box@end{%
10724 \eql@box@close
10725 \egroup
10726 \eql@box@frame{%
10727 \ifdefined\eql@display@marginleft
10728 \hskip\glueexpr\eql@display@marginleft\relax
10729 \fi
10730 \ifx\eql@box@box\vcenter
10731 \eql@box@vcenter{\unvbox\z@}%
10732 \else
10733 \box\z@
10734 \fi
10735 \eql@tagging@tableaddinner
10736 \ifdefined\eql@display@marginright
10737 \hskip\glueexpr\eql@display@marginright\relax
10738 \fi
10739 }%
10740 \eql@stack@restore
10741 \ifdefined\eql@box@endmath
10742 \expandafter$%$
10743 \fi
10744 }
10745 % \end{macrocode}
10746 %
10747 % \macro{\eql@box@main}
10748 % Combined opening, body and closing for pre-scanned body:
10749 % \begin{macrocode}
10750 \def\eql@box@main{%
10751 \eql@box@start
10752 \eql@scan@body
10753 \eql@box@end
10754 }
10755 % \end{macrocode}
10756 %
10757 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10758 % \subsection{Options Processing}
10759 %
10760 % \TODO describe
10761 % \begin{macrocode}
10762 \def\eql@box@test@setopt{\let\eql@box@test\eql@box@testopt}
10763 \def\eql@box@test@setall{\let\eql@box@test\eql@box@testall}
10764 % \end{macrocode}
10765 %
10766 % \macro{\eql@box@testopt}
10767 % \TODO describe
10768 % \begin{macrocode}
10769 \def\eql@box@testopt#1{\eql@testopt@tight{\eql@box@testopt@set{#1}}{}}
10770 \def\eql@box@testopt@set#1[#2]{\eqnaddopt{#2}#1}
10771 % \end{macrocode}
10772 %
10773 % \begin{macrocode}
10774 \def\eql@box@testall{\eql@parseopt@env\eql@box@testall@parse}
10775 \def\eql@box@testall@parse{%
10776 \ifx\eql@parseopt@token[%]
10777 \let\eql@parseopt@next\eql@parseopt@opt
10778 \fi
10779 \ifx\eql@parseopt@token.%
10780 \let\eql@parseopt@next\eql@parseopt@punctpass
10781 \fi
10782 \ifx\eql@parseopt@token,%
10783 \let\eql@parseopt@next\eql@parseopt@punctpass
10784 \fi
10785 \ifx\eql@parseopt@token~%
10786 \let\eql@parseopt@next\eql@parseopt@punctpass
10787 \fi
10788 \ifx\eql@parseopt@token`%
10789 \let\eql@parseopt@next\eql@parseopt@punctopt
10790 \fi
10791 \ifx\eql@parseopt@token!%
10792 \let\eql@parseopt@next\eql@box@parse@punctterm
10793 \fi
10794 \ifx\eql@parseopt@token=%
10795 \let\eql@parseopt@next\eql@parseopt@lines
10796 \fi
10797 \ifx\eql@parseopt@token|%
10798 \let\eql@parseopt@next\eql@parseopt@columns
10799 \fi
10800 \ifx\eql@parseopt@token<%
10801 \let\eql@parseopt@next\eql@parseopt@ampeq
10802 \fi
10803 \ifx\eql@parseopt@token>%
10804 \let\eql@parseopt@next\eql@parseopt@eqamp
10805 \fi
10806 }
10807 \def\eql@box@parse@punctterm#1{\eqnaddopt{punctterm}\eql@parseopt@peek}
10808 % \end{macrocode}
10809 %
10810 % \macro{\eql@box@end@testall}
10811 % \TODO describe
10812 % \begin{macrocode}
10813 \def\eql@box@end@testall{\eql@parseopt@env\eql@box@end@testall@parse}
10814 \def\eql@box@end@testall@parse{%
10815 \ifx\eql@parseopt@token.%
10816 \let\eql@parseopt@next\eql@parseopt@punctpass
10817 \fi
10818 \ifx\eql@parseopt@token,%
10819 \let\eql@parseopt@next\eql@parseopt@punctpass
10820 \fi
10821 \ifx\eql@parseopt@token~%
10822 \let\eql@parseopt@next\eql@parseopt@punctpass
10823 \fi
10824 \ifx\eql@parseopt@token`%
10825 \let\eql@parseopt@next\eql@parseopt@punctblock
10826 \fi
10827 \ifx\eql@parseopt@token!%
10828 \let\eql@parseopt@next\eql@box@end@parse@punctterm
10829 \fi
10830 \ifx\eql@parseopt@token$%$
10831 \let\eql@parseopt@next\eql@parseopt@end
10832 \fi
10833 }
10834 \def\eql@box@end@parse@punctterm#1{%
10835 \let\eql@box@punct@term\eql@true\eql@parseopt@peek}
10836 % \end{macrocode}
10837 %
10838 % \macro{\eql@box@processopt}
10839 % \TODO describe
10840 % \begin{macrocode}
10841 \def\eql@box@processopt{%
10842 \let\eql@box@frame\@firstofone
10843 \let\eql@display@marginleft\@undefined
10844 \let\eql@display@marginright\@undefined
10845 \let\eql@box@punct@term\eql@false
10846 \let\eql@punct@block\@undefined
10847 \eql@nextopt@process{box}%
10848 \let\eql@punct@next\@undefined
10849 \eql@colsep@\glueexpr\eql@box@colsep\relax
10850 \ifdefined\eql@paddingleft@val
10851 \eql@paddingleft@\glueexpr\eql@paddingleft@val\relax
10852 \else
10853 \eql@paddingleft@\z@
10854 \fi
10855 \ifdefined\eql@paddingright@val
10856 \eql@paddingright@\glueexpr\eql@paddingright@val\relax
10857 \else
10858 \eql@paddingright@\z@
10859 \fi
10860 \eql@indent@\glueexpr\eql@indent@val\relax
10861 }
10862 % \end{macrocode}
10863 %
10864 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10865 % \subsection{Environment}
10866 %
10867 % \environment{equationsbox}
10868 % \begin{macrocode}
10869 \newenvironment{equationsbox}{%
10870 \eql@verbose@info\eql@verbose@msg@enterenv
10871 \ifdefined\eql@box@env@modifier
10872 \eql@box@test@setall
10873 \else
10874 \eql@box@nomodifier
10875 \fi
10876 \eql@ampprotect\eql@box@test\eql@box@env@start
10877 }{%
10878 \ifdefined\eql@box@doscan\else
10879 \expandafter\eql@box@end
10880 \fi
10881 \eql@verbose@info\eql@verbose@msg@leaveenv
10882 }
10883 % \end{macrocode}
10884 %
10885 % \macro{\eql@box@env@start}
10886 % \begin{macrocode}
10887 \def\eql@box@env@start{%
10888 \eql@box@processopt
10889 \ifdefined\eql@box@doscan
10890 \eql@box@call@set
10891 \expandafter\eql@scan@env
10892 \else
10893 \expandafter\eql@box@start
10894 \fi
10895 }
10896 % \end{macrocode}
10897 %
10898 % \macro{\eql@box@call}
10899 % \begin{macrocode}
10900 \def\eql@box@call{\eql@box@main\eql@scan@end}
10901 \def\eql@box@call@test{%
10902 \eql@ampprotect\eql@box@end@testall\eql@box@call}
10903 \def\eql@box@call@set{%
10904 \ifdefined\eql@box@end@modifier
10905 \let\eql@scan@call\eql@box@call@test
10906 \else
10907 \let\eql@scan@call\eql@box@call
10908 \fi
10909 }
10910 % \end{macrocode}
10911 %
10912 % \macro{\eql@box@ang@open}
10913 % \begin{macrocode}
10914 \newenvironment{equationsbox@ang}{}{}
10915 \def\eql@box@ang@open{%
10916 \expandafter\eqnaddopt\expandafter{\eql@box@ang@opt}%
10917 \begin{equationsbox@ang}%
10918 \eql@verbose@info\eql@verbose@msg@enterenv
10919 \let\>\eql@box@ang@close
10920 \ifdefined\eql@box@ang@modifier
10921 \eql@box@test@setall
10922 \else
10923 \eql@box@nomodifier
10924 \fi
10925 \eql@ampprotect\eql@box@test\eql@box@ang@start
10926 }
10927 % \end{macrocode}
10928 %
10929 % \macro{\eql@box@ang@start}
10930 % Process arguments and start handling the box:
10931 % \begin{macrocode}
10932 \def\eql@box@ang@start{%
10933 \eql@box@processopt
10934 \ifdefined\eql@box@doscan
10935 \eql@box@call@set
10936 \expandafter\eql@scan@ang
10937 \else
10938 \expandafter\eql@box@start
10939 \fi
10940 }
10941 % \end{macrocode}
10942 %
10943 % \macro{\eql@box@ang@close}
10944 % \TODO describe
10945 % \begin{macrocode}
10946 \def\eql@box@ang@close{%
10947 \ifdefined\eql@box@doscan
10948 \let\eql@box@end@modifier\eql@false
10949 \fi
10950 \ifdefined\eql@box@end@modifier
10951 \expandafter\eql@ampprotect\expandafter\eql@box@end@testall
10952 \fi
10953 \eql@box@ang@end
10954 }
10955 % \end{macrocode}
10956 %
10957 % \macro{\eql@box@ang@end}
10958 % \TODO describe
10959 % \begin{macrocode}
10960 \def\eql@box@ang@end{%
10961 \ifdefined\eql@box@doscan\else
10962 \expandafter\eql@box@end
10963 \fi
10964 \eql@verbose@info\eql@verbose@msg@leaveenv
10965 \end{equationsbox@ang}%
10966 \ignorespaces
10967 }
10968 % \end{macrocode}
10969 %
10970 %
10971 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10972 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10973 % \section{Single-Line Equation}
10974 %
10975 % \TODO describe
10976 %
10977 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10978 % \subsection{Native Mode}
10979 %
10980 % \begin{macrocode}
10981 \def\eql@single@start@native{%
10982 \eql@display@init
10983 \eql@display@print
10984 \let\raisetag\eql@raisetag@default
10985 \eql@shape@align@disable
10986 \eql@hook@eqin
10987 }%
10988 % \end{macrocode}
10989 %
10990 % \TODO describe
10991 % \begin{macrocode}
10992 \def\eql@single@end@native{%
10993 \eql@tags@container
10994 \eql@numbering@single@eval
10995 \if@eqnsw
10996 \ifdefined\eql@tagsleft
10997 \leqno
10998 \else
10999 \eqno
11000 \fi
11001 \eql@composetag@print
11002 \fi
11003 \eql@interline@container
11004 \advance\eql@belowspace@\eql@vspaceskip@
11005 \eql@display@container
11006 \eql@display@penalty
11007 \eql@display@vspace@native
11008 }%
11009 % \end{macrocode}
11010 %
11011 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11012 % \subsection{Print}
11013 %
11014 % \begin{macrocode}
11015 \def\eql@single@start@print{%
11016 \eql@display@init
11017 \eql@display@print
11018 \eql@shape@align@enable
11019 % \end{macrocode}
11020 %
11021 % \begin{macrocode}
11022 \eql@totalrows@\@ne
11023 \eql@row@\@ne
11024 \eql@arrange@init
11025 \global\let\eql@cell@container\@empty
11026 % \end{macrocode}
11027 %
11028 % \begin{macrocode}
11029 \prevgraf\numexpr\prevgraf+\@ne\relax
11030 \setbox\eql@cellbox@\hbox\bgroup
11031 \eql@restore@hfuzz
11032 \eql@strut@cell
11033 $\m@th\eql@mathstyle%$
11034 \eql@hook@eqin
11035 }
11036 % \end{macrocode}
11037 %
11038 % \begin{macrocode}
11039 \def\eql@single@end@print{%
11040 \eql@tagging@mathsave
11041 $%$
11042 \hfil
11043 \kern\z@
11044 \egroup
11045 \prevgraf\numexpr\prevgraf-\@ne\relax
11046 % \end{macrocode}
11047 %
11048 % \begin{macrocode}
11049 \eql@shape@eval
11050 \eql@cell@container
11051 % \end{macrocode}
11052 %
11053 % \begin{macrocode}
11054 \ifdefined\eql@frame@cmd
11055 \eql@frame@adjust
11056 \fi
11057 % \end{macrocode}
11058 %
11059 % \begin{macrocode}
11060 \eql@cellwidth@\wd\eql@cellbox@
11061 \eql@line@height@\ht\eql@cellbox@
11062 \eql@line@depth@\dp\eql@cellbox@
11063 \eql@totalwidth@\eql@cellwidth@
11064 \eql@totalheight@\dimexpr\eql@line@height@+\eql@line@depth@\relax
11065 \eql@topheight@\eql@line@height@
11066 \eql@bottomdepth@\eql@line@depth@
11067 % \end{macrocode}
11068 %
11069 % \begin{macrocode}
11070 \eql@tags@container
11071 \eql@numbering@single@eval
11072 \if@eqnsw
11073 \eql@tagbox@make\eql@composetag@print
11074 \eql@tagrows@\@ne
11075 \ifdefined\eql@tagpos@reserve\else
11076 \eql@tagwidth@\z@
11077 \fi
11078 \eql@tagheight@block@\ht\eql@tagbox@
11079 \eql@tagdepth@block@\dp\eql@tagbox@
11080 \else
11081 \eql@numbering@warnunused
11082 \eql@tagwidth@\z@
11083 \eql@tagrows@\z@
11084 \fi
11085 \eql@tagwidth@max@\eql@tagwidth@
11086 \eql@tagpos@single@eval
11087 \eql@tagpos@print@line@eval
11088 % \end{macrocode}
11089 %
11090 % \begin{macrocode}
11091 \eql@intercolumns@\z@
11092 \eql@adjust@calc@lines
11093 % \end{macrocode}
11094 %
11095 % \begin{macrocode}
11096 \eql@display@halign@init{}%
11097 \halign{##\crcr
11098 \noalign{\eql@display@halign@start}%
11099 \eql@arrange@print@line
11100 \cr
11101 \noalign{\eql@display@halign@end}%
11102 \eql@tagging@tablesavelines
11103 }%
11104 \eql@tagpos@print@line@end
11105 \eql@display@close
11106 }
11107 % \end{macrocode}
11108 %
11109 %
11110 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11111 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11112 % \section{Multi-Line with Single Column}
11113 %
11114 % \TODO outline sequence of calls
11115 %
11116 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11117 % \subsection{Measure}
11118 %
11119 % \TODO describe
11120 %
11121 % \begin{macrocode}
11122 \def\eql@lines@measure@line@begin{%
11123 \eql@verbose@info\eql@verbose@msg@startline@number
11124 \eql@numbering@measure@line@begin
11125 \eql@hook@linein
11126 }
11127 % \end{macrocode}
11128 %
11129 % \TODO describe
11130 % \begin{macrocode}
11131 \def\eql@lines@measure@line@end{%
11132 \eql@punct@apply@line
11133 \eql@hook@lineout
11134 }
11135 % \end{macrocode}
11136 %
11137 % \TODO describe
11138 % \TODO it would be an option to add the absolute shove amount
11139 % to the calculation of the maximum width
11140 % \begin{macrocode}
11141 \def\eql@lines@measure@cell{%
11142 \ifdefined\eql@frame@cmd
11143 \ifcase\eql@shape@pos@
11144 \eql@frame@measure
11145 \advance\eql@shape@amount@-\eql@frame@margin@
11146 \or\or
11147 \eql@frame@measure
11148 \advance\eql@shape@amount@+\eql@frame@margin@
11149 \fi
11150 \eql@frame@print
11151 \fi
11152 \eql@cellwidth@\wd\eql@cellbox@
11153 \eql@line@height@\ht\eql@cellbox@
11154 \eql@line@depth@\dp\eql@cellbox@
11155 \eql@dimensions@startrow
11156 \eql@dimensions@savecell
11157 \kern\eql@cellwidth@
11158 }
11159 % \end{macrocode}
11160 %
11161 % \macro{\eql@lines@measure}
11162 % \begin{macrocode}
11163 \def\eql@lines@measure{%
11164 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@lines@measure
11165 \eql@measure@init\eql@lines@measure@line@begin\eql@lines@measure@line@end
11166 \ifdefined\eql@amp@mode
11167 \let\&\eql@break@amp
11168 \fi
11169 \eql@totalrows@\@M
11170 \eql@shape@select
11171 % \end{macrocode}
11172 %
11173 % \begin{macrocode}
11174 \setbox\z@\vbox{\measuring@true\halign{%
11175 \global\let\eql@cell@container\@empty
11176 \setbox\eql@cellbox@\hbox{%
11177 \eql@strut@cell
11178 \@lign
11179 $\m@th\eql@mathstyle
11180 \eql@hook@colin
11181 ##%
11182 \eql@punct@apply@col
11183 \eql@hook@colout
11184 $%
11185 }%
11186 \ifdefined\eql@shape@lastrow
11187 \eql@totalrows@\eql@row@
11188 \fi
11189 \eql@shape@eval
11190 \eql@cell@container
11191 \eql@lines@measure@cell
11192 \eql@measure@tag
11193 \eql@measure@endrow
11194 \crcr
11195 % \end{macrocode}
11196 %
11197 % \begin{macrocode}
11198 \noalign{%
11199 \global\let\eql@shape@lastrow\eql@false
11200 \eql@hook@blockbefore
11201 }%
11202 \eql@hook@blockin
11203 \eql@scan@body
11204 \ifvmode\else
11205 \global\let\eql@shape@lastrow\eql@true
11206 \eql@punct@apply@block
11207 \eql@hook@blockout
11208 \eql@multi@endline
11209 \cr
11210 \fi
11211 \omit
11212 \cr
11213 \noalign{%
11214 \eql@hook@blockafter
11215 \global\let\eql@shape@lastrow\eql@false
11216 }%
11217 }}%
11218 % \end{macrocode}
11219 %
11220 % \begin{macrocode}
11221 \eql@measure@close
11222 % \end{macrocode}
11223 %
11224 % \begin{macrocode}
11225 \setbox\z@\vbox{%
11226 \unvbox\z@
11227 \unpenalty
11228 \global\setbox\@ne\lastbox
11229 }%
11230 \eql@totalwidth@\wd\@ne
11231 % \end{macrocode}
11232 %
11233 % \begin{macrocode}
11234 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@lines@measure
11235 }
11236 % \end{macrocode}
11237 %
11238 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11239 % \subsection{Column Placement}
11240 %
11241 % \TODO describe
11242 % Find the best row for tag placement:
11243 % \begin{macrocode}
11244 \def\eql@lines@adjust{%
11245 \eql@tagpos@adjust@eval
11246 \eql@adjust@calc@lines
11247 \eql@numbering@best@eval
11248 }
11249 % \end{macrocode}
11250 %
11251 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11252 % \subsection{Print}
11253 %
11254 % \TODO describe
11255 %
11256 % \macro{\eql@lines@print@line@begin}
11257 % \begin{macrocode}
11258 \def\eql@lines@print@line@begin{%
11259 \eql@verbose@info\eql@verbose@msg@startline@number
11260 \eql@numbering@print@line@begin
11261 \eql@hook@linein
11262 }
11263 % \end{macrocode}
11264 %
11265 % \TODO describe
11266 % \begin{macrocode}
11267 \def\eql@lines@print@line@end{%
11268 \eql@punct@apply@line
11269 \eql@hook@lineout
11270 }
11271 % \end{macrocode}
11272 %
11273 % \TODO describe
11274 % \begin{macrocode}
11275 \def\eql@lines@print@line@adjust{%
11276 \ifdefined\eql@frame@cmd
11277 \ifcase\eql@shape@pos@
11278 \eql@frame@measure
11279 \advance\eql@shape@amount@-\eql@frame@margin@
11280 \or\or
11281 \eql@frame@measure
11282 \advance\eql@shape@amount@+\eql@frame@margin@
11283 \fi
11284 \eql@frame@adjust
11285 \fi
11286 \eql@cellwidth@\wd\eql@cellbox@
11287 \eql@line@height@\ht\eql@cellbox@
11288 \eql@line@depth@\dp\eql@cellbox@
11289 \eql@numbering@print@line@eval
11290 \if@eqnsw
11291 \eql@tagbox@make\eql@composetag@print
11292 \fi
11293 \eql@tagpos@print@line@eval
11294 \eql@arrange@print@line
11295 \eql@tagpos@print@line@end
11296 }
11297 % \end{macrocode}
11298 %
11299 % \TODO describe
11300 % \begin{macrocode}
11301 \def\eql@lines@print{%
11302 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@lines@print
11303 \eql@arrange@init
11304 \eql@display@halign@init\eql@lines@print@line@begin
11305 \eql@multi@cr@let\eql@lines@print@line@end
11306 \ifdefined\eql@amp@mode
11307 \let\&\eql@break@amp
11308 \fi
11309 \tabskip\z@skip
11310 % \end{macrocode}
11311 %
11312 % \begin{macrocode}
11313 \halign{%
11314 \global\let\eql@cell@container\@empty
11315 \setbox\eql@cellbox@\hbox{%
11316 \eql@restore@hfuzz
11317 \eql@strut@cell
11318 \@lign
11319 $\m@th\eql@mathstyle
11320 \eql@hook@colin
11321 ##%
11322 \eql@punct@apply@col
11323 \eql@hook@colout
11324 \eql@tagging@mathsave
11325 $%
11326 \hfil
11327 \kern\z@
11328 }%
11329 \eql@shape@eval
11330 \eql@cell@container
11331 \eql@lines@print@line@adjust
11332 \crcr
11333 % \end{macrocode}
11334 %
11335 % \begin{macrocode}
11336 \noalign{%
11337 \eql@display@halign@start
11338 \eql@numbering@print@block@begin
11339 \eql@hook@blockbefore
11340 }%
11341 \eql@hook@blockin
11342 \eql@scan@body
11343 \ifvmode\else
11344 \relax
11345 \eql@punct@apply@block
11346 \eql@hook@blockout
11347 \eql@multi@endline
11348 \cr
11349 \fi
11350 \noalign{%
11351 \eql@hook@blockafter
11352 \eql@display@halign@end
11353 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@lines@print
11354 }%
11355 \eql@tagging@tablesavelines
11356 }%
11357 }
11358 % \end{macrocode}
11359 %
11360 %
11361 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11362 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11363 % \section{Multi-Line with Multiple Columns}
11364 %
11365 % \TODO describe
11366 % \TODO outline sequence of calls
11367 %
11368 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11369 % \subsection{Support}
11370 %
11371 % \TODO describe
11372 %
11373 % \macro{\eql@columns@add@amp}
11374 % \macro{\eql@columns@completerow}
11375 % \begin{macrocode}
11376 \def\eql@columns@add@amp#1{\if m#1&\omit\expandafter\eql@columns@add@amp\fi}
11377 \def\eql@columns@completerow{%
11378 \count@\numexpr\eql@totalcolumns@+\@ne-\eql@column@\relax
11379 \edef\eql@tmp{%
11380 \expandafter\eql@columns@add@amp\romannumeral\number\count@ 000q}%
11381 \eql@tmp
11382 }
11383 % \end{macrocode}
11384 %
11385 % \begin{macrocode}
11386 \def\eql@columns@overfull{%
11387 \dimen@\eql@line@width@
11388 \advance\dimen@-\hfuzz
11389 \ifdim\dimen@>\displaywidth
11390 \setbox\z@\hbox to\displaywidth{\hbox to\eql@line@width@{\hfil}}%
11391 \wd\z@\z@
11392 \ht\z@\eql@line@height@
11393 \dp\z@\eql@line@depth@
11394 \box\z@
11395 \fi
11396 }
11397 % \end{macrocode}
11398 %
11399 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11400 % \subsection{Column Breaks}
11401 %
11402 % \TODO describe
11403 %
11404 % \TODO describe
11405 % \begin{macrocode}
11406 \let\eql@amp@org\&
11407 % \end{macrocode}
11408 %
11409 % \begin{macrocode}
11410 \def\eql@columns@amp{%
11411 \eql@ampprotecttwo\eql@columns@amp@testescape\eql@amp@org
11412 \eql@columns@amp@process}
11413 \def\eql@columns@amp@testescape#1#2{\eql@ifnextgobble@tight/{#1}{%
11414 \relax
11415 \let\eql@punct@term\eql@false
11416 \let\eql@class@rel@composed\@empty
11417 \eql@columns@amp@test{#2}}}
11418 % \end{macrocode}
11419 %
11420 % \TODO describe
11421 % \begin{macrocode}
11422 \def\eql@columns@amp@test@setopt{%
11423 \let\eql@columns@amp@test\eql@columns@amp@testopt}
11424 \def\eql@columns@amp@test@setall{%
11425 \let\eql@columns@amp@test\eql@columns@amp@testall}
11426 % \end{macrocode}
11427 %
11428 % \macro{\eql@columns@amp@testopt}
11429 % \TODO describe
11430 % \begin{macrocode}
11431 \let\eql@columns@amp@testopt\@empty
11432 % \end{macrocode}
11433 %
11434 % \macro{\eql@columns@amp@testall}
11435 % \macro{\eql@columns@amp@testall@parse}
11436 % \TODO describe
11437 % \begin{macrocode}
11438 \def\eql@columns@amp@testall{\eql@parseopt@cr\eql@columns@amp@testall@parse}
11439 \def\eql@columns@amp@testall@parse{%
11440 \ifx\eql@parseopt@token.%
11441 \let\eql@parseopt@next\eql@parseopt@punctpass
11442 \fi
11443 \ifx\eql@parseopt@token,%
11444 \let\eql@parseopt@next\eql@parseopt@punctpass
11445 \fi
11446 \ifx\eql@parseopt@token~%
11447 \let\eql@parseopt@next\eql@parseopt@punctpass
11448 \fi
11449 \ifx\eql@parseopt@token`%
11450 \let\eql@parseopt@next\eql@parseopt@punctnext
11451 \fi
11452 \ifx\eql@parseopt@token!%
11453 \let\eql@parseopt@next\eql@parseopt@punctterm
11454 \fi
11455 \ifx\eql@parseopt@token=%
11456 \let\eql@parseopt@next\eql@parseopt@relsymb
11457 \fi
11458 \ifx\eql@parseopt@token;%
11459 \let\eql@parseopt@next\eql@parseopt@relcont
11460 \fi
11461 \ifx\eql@parseopt@token:%
11462 \let\eql@parseopt@next\eql@parseopt@relstart
11463 \fi
11464 \ifx\eql@parseopt@token|%
11465 \let\eql@parseopt@next\eql@parseopt@relord
11466 \fi
11467 \ifx\eql@parseopt@token?%
11468 \let\eql@parseopt@next\eql@columns@amp@parse@rel
11469 \fi
11470 \ifx\eql@parseopt@token&%
11471 \let\eql@parseopt@next\eql@parseopt@end
11472 \fi
11473 }
11474 \def\eql@columns@amp@parse@rel#1#2{%
11475 \def\eql@class@rel@composed{\eql@class@rel@make{#2}}%
11476 \eql@parseopt@end}
11477 % \end{macrocode}
11478 %
11479 % \macro{\eql@columns@amp@process}
11480 % \begin{macrocode}
11481 \def\eql@columns@amp@process{%
11482 \ifdefined\eql@punct@term\eql@punct@apply@top\fi
11483 \edef\eql@tmp{%
11484 \ifx\eql@class@rel@composed\@empty
11485 \ifodd\eql@column@&\noexpand\eql@punct@next@clear\fi&%
11486 \else
11487 \ifodd\eql@column@\else&\fi%
11488 \unexpanded\expandafter{\eql@class@rel@composed}%
11489 \fi
11490 }%
11491 \eql@tmp
11492 }
11493 % \end{macrocode}
11494 %
11495 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11496 % \subsection{Transpose}
11497 %
11498 % \TODO describe
11499 %
11500 % \TODO adjust to |\&|?!
11501 %
11502 % \TODO describe
11503 % \begin{macrocode}
11504 \let\eql@transpose@active\eql@false
11505 \def\eql@transpose@end{\eql@transpose@end}
11506 \def\eql@transpose@skip{&\eql@punct@next@clear}
11507 \def\eql@transpose@complete{%
11508 \relax\ifodd\eql@column@\expandafter\eql@transpose@skip\fi&}
11509 % \end{macrocode}
11510 %
11511 % \TODO describe
11512 % \begin{macrocode}
11513 \def\eql@transpose{%
11514 \eql@totalcolumns@\z@
11515 \eql@totalrows@\z@
11516 \expandafter\eql@transpose@scan@col\the\eql@scan@reg@\&\eql@transpose@end\&%
11517 \eql@scan@reg@{}%
11518 \eql@row@\z@
11519 \eql@transpose@output@row
11520 }
11521 % \end{macrocode}
11522 %
11523 % \TODO describe
11524 % \begin{macrocode}
11525 \def\eql@transpose@save@col#1{%
11526 \@namedef{eql@transpose@data@col@\the\eql@totalcolumns@}{%
11527 \ifcase\eql@row@#1\else\let\eql@tmp\eql@transpose@skip\fi}}
11528 % \end{macrocode}
11529 %
11530 % \TODO describe
11531 % \begin{macrocode}
11532 \def\eql@transpose@scan@col#1\&{%
11533 \def\eql@tmpa{#1}%
11534 \ifx\eql@tmpa\eql@transpose@end\else
11535 \advance\eql@totalcolumns@\@ne
11536 \eql@row@\z@
11537 \let\eql@transpose@data@col\@empty
11538 \eql@transpose@scan@row#1\\\eql@transpose@end\\%
11539 \ifnum\eql@row@>\eql@totalrows@
11540 \eql@totalrows@\eql@row@
11541 \fi
11542 \expandafter\eql@transpose@save@col\expandafter{\eql@transpose@data@col}%
11543 \expandafter\eql@transpose@scan@col
11544 \fi
11545 }
11546 % \end{macrocode}
11547 %
11548 % \TODO describe
11549 % \begin{macrocode}
11550 \def\eql@transpose@append@row#1{%
11551 \advance\eql@row@\@ne
11552 \eql@append\eql@transpose@data@col{\or\def\eql@tmp{#1}}}
11553 % \end{macrocode}
11554 %
11555 % \TODO describe
11556 % \begin{macrocode}
11557 \def\eql@transpose@scan@row#1\\{%
11558 \def\eql@tmpa{#1}%
11559 \ifx\eql@tmpa\eql@transpose@end\else
11560 \ifx\eql@transpose@active+
11561 \eql@transpose@scan@cell#1&\eql@transpose@end&%
11562 \else
11563 \eql@transpose@append@row{#1}%
11564 \fi
11565 \expandafter\eql@transpose@scan@row
11566 \fi
11567 }
11568 % \end{macrocode}
11569 %
11570 % \TODO describe
11571 % \begin{macrocode}
11572 \def\eql@transpose@scan@cell#1&#2&{%
11573 \def\eql@tmpa{#2}%
11574 \ifx\eql@tmpa\eql@transpose@end
11575 \eql@transpose@append@row{#1}%
11576 \else
11577 \eql@transpose@append@row{#1&#2}%
11578 \expandafter\eql@transpose@scan@cell@next
11579 \fi
11580 }
11581 % \end{macrocode}
11582 %
11583 % \TODO describe
11584 % \begin{macrocode}
11585 \def\eql@transpose@scan@cell@next#1&{%
11586 \def\eql@tmpa{#1}%
11587 \ifx\eql@tmpa\eql@transpose@end\else
11588 \eql@transpose@append@row{&#1}%
11589 \expandafter\eql@transpose@scan@cell@next
11590 \fi
11591 }
11592 % \end{macrocode}
11593 %
11594 % \TODO describe
11595 % \begin{macrocode}
11596 \def\eql@transpose@output@row{%
11597 \ifnum\eql@row@<\eql@totalrows@
11598 \advance\eql@row@\@ne
11599 \eql@column@\z@
11600 \eql@transpose@output@col
11601 \ifnum\eql@row@<\eql@totalrows@
11602 \eql@scan@addto\\%
11603 \fi
11604 \expandafter\eql@transpose@output@row
11605 \fi
11606 }
11607 % \end{macrocode}
11608 %
11609 % \TODO describe
11610 % \begin{macrocode}
11611 \def\eql@transpose@output@col{%
11612 \ifnum\eql@column@<\eql@totalcolumns@
11613 \advance\eql@column@\@ne
11614 \csname eql@transpose@data@col@\the\eql@column@\endcsname
11615 \expandafter\eql@scan@addto\expandafter{\eql@tmp}%
11616 \ifnum\eql@column@<\eql@totalcolumns@
11617 \eql@scan@addto{\eql@transpose@complete}%
11618 \fi
11619 \expandafter\eql@transpose@output@col
11620 \fi
11621 }
11622 % \end{macrocode}
11623 %
11624 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11625 % \subsection{Measure}
11626 %
11627 % \TODO describe
11628 % \TODO this is called also for extra line and concluding cr
11629 % \macro{\eql@columns@measure@line@begin}
11630 % \begin{macrocode}
11631 \def\eql@columns@measure@line@begin{%
11632 \eql@verbose@info\eql@verbose@msg@startline@number
11633 \global\eql@column@\z@
11634 \global\eql@line@height@\z@
11635 \global\eql@line@depth@\z@
11636 \eql@numbering@measure@line@begin
11637 \eql@hook@linein
11638 }
11639 % \end{macrocode}
11640 %
11641 % \begin{macrocode}
11642 \def\eql@columns@measure@cell{%
11643 \eql@cellwidth@\wd\eql@cellbox@
11644 \ifdefined\eql@frame@cmd
11645 \eql@frame@measure
11646 \advance\eql@cellwidth@\eql@frame@margin@
11647 \fi
11648 \ifdim\ht\eql@cellbox@>\eql@line@height@
11649 \global\eql@line@height@\ht\eql@cellbox@
11650 \fi
11651 \ifdim\dp\eql@cellbox@>\eql@line@depth@
11652 \global\eql@line@depth@\dp\eql@cellbox@
11653 \fi
11654 \ifnum\eql@column@=\@ne
11655 \eql@dimensions@startrow
11656 \fi
11657 \ifodd\eql@column@
11658 \eql@shape@pos@\tw@
11659 \else
11660 \eql@shape@pos@\z@
11661 \fi
11662 \eql@shape@amount@\z@
11663 \eql@dimensions@savecell
11664 \ifodd\eql@column@\else
11665 \eql@dimensions@savesep
11666 \fi
11667 \kern\eql@cellwidth@
11668 }
11669 % \end{macrocode}
11670 %
11671 % \macro{\eql@columns@measure@line@end}
11672 % \begin{macrocode}
11673 \def\eql@columns@measure@line@end{%
11674 \eql@punct@apply@line
11675 \eql@hook@lineout
11676 &\omit
11677 \ifnum\eql@column@>\eql@totalcolumns@
11678 \global\eql@totalcolumns@\eql@column@
11679 \fi
11680 % \end{macrocode}
11681 % \TODO not sure whether saving the last cell value makes sense,
11682 % but rather not increase |\eql@totalcolumns@|
11683 % because that will disable the fallback to lines mode.
11684 % \TODO additional column in width table is accounted for in column table
11685 % \begin{macrocode}
11686 \ifdefined\eql@frame@cmd
11687 \advance\eql@column@\@ne
11688 \wd\eql@cellbox@\z@
11689 \eql@columns@measure@cell
11690 \fi
11691 \eql@measure@tag
11692 \eql@measure@endrow
11693 }
11694 % \end{macrocode}
11695 %
11696 % \macro{\eql@columns@measure}
11697 % \begin{macrocode}
11698 \def\eql@columns@measure{%
11699 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@columns@measure
11700 \eql@totalcolumns@\z@
11701 \eql@measure@init\eql@columns@measure@line@begin\eql@columns@measure@line@end
11702 \ifdefined\eql@amp@mode
11703 \let\&\eql@columns@amp
11704 \fi
11705 % \end{macrocode}
11706 %
11707 % \begin{macrocode}
11708 \setbox\z@\vbox{\measuring@true\halign{%
11709 &%
11710 \global\advance\eql@column@\@ne
11711 \global\let\eql@cell@container\@empty
11712 \global\setbox\eql@cellbox@\hbox{%
11713 \eql@strut@cell
11714 \@lign
11715 $\m@th\eql@mathstyle
11716 \eql@hook@colin
11717 ##%
11718 \eql@punct@apply@next
11719 \eql@class@innerleft
11720 \eql@hook@innerleft
11721 $%
11722 }%
11723 \eql@cell@container
11724 \hfil
11725 \eql@columns@measure@cell
11726 \global\let\eql@frame@prevcmd\eql@frame@cmd
11727 &%
11728 \eql@prevwidth@\wd\eql@cellbox@
11729 \let\eql@frame@cmd\eql@frame@prevcmd
11730 \global\advance\eql@column@\@ne
11731 \global\let\eql@cell@container\@empty
11732 \setbox\eql@cellbox@\hbox{%
11733 \eql@strut@cell
11734 \@lign
11735 $\m@th\eql@mathstyle
11736 \eql@hook@innerright
11737 \eql@class@innerright@sel
11738 ##%
11739 \eql@punct@apply@col
11740 \eql@hook@colout
11741 $%
11742 }%
11743 \eql@cell@container
11744 \eql@columns@measure@cell
11745 \hfil
11746 \crcr
11747 % \end{macrocode}
11748 %
11749 % \begin{macrocode}
11750 \noalign{%
11751 \eql@hook@blockbefore
11752 }%
11753 \eql@hook@blockin
11754 \eql@scan@body
11755 % \end{macrocode}
11756 %
11757 % \begin{macrocode}
11758 \ifvmode\else
11759 \eql@punct@apply@block
11760 \eql@hook@blockout
11761 \eql@multi@endline
11762 \cr
11763 \fi
11764 \noalign{%
11765 \eql@hook@blockafter
11766 }%
11767 % \end{macrocode}
11768 % \TODO note we also include the tag column as a backup
11769 % \begin{macrocode}
11770 \omit
11771 \eql@column@\@ne
11772 \eql@columns@completerow
11773 \cr
11774 }}%
11775 % \end{macrocode}
11776 %
11777 % \begin{macrocode}
11778 \eql@measure@close
11779 % \end{macrocode}
11780 %
11781 % \begin{macrocode}
11782 \setbox\z@\vbox{%
11783 \unvbox\z@
11784 \unpenalty
11785 \global\setbox\@ne\lastbox
11786 }%
11787 \eql@totalwidth@\wd\@ne
11788 % \end{macrocode}
11789 %
11790 % \TODO why not recycle box contents altogether?!
11791 % \begin{macrocode}
11792 \let\eql@colwidth@tab\@empty
11793 \loop
11794 \setbox\@ne\hbox{%
11795 \unhbox\@ne
11796 \unskip
11797 \global\setbox\thr@@\lastbox
11798 }%
11799 \ifhbox\thr@@
11800 \eql@colwidth@save{\wd\thr@@}%
11801 \repeat
11802 % \end{macrocode}
11803 %
11804 % \begin{macrocode}
11805 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@columns@measure
11806 }
11807 % \end{macrocode}
11808 %
11809 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11810 % \subsection{Columns Placement}
11811 %
11812 % \TODO describe
11813 % Make sure we have complete pairs of right and left adjusted columns,
11814 % otherwise add a final empty column:
11815 % \begin{macrocode}
11816 \def\eql@columns@adjust{%
11817 \ifodd\eql@totalcolumns@
11818 \advance\eql@totalcolumns@\@ne
11819 \fi
11820 \eql@tagpos@adjust@eval
11821 \eql@adjust@calc@columns
11822 }
11823 % \end{macrocode}
11824 %
11825 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11826 % \subsection{Print}
11827 %
11828 % \TODO describe
11829 %
11830 % \macro{\eql@columns@print@line@begin}
11831 % \begin{macrocode}
11832 \def\eql@columns@print@line@begin{%
11833 \eql@verbose@info\eql@verbose@msg@startline@number
11834 \global\eql@column@\z@
11835 \global\eql@line@pos@\eql@marginleft@
11836 \global\eql@line@width@\z@
11837 \global\eql@line@avail@\eql@totalwidth@
11838 \global\eql@line@height@\z@
11839 \global\eql@line@depth@\z@
11840 \eql@numbering@print@line@begin
11841 \eql@hook@linein
11842 }
11843 % \end{macrocode}
11844 %
11845 % \macro{\eql@columns@print@cell}
11846 % \begin{macrocode}
11847 \def\eql@columns@print@cell{%
11848 \eql@cellwidth@\wd\eql@cellbox@
11849 \ifodd\eql@column@
11850 \ifdefined\eql@frame@cmd
11851 \eql@frame@measure
11852 \advance\eql@cellwidth@\eql@frame@margin@
11853 \fi
11854 \dimen@\z@
11855 \else
11856 \advance\eql@cellwidth@-\eql@prevwidth@
11857 % \end{macrocode}
11858 % draw a frame
11859 % \begin{macrocode}
11860 \ifdefined\eql@frame@cmd
11861 \eql@frame@measure
11862 \advance\eql@cellwidth@\eql@frame@margin@
11863 \advance\eql@prevwidth@\eql@frame@margin@
11864 \eql@frame@print
11865 \fi
11866 % \end{macrocode}
11867 % update height and depth
11868 % \begin{macrocode}
11869 \ifdim\ht\eql@cellbox@>\eql@line@height@
11870 \global\eql@line@height@\ht\eql@cellbox@
11871 \fi
11872 \ifdim\dp\eql@cellbox@>\eql@line@depth@
11873 \global\eql@line@depth@\dp\eql@cellbox@
11874 \fi
11875 % \end{macrocode}
11876 % print box
11877 % \begin{macrocode}
11878 \kern-\eql@prevwidth@
11879 \unhbox\eql@cellbox@
11880 \dimen@-\eql@cellwidth@
11881 \fi
11882 % \end{macrocode}
11883 % enforce given width:
11884 % hopefully measure was correct, but need a precise width for tag placement
11885 % \begin{macrocode}
11886 \advance\dimen@\eql@colwidth@get\eql@column@\relax
11887 \kern\dimen@
11888 % \end{macrocode}
11889 % update available and used space
11890 % \begin{macrocode}
11891 \dimen@\eql@colwidth@get\eql@column@\relax
11892 \ifdim\eql@cellwidth@>\z@
11893 \ifdim\eql@line@width@=\z@
11894 \eql@line@avail@\eql@line@pos@
11895 \ifodd\eql@column@
11896 \advance\eql@line@avail@\dimen@
11897 \advance\eql@line@avail@-\eql@cellwidth@
11898 \fi
11899 \global\eql@line@avail@\eql@line@avail@
11900 \fi
11901 \eql@line@width@\eql@line@pos@
11902 \ifodd\eql@column@
11903 \advance\eql@line@width@\dimen@
11904 \else
11905 \advance\eql@line@width@\eql@cellwidth@
11906 \fi
11907 \global\eql@line@width@\eql@line@width@
11908 \fi
11909 \advance\eql@line@pos@\dimen@
11910 \ifodd\eql@column@\else
11911 \advance\eql@line@pos@\eql@colsep@
11912 \fi
11913 \global\eql@line@pos@\eql@line@pos@
11914 }
11915 % \end{macrocode}
11916 %
11917 % \begin{macrocode}
11918 \def\eql@columns@print@trailright{%
11919 &\omit
11920 \eql@prevwidth@\wd\eql@cellbox@
11921 \let\eql@frame@cmd\eql@frame@prevcmd
11922 \global\advance\eql@column@\@ne
11923 \eql@columns@print@cell
11924 }
11925 % \end{macrocode}
11926 %
11927 % \macro{\eql@columns@print@line@end}
11928 % \TODO add an even column with empty stuff if box processing deferred
11929 % \begin{macrocode}
11930 \def\eql@columns@print@line@end{%
11931 \eql@punct@apply@line
11932 \eql@hook@lineout
11933 \ifodd\eql@column@
11934 \expandafter\eql@columns@print@trailright
11935 \fi
11936 \eql@columns@completerow
11937 \eql@columns@print@tag
11938 }
11939 % \end{macrocode}
11940 %
11941 % \macro{\eql@columns@print@tag}
11942 % \begin{macrocode}
11943 \def\eql@columns@print@tag{%
11944 \kern-\dimexpr\eql@totalwidth@+\eql@colsep@\relax
11945 % \end{macrocode}
11946 % determine first line available space
11947 % \begin{macrocode}
11948 \eql@display@firstavail@set\eql@line@avail@
11949 \eql@columns@overfull
11950 \eql@numbering@print@line@eval
11951 \if@eqnsw
11952 \eql@tagbox@make\eql@composetag@print
11953 \fi
11954 \eql@tagpos@print@line@eval
11955 \eql@tagbox@print@cell
11956 \eql@tagpos@print@line@end
11957 }
11958 % \end{macrocode}
11959 %
11960 % \macro{\eql@columns@print}
11961 % \begin{macrocode}
11962 \def\eql@columns@print{%
11963 \eql@verbose@infoarg\eql@verbose@msg@enter\eql@columns@print
11964 \eql@shape@align@disable
11965 \eql@display@halign@init\eql@columns@print@line@begin
11966 \eql@multi@cr@let\eql@columns@print@line@end
11967 \ifdefined\eql@amp@mode
11968 \let\&\eql@columns@amp
11969 \fi
11970 \tabskip\eql@marginleft@
11971 % \end{macrocode}
11972 %
11973 % \begin{macrocode}
11974 \halign{%
11975 &%
11976 \global\advance\eql@column@\@ne
11977 \global\let\eql@cell@container\@empty
11978 \global\setbox\eql@cellbox@\hbox{%
11979 \eql@strut@cell
11980 \@lign
11981 $\m@th\eql@mathstyle
11982 \eql@hook@colin
11983 ##%
11984 \eql@punct@apply@next
11985 \eql@class@innerleft
11986 \eql@hook@innerleft
11987 \eql@tagging@mathsave
11988 $%
11989 \eql@tagging@mathaddlast
11990 }%
11991 \eql@cell@container
11992 \hfil
11993 \eql@columns@print@cell
11994 \global\let\eql@frame@prevcmd\eql@frame@cmd
11995 \tabskip\z@skip
11996 &%
11997 \eql@prevwidth@\wd\eql@cellbox@
11998 \let\eql@frame@cmd\eql@frame@prevcmd
11999 \global\advance\eql@column@\@ne
12000 \global\let\eql@cell@container\@empty
12001 \setbox\eql@cellbox@\hbox{%
12002 \unhbox\eql@cellbox@
12003 \eql@strut@cell
12004 \@lign
12005 $\m@th\eql@mathstyle
12006 \eql@hook@innerright
12007 \eql@class@innerright@sel
12008 ##%
12009 \eql@punct@apply@col
12010 \eql@hook@colout
12011 \eql@tagging@mathsave
12012 $%
12013 \eql@tagging@mathaddlast
12014 }%
12015 \eql@cell@container
12016 \eql@columns@print@cell
12017 \hfil
12018 \tabskip\eql@colsep@\relax
12019 \crcr
12020 % \end{macrocode}
12021 %
12022 % \begin{macrocode}
12023 \noalign{%
12024 \eql@display@halign@start
12025 \eql@numbering@print@block@begin
12026 \eql@hook@blockbefore
12027 }%
12028 \eql@hook@blockin
12029 \eql@scan@body
12030 \ifvmode\else
12031 \relax
12032 \eql@punct@apply@block
12033 \eql@hook@blockout
12034 \eql@multi@endline
12035 \cr
12036 \fi
12037 \noalign{%
12038 \eql@hook@blockafter
12039 \eql@display@halign@end
12040 \eql@verbose@infoarg\eql@verbose@msg@leave\eql@columns@print
12041 }%
12042 \eql@tagging@tablesavealign
12043 }%
12044 }
12045 % \end{macrocode}
12046 %
12047 %
12048 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12049 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12050 % \section{Interface}
12051 %
12052 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12053 % \subsection{Options Processing}
12054 %
12055 % \TODO describe
12056 % \begin{macrocode}
12057 \def\eql@equations@test@setopt{\let\eql@equations@test\eql@equations@testopt}
12058 \def\eql@equations@test@setall{\let\eql@equations@test\eql@equations@testall}
12059 % \end{macrocode}
12060 %
12061 % \macro{\eql@equations@testopt}
12062 % \TODO describe
12063 % \begin{macrocode}
12064 \def\eql@equations@testopt#1{%
12065 \eql@testopt@tight{\eql@equations@testopt@set{#1}}{}}
12066 \def\eql@equations@testopt@set#1[#2]{\eqnaddopt{#2}#1}
12067 % \end{macrocode}
12068 %
12069 % \macro{\eql@equations@testall}
12070 % The macro sequence started by |\eql@equations@testall|
12071 % scans for optional arguments to the equation environments
12072 % and appends them to the argument list using |\eqnaddopt|.
12073 % All arguments are scanned such that any spaces
12074 % stop the scanning and such that any alignment markers `|&|'
12075 % cannot interfere:
12076 % \TODO update
12077 % \begin{macrocode}
12078 \def\eql@equations@testall{\eql@parseopt@env\eql@equations@testall@parse}
12079 \def\eql@equations@testall@parse{%
12080 \ifx\eql@parseopt@token*%
12081 \let\eql@parseopt@next\eql@parseopt@nonumber
12082 \fi
12083 \ifx\eql@parseopt@token!%
12084 \let\eql@parseopt@next\eql@parseopt@donumber
12085 \fi
12086 \ifx\eql@parseopt@token/%
12087 \let\eql@parseopt@next\eql@parseopt@transpose
12088 \fi
12089 \ifx\eql@parseopt@token[%]
12090 \let\eql@parseopt@next\eql@parseopt@opt
12091 \fi
12092 \ifx\eql@parseopt@token\eql@atxi
12093 \let\eql@parseopt@next\eql@parseopt@label
12094 \fi
12095 \ifx\eql@parseopt@token\eql@atxii
12096 \let\eql@parseopt@next\eql@parseopt@label
12097 \fi
12098 \ifx\eql@parseopt@token.%
12099 \let\eql@parseopt@next\eql@parseopt@punctpass
12100 \fi
12101 \ifx\eql@parseopt@token,%
12102 \let\eql@parseopt@next\eql@parseopt@punctpass
12103 \fi
12104 \ifx\eql@parseopt@token~%
12105 \let\eql@parseopt@next\eql@parseopt@punctpass
12106 \fi
12107 \ifx\eql@parseopt@token`%
12108 \let\eql@parseopt@next\eql@parseopt@punctopt
12109 \fi
12110 \ifx\eql@parseopt@token-%
12111 \let\eql@parseopt@next\eql@parseopt@single
12112 \fi
12113 \ifx\eql@parseopt@token=%
12114 \let\eql@parseopt@next\eql@parseopt@lines
12115 \fi
12116 \ifx\eql@parseopt@token|%
12117 \let\eql@parseopt@next\eql@parseopt@columns
12118 \fi
12119 \ifx\eql@parseopt@token<%
12120 \let\eql@parseopt@next\eql@parseopt@ampeq
12121 \fi
12122 \ifx\eql@parseopt@token>%
12123 \let\eql@parseopt@next\eql@parseopt@eqamp
12124 \fi
12125 \ifx\eql@parseopt@token\label
12126 \let\eql@parseopt@next\eql@parseopt@end
12127 \fi
12128 \ifx\eql@parseopt@token\begin
12129 \let\eql@parseopt@next\eql@parseopt@end
12130 \fi
12131 }
12132 % \end{macrocode}
12133 %
12134 % \macro{\eql@equations@end@testall}
12135 % \TODO describe
12136 % \begin{macrocode}
12137 \def\eql@equations@end@testall{%
12138 \eql@parseopt@env\eql@equations@end@testall@parse}
12139 \def\eql@equations@end@testall@parse{%
12140 \ifx\eql@parseopt@token.%
12141 \let\eql@parseopt@next\eql@parseopt@punctpass
12142 \fi
12143 \ifx\eql@parseopt@token,%
12144 \let\eql@parseopt@next\eql@parseopt@punctpass
12145 \fi
12146 \ifx\eql@parseopt@token~%
12147 \let\eql@parseopt@next\eql@parseopt@punctpass
12148 \fi
12149 \ifx\eql@parseopt@token`%
12150 \let\eql@parseopt@next\eql@parseopt@punctblock
12151 \fi
12152 }
12153 % \end{macrocode}
12154 %
12155 % \macro{\eql@equations@processopt}
12156 % The macro |\eql@equations@processopt| processes the options
12157 % recevied by |\eqnaddopt|.
12158 % First, clear several non-persistent registers
12159 % (labels, tags, direct vertical spacing).
12160 % Then process the arguments.
12161 % Finally evaluate |\eql@indent@val| and |\eql@tagsepmin@val|
12162 % and prevent main punctuation from being passed to nested environments:
12163 % \begin{macrocode}
12164 \def\eql@equations@processopt{%
12165 \let\eql@tags@container@block\eql@tags@container@clear
12166 \let\eql@tags@frame@cmd\@firstofone
12167 \let\eql@skip@force@above\@undefined
12168 \let\eql@skip@force@below\@undefined
12169 \let\eql@skip@force@leave\@undefined
12170 \let\eql@display@linewidth\@undefined
12171 \let\eql@display@marginleft\@undefined
12172 \let\eql@display@marginright\@undefined
12173 \eql@abovespace@\z@skip
12174 \eql@belowspace@\z@skip
12175 \eql@displaybreak@prepen@\@MM
12176 \eql@displaybreak@postpen@\@MM
12177 \eql@nextopt@process{equations}%
12178 \let\eql@punct@next\@undefined
12179 \eql@indent@\glueexpr\eql@indent@val\relax
12180 \eql@tagsepmin@\glueexpr\eql@tagsepmin@val\relax
12181 }
12182 % \end{macrocode}
12183 %
12184 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12185 % \subsection{Single-Line Main}
12186 %
12187 % In the following, we define the main routine
12188 % for the single-line equation mode.
12189 %
12190 % \macro{\eql@single@cr@error}
12191 % Cannot use line breaks, produce an error message:
12192 % \begin{macrocode}
12193 \def\eql@single@cr@error{%
12194 \eql@error{Cannot use '\string\\' within display equation.
12195 Please switch to equations environment}%
12196 }
12197 % \end{macrocode}
12198 %
12199 % \macro{\eql@single@start}
12200 % Opening code for single-line equation.
12201 % Capture current vertical mode, trigger PDF tagging,
12202 % enter display math mode, initialise numbering scheme,
12203 % backup current state of global registers,
12204 % set native vs.\ manual equation tag mode,
12205 % install error message for using |\\|.
12206 % Hand over to mode-specific opening:
12207 % \begin{macrocode}
12208 \def\eql@single@start{%
12209 \eql@display@enter
12210 \eql@tagging@start
12211 \eql@dollardollar@begin
12212 \eql@display@adjust
12213 \eql@numbering@init
12214 \eql@stack@save@equations
12215 \eql@numbering@single@init
12216 \ifdefined\eql@single@cr@mode
12217 \let\\\eql@single@cr@mode
12218 \fi
12219 \ifdefined\eql@amp@mode
12220 \let\&\eql@break@amp
12221 \fi
12222 \ifdefined\eql@single@native
12223 \let\eql@single@start@sel\eql@single@start@native
12224 \let\eql@single@end@sel\eql@single@end@native
12225 \else
12226 \let\eql@single@start@sel\eql@single@start@print
12227 \let\eql@single@end@sel\eql@single@end@print
12228 \fi
12229 \eql@single@start@sel
12230 }
12231 % \end{macrocode}
12232 %
12233 % \macro{\eql@single@end}
12234 % Closing code for single-line equation.
12235 % Apply punctuation for the block, perform mode-specific ending,
12236 % restore global variables, end display math, indicate end to PDF tagging,
12237 % return to vertical mode if desired:
12238 % \begin{macrocode}
12239 \def\eql@single@end{%
12240 \eql@punct@apply@block
12241 \eql@hook@eqout
12242 \eql@single@end@sel
12243 \global\eql@punct@top@reset
12244 \eql@stack@restore
12245 \eql@dollardollar@end
12246 \eql@tagging@end
12247 \eql@display@leave
12248 }
12249 % \end{macrocode}
12250 %
12251 % \macro{\eql@single@main}
12252 % Combined opening, body and closing for pre-scanned body:
12253 % \begin{macrocode}
12254 \def\eql@single@main{%
12255 \eql@single@start
12256 \eql@scan@body
12257 \eql@single@end
12258 }
12259 % \end{macrocode}
12260 %
12261 % \macro{\eql@equations@single@set}
12262 % Configure equations macros to single-line mode:
12263 % \begin{macrocode}
12264 \def\eql@equations@single@set{%
12265 \ifdefined\eql@single@doscan
12266 \let\eql@equations@main\eql@single@main
12267 \else
12268 \let\eql@equations@main\@undefined
12269 \fi
12270 }
12271 % \end{macrocode}
12272 %
12273 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12274 % \subsection{Multi-Line Main}
12275 %
12276 % \ebool{\eql@multi@linesmode}
12277 % Switch register for lines vs.\ columns mode:
12278 % \begin{macrocode}
12279 \let\eql@multi@linesmode\eql@false
12280 % \end{macrocode}
12281 %
12282 % \macro{\eql@multi@main}
12283 % Main routine for multi-line modes.
12284 % Capture current vertical mode, trigger PDF tagging,
12285 % enter display math mode, initialise numbering scheme,
12286 % backup current state of global registers,
12287 % initialise macros for use within equations:
12288 % \TODO shove depends on lines vs columns
12289 % \begin{macrocode}
12290 \def\eql@multi@main{%
12291 \eql@display@enter
12292 \eql@tagging@start
12293 \eql@dollardollar@begin
12294 \eql@display@adjust
12295 \eql@numbering@init
12296 \eql@stack@save@equations
12297 \ifdefined\eql@transpose@active
12298 \ifdefined\eql@multi@linesmode\else
12299 \eql@transpose
12300 \fi
12301 \fi
12302 \ifdefined\eql@numbering@subeq@use
12303 \eql@numbering@subeq@init
12304 \fi
12305 \eql@display@init
12306 \let\intertext\eql@intertext
12307 \let\endintertext\endeql@intertext
12308 \eql@shape@align@enable
12309 % \end{macrocode}
12310 % Now measure the given multi-line equations body:
12311 % \begin{macrocode}
12312 \ifdefined\eql@multi@linesmode
12313 \eql@lines@measure
12314 \else
12315 \ifdefined\eql@ampproof@active
12316 \eql@ampproof
12317 \fi
12318 \eql@columns@measure
12319 \fi
12320 % \end{macrocode}
12321 % If only a single equation number is used for subequation numbering,
12322 % revert to normal equation numbering.
12323 % If only a single column is used in columns mode,
12324 % may fallback to lines mode.
12325 % Switching from columns to lines mode, the width can be incorrect,
12326 % expect only minor discrpancies,
12327 % but for accurateness, should call |\eql@lines@measure|:
12328 % \begin{macrocode}
12329 \ifdefined\eql@numbering@subeq@use
12330 \eql@numbering@subeq@test
12331 \fi
12332 \ifdefined\eql@multi@linesmode\else
12333 \ifdefined\eql@multi@linesfallback
12334 \ifnum\eql@totalcolumns@=\@ne
12335 \let\eql@multi@linesmode\eql@true
12336 \ifx\eql@multi@linesfallback\z@\else
12337 \eql@lines@measure
12338 \fi
12339 \fi
12340 \fi
12341 \fi
12342 % \end{macrocode}
12343 % Adjust the multi-line equations body:
12344 % \begin{macrocode}
12345 \ifdefined\eql@multi@linesmode
12346 \eql@lines@adjust
12347 \else
12348 \eql@columns@adjust
12349 \fi
12350 % \end{macrocode}
12351 % Now print the multi-line equations body:
12352 % \begin{macrocode}
12353 \eql@display@print
12354 \eql@numbering@print@init
12355 \ifdefined\eql@multi@linesmode
12356 \eql@lines@print
12357 \else
12358 \eql@columns@print
12359 \fi
12360 \eql@display@close
12361 % \end{macrocode}
12362 % Close numbering, restore global variables,
12363 % end display math, indicate end to PDF tagging,
12364 % return to vertical mode if desired:
12365 % \begin{macrocode}
12366 \ifdefined\eql@numbering@subeq@use
12367 \eql@numbering@subeq@close
12368 \fi
12369 \global\eql@punct@top@reset
12370 \eql@stack@restore
12371 \eql@dollardollar@end
12372 \eql@tagging@end
12373 \eql@display@leave
12374 }
12375 % \end{macrocode}
12376 %
12377 % \macro{\eql@equations@columns@set}
12378 % \macro{\eql@equations@lines@set}
12379 % Configure equations macros to one of the two multi-line modes:
12380 % \begin{macrocode}
12381 \def\eql@equations@columns@set{%
12382 \let\eql@equations@main\eql@multi@main
12383 \let\eql@multi@linesmode\eql@false
12384 }
12385 \def\eql@equations@lines@set{%
12386 \let\eql@equations@main\eql@multi@main
12387 \let\eql@multi@linesmode\eql@true
12388 }
12389 % \end{macrocode}
12390 %
12391 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12392 % \subsection{Equations Environment}
12393 %
12394 % We now declare the main environment and its symbolic versions.
12395 %
12396 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12397 % \paragraph{Environment.}
12398 %
12399 % \environment{equations}
12400 % Declare the main equations environment.
12401 % If already in math mode, fail and cancel the environment body.
12402 % Otherwise scan for optional arguments
12403 % and pass on to |\eql@equations@start|:
12404 % \begin{macrocode}
12405 \newenvironment{equations}{%
12406 \ifmmode
12407 \expandafter\eql@equations@env@cancel
12408 \else
12409 \eql@verbose@info\eql@verbose@msg@enterenv
12410 \expandafter\eql@equations@env@open
12411 \fi
12412 }{%
12413 \ifdefined\eql@equations@main\else
12414 \expandafter\eql@single@end
12415 \fi
12416 \ignorespacesafterend
12417 \eql@verbose@info\eql@verbose@msg@leaveenv
12418 }
12419 \eql@markline@amsthm@register{equations}
12420 \eql@tagging@register@luamml{equations}
12421 % \end{macrocode}
12422 %
12423 % \macro{\eql@equations@env@cancel}
12424 % \begin{macrocode}
12425 \def\eql@equations@env@cancel{%
12426 \eql@error@mathmode{\string\begin{\@currenvir}}%
12427 \let\eql@scan@call\eql@scan@env@cancel
12428 \eql@scan@env
12429 }
12430 % \end{macrocode}
12431 %
12432 % \macro{\eql@equations@env@open}
12433 % \begin{macrocode}
12434 \def\eql@equations@env@open{%
12435 \ifdefined\eql@equations@env@modifier
12436 \eql@equations@test@setall
12437 \else
12438 \eql@equations@nomodifier
12439 \fi
12440 \eql@ampprotect\eql@equations@test\eql@equations@env@start
12441 }
12442 % \end{macrocode}
12443 %
12444 % \macro{\eql@equations@env@start}
12445 % The macro |\eql@equations@env@start| first processes the arguments.
12446 % Depending on the chosen mode of operation,
12447 % scan the environment body passing on to |\eql@equations@main|
12448 % or process a single-line equation via |\eql@single@start|:
12449 % \begin{macrocode}
12450 \def\eql@equations@env@start{%
12451 \eql@equations@processopt
12452 \ifdefined\eql@equations@main
12453 \eql@equations@call@set
12454 \expandafter\eql@scan@env
12455 \else
12456 \expandafter\eql@single@start
12457 \fi
12458 }
12459 % \end{macrocode}
12460 %
12461 % \macro{\eql@equations@call}
12462 % \begin{macrocode}
12463 \def\eql@equations@call{\eql@equations@main\eql@scan@end}
12464 \def\eql@equations@call@test{%
12465 \eql@ampprotect\eql@equations@end@testall\eql@equations@call}
12466 \def\eql@equations@call@set{%
12467 \ifdefined\eql@equations@end@modifier
12468 \let\eql@scan@call\eql@equations@call@test
12469 \else
12470 \let\eql@scan@call\eql@equations@call
12471 \fi
12472 }
12473 % \end{macrocode}
12474 %
12475 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12476 % \paragraph{Square Brackets.}
12477 %
12478 % \environment{equations@sqr}
12479 % Define a pseudo-environment |equations@sqr|
12480 % such that |\@currenvir| may point to it when needed:
12481 % \begin{macrocode}
12482 \newenvironment{equations@sqr}{}{}
12483 \eql@markline@amsthm@register{equations@sqr}
12484 \eql@tagging@register@luamml{equations@sqr}
12485 % \end{macrocode}
12486 %
12487 % \macro{\eql@equations@sqr@open}
12488 % Definition for `|\[|'.
12489 % Add the default arguments |\eql@equations@sqr@opt|,
12490 % enter the pseudo-environment, scan for optional arguments,
12491 % and pass on to |\eql@equations@sqr@start|:
12492 % \begin{macrocode}
12493 \def\eql@equations@sqr@open{%
12494 \expandafter\eqnaddopt\expandafter{\eql@equations@sqr@opt}%
12495 \begin{equations@sqr}%
12496 \eql@verbose@info\eql@verbose@msg@enterenv
12497 \let\]\eql@equations@sqr@close
12498 \ifdefined\eql@equations@sqr@modifier
12499 \eql@equations@test@setall
12500 \else
12501 \eql@equations@nomodifier
12502 \fi
12503 \eql@ampprotect\eql@equations@test\eql@equations@sqr@start
12504 }
12505 % \end{macrocode}
12506 %
12507 % \macro{\eql@equations@sqr@start}
12508 % Process arguments. Depending on mode of operation,
12509 % scan and process enclosed contents via |\eql@equations@main|
12510 % or pass on to |\eql@single@start|:
12511 % \begin{macrocode}
12512 \def\eql@equations@sqr@start{%
12513 \eql@equations@processopt
12514 \ifdefined\eql@equations@main
12515 \eql@equations@call@set
12516 \expandafter\eql@scan@sqr
12517 \else
12518 \expandafter\eql@single@start
12519 \fi
12520 }
12521 % \end{macrocode}
12522 %
12523 % \macro{\eql@equations@sqr@close}
12524 % Definition for `|\]|'.
12525 % Parse modifiers following `|\]|'
12526 % and hand on to |\eql@equations@sqr@end|:
12527 % \begin{macrocode}
12528 \protected\def\eql@equations@sqr@close{%
12529 \ifdefined\eql@equations@main
12530 \let\eql@equations@end@modifier\eql@false
12531 \fi
12532 \ifdefined\eql@equations@end@modifier
12533 \expandafter\eql@ampprotect\expandafter\eql@equations@end@testall
12534 \fi
12535 \eql@equations@sqr@end
12536 }
12537 % \end{macrocode}
12538 %
12539 % \macro{\eql@equations@sqr@end}
12540 % \TODO complete
12541 % End |\[|\,\ldots|\]| block:
12542 % \begin{macrocode}
12543 \def\eql@equations@sqr@end{%
12544 \ifdefined\eql@equations@main\else
12545 \expandafter\eql@single@end
12546 \fi
12547 \eql@verbose@info\eql@verbose@msg@leaveenv
12548 \end{equations@sqr}%
12549 \ignorespaces
12550 }
12551 % \end{macrocode}
12552 %
12553 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12554 % \paragraph{Angle Brackets.}
12555 %
12556 % \environment{equations@ang}
12557 % Define a pseudo-environment |equations@ang|:
12558 % \begin{macrocode}
12559 \newenvironment{equations@ang}{}{}
12560 \eql@markline@amsthm@register{equations@ang}
12561 \eql@tagging@register@luamml{equations@ang}
12562 % \end{macrocode}
12563 %
12564 % \macro{\eql@equations@ang@open}
12565 % \begin{macrocode}
12566 \def\eql@equations@ang@open{%
12567 \expandafter\eqnaddopt\expandafter{\eql@equations@ang@opt}%
12568 \begin{equations@ang}%
12569 \eql@verbose@info\eql@verbose@msg@enterenv
12570 \let\>\eql@equations@ang@close
12571 \ifdefined\eql@equations@ang@modifier
12572 \eql@equations@test@setall
12573 \else
12574 \eql@equations@nomodifier
12575 \fi
12576 \eql@ampprotect\eql@equations@test\eql@equations@ang@start
12577 }
12578 % \end{macrocode}
12579 %
12580 % \macro{\eql@equations@ang@start}
12581 % Process arguments and start handling the equation:
12582 % \begin{macrocode}
12583 \def\eql@equations@ang@start{%
12584 \eql@equations@processopt
12585 \ifdefined\eql@equations@main
12586 \eql@equations@call@set
12587 \expandafter\eql@scan@ang
12588 \else
12589 \expandafter\eql@single@start
12590 \fi
12591 }
12592 % \end{macrocode}
12593 %
12594 % \macro{\eql@equations@ang@close}
12595 % \TODO describe
12596 % \begin{macrocode}
12597 \def\eql@equations@ang@close{%
12598 \ifdefined\eql@equations@main
12599 \let\eql@equations@end@modifier\eql@false
12600 \fi
12601 \ifdefined\eql@equations@end@modifier
12602 \expandafter\eql@ampprotect\expandafter\eql@equations@end@testall
12603 \fi
12604 \eql@equations@ang@end
12605 }
12606 % \end{macrocode}
12607 %
12608 % \macro{\eql@equations@ang@end}
12609 % \TODO describe
12610 % \begin{macrocode}
12611 \def\eql@equations@ang@end{%
12612 \ifdefined\eql@equations@main\else
12613 \expandafter\eql@single@end
12614 \fi
12615 \eql@verbose@info\eql@verbose@msg@leaveenv
12616 \end{equations@ang}%
12617 \ignorespaces
12618 }
12619 % \end{macrocode}
12620 %
12621 %
12622 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12623 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12624 % \section{Options}
12625 %
12626 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12627 % \subsection{Selection Tools}
12628 %
12629 % \macro{\eql@decide@abovebelow}
12630 % Select between values `|above|' or `|below|' or both:
12631 % execute the corresponding code provided in the latter two arguments:
12632 % \begin{macrocode}
12633 \def\eql@decide@abovebelow#1#2#3#4#5{%
12634 \eql@decide@select{#1}{#2}{#3}{%
12635 {abovebelow,both,tb}{#4#5},%
12636 {above,top,t}{#4},%
12637 {below,bottom,b}{#5}}}
12638 % \end{macrocode}
12639 %
12640 % \macro{\eql@decide@situation}
12641 % Select a particular vertical spacing situation and store it in
12642 % the macro |#4|:
12643 % \begin{macrocode}
12644 \def\eql@decide@situation#1#2#3#4{%
12645 \eql@decide@select{#1}{#2}{#3}{%
12646 {{long}{\def#4{0}}},%
12647 {{short}{\def#4{1}}},%
12648 {{cont}{\def#4{2}}},%
12649 {{par}{\def#4{3}}},%
12650 {{top}{\def#4{4}}},%
12651 {{noskip}{\def#4{5}}},%
12652 {{medskip}{\def#4{6}}}}}
12653 % \end{macrocode}
12654 %
12655 % \macro{\eql@decide@delim}
12656 % \TODO describe
12657 % \begin{macrocode}
12658 \def\eql@decide@delim#1#2#3{%
12659 \eql@decide@select{#1}{#2}{#3}{%
12660 {{,.,\eql@decide@false}{\eql@box@wrap{}{}}},%
12661 {{\eql@decide@true,r,p,round,parentheses}{\eql@box@delim()}},%
12662 {{s,b,sqr,square}{\eql@box@delim[]}},%
12663 {{c,B,curly,braces}{\eql@box@delim\lbrace\rbrace}},%
12664 {{a,ang,angle}{\eql@box@delim\langle\rangle}},%
12665 {{v,vert}{\eql@box@delim\vert\vert}},%
12666 {{d,V,dvert}{\eql@box@delim\Vert\Vert}},%
12667 {\relax{\eql@box@delim#3}}}}%
12668 % \end{macrocode}
12669 %
12670 % \TODO describe
12671 % \begin{macrocode}
12672 \def\eql@keyall{equations,box,setup}
12673 % \end{macrocode}
12674 %
12675 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12676 % \subsection{Options Declarations}
12677 %
12678 % We now declare all key-value pairs for options sorted by their category.
12679 %
12680 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12681 % \paragraph{Modes for Equations Box Environment.}
12682 %
12683 % Declare horizontal and vertical alignment modes
12684 % for the boxed equations environment.
12685 % Also declare spacing of columns:
12686 % \begin{macrocode}
12687 \eql@define@key{box}{lines,ln,gathered,gather,ga}[]{%
12688 \eql@box@lines@set}
12689 \eql@define@key{box}{columns,col,aligned,align,al}[]{%
12690 \eql@box@columns@set}
12691 \eql@define@key{box}{cases}[]{%
12692 \eql@box@cases@set\eql@box@ldelim\lbrace%
12693 \def\eql@box@colsep{\eql@box@condsep}}
12694 \eql@define@key{box}{matrix}[r]{%
12695 \eql@box@lines@set\eql@shape@set{center}%
12696 \let\eql@spread@reset\eql@true\def\eql@spread@val{\z@}%
12697 \def\eql@box@colsep{\eql@box@matrixsep}%
12698 \let\eql@mathstyle\@empty
12699 \eql@punct@clear
12700 \eql@box@cr@test@setopt
12701 \eql@box@amp@test@setopt
12702 \let\eql@box@end@modifier\eql@false
12703 \eql@decide@delim{#3}{#2}{#1}}
12704 \eql@define@key{box}{top,t}[]{\let\eql@box@box\vtop}
12705 \eql@define@key{box}{center,c}[]{\let\eql@box@box\vcenter}
12706 \eql@define@key{box}{bottom,b}[]{\let\eql@box@box\vbox}
12707 \eql@define@key{box}{intro}{%
12708 \def\eql@box@cases@condintro{#1}}
12709 \eql@define@key{box}{introtext}{%
12710 \def\eql@box@cases@condintro{%
12711 \ifmmode\expandafter\hbox\else\expandafter\@firstofone\fi{#1 }}}
12712 \eql@define@key{box}{textcond}[true]{%
12713 \eql@decide@select{#3}{#2}{#1}{%
12714 {{\eql@decide@true,text}{\let\eql@box@cases@condtext\eql@true}},%
12715 {{\eql@decide@false,math}{\let\eql@box@cases@condtext\eql@false}}}}
12716 \eql@define@key{setup}{scanbox}[true]{%
12717 \eql@decide@bool{#3}{#2}{#1}\eql@box@doscan}
12718 \eql@define@key{box}{scan}[true]{%
12719 \eql@decide@bool{#3}{#2}{#1}\eql@box@doscan}
12720 \eql@define@key{setup}{boxangopt}[]{%
12721 \def\eql@box@ang@opt{columns,#1}}
12722 % \end{macrocode}
12723 %
12724 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12725 % \paragraph{Modes for Equations Environment.}
12726 %
12727 % \begin{macrocode}
12728 \let\eql@box@doscan\eqn@false
12729 % \end{macrocode}
12730 %
12731 % Declare modes and switches for the equations environment:
12732 % \begin{macrocode}
12733 \eql@define@key{equations}{single,1,equation,eq}[]{\eql@equations@single@set}
12734 \eql@define@key{equations}{lines,ln,gathered,gather,ga}[]{%
12735 \eql@equations@lines@set}
12736 \eql@define@key{equations}{columns,col,aligned,align,al}[]{%
12737 \eql@equations@columns@set}
12738 \eql@define@key{equations,setup}{transpose}[true]{%
12739 \eql@decide@select{#3}{#2}{#1}{%
12740 {\eql@decide@false{\let\eql@transpose@active\eql@false}},%
12741 {{noamp,plain,restricted}{\let\eql@transpose@active\eql@true}},%
12742 {{\eql@decide@true,amp,cont}{\let\eql@transpose@active=+}}}}
12743 \eql@define@key{setup}{nativeequation}[true]{%
12744 \eql@decide@bool{#3}{#2}{#1}\eql@single@native}
12745 \eql@define@key{equations}{native}[true]{%
12746 \eql@decide@bool{#3}{#2}{#1}\eql@single@native%
12747 \ifdefined\eql@single@native\let\eql@layoutleft\eql@false\fi}
12748 \eql@define@key{setup}{scanequation}[true]{%
12749 \eql@decide@bool{#3}{#2}{#1}\eql@single@doscan}
12750 \eql@define@key{equations}{scan}[true]{%
12751 \eql@decide@bool{#3}{#2}{#1}\eql@single@doscan}
12752 \eql@define@key{setup}{sqropt}[]{%
12753 \def\eql@equations@sqr@opt{equation,#1}}
12754 \eql@define@key{setup}{angopt}[]{%
12755 \def\eql@equations@ang@opt{columns,#1}}
12756 % \end{macrocode}
12757 %
12758 % \TODO describe
12759 % \begin{macrocode}
12760 \eql@define@key{control}{restoreexterior}[]{\eql@display@restore}
12761 \eql@define@key{control}{restoreexterior*}[]{\@arrayparboxrestore}
12762 % \end{macrocode}
12763 %
12764 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12765 % \paragraph{Modes for Modifier Scanning.}
12766 %
12767 % \begin{macrocode}
12768 \def\eql@equations@nomodifier{%
12769 \eql@equations@test@setopt
12770 \let\eql@equations@end@modifier\eql@false
12771 \eql@multi@cr@test@setopt
12772 \eql@columns@amp@test@setopt
12773 \eql@break@cr@test@setopt
12774 \eql@break@amp@test@setopt
12775 }
12776 \let\eql@equations@env@modifier\eql@false
12777 \let\eql@equations@sqr@modifier\eql@true
12778 \let\eql@equations@ang@modifier\eql@true
12779 \let\eql@equations@end@modifier\eql@true
12780 \eql@equations@test@setall
12781 \eql@multi@cr@test@setall
12782 \eql@columns@amp@test@setall
12783 \eql@break@cr@test@setall
12784 \eql@break@amp@test@setall
12785 \eql@break@test@setopt
12786 \let\eql@multi@cr@relnext\eql@true
12787 % \end{macrocode}
12788 %
12789 % \begin{macrocode}
12790 \def\eql@box@nomodifier{%
12791 \eql@box@test@setopt
12792 \let\eql@box@end@modifier\eql@false
12793 \eql@box@cr@test@setopt
12794 \eql@box@amp@test@setopt
12795 }
12796 \let\eql@box@env@modifier\eql@false
12797 \let\eql@box@ang@modifier\eql@true
12798 \let\eql@box@end@modifier\eql@true
12799 \eql@box@test@setall
12800 \eql@box@cr@test@setall
12801 \eql@box@amp@test@setall
12802 % \end{macrocode}
12803 %
12804 % \begin{macrocode}
12805 \eql@define@key{setup}{modifier}[true]{%
12806 \eql@decide@if{#3}{#2}{#1}%
12807 {\let\eql@equations@env@modifier\eql@true
12808 \let\eql@equations@sqr@modifier\eql@true
12809 \let\eql@equations@ang@modifier\eql@true
12810 \let\eql@box@env@modifier\eql@true
12811 \let\eql@box@ang@modifier\eql@true
12812 \eql@multi@cr@test@setall\eql@break@cr@test@setall
12813 \eql@columns@amp@test@setall\eql@break@amp@test@setall
12814 \eql@box@cr@test@setall\eql@box@amp@test@setall
12815 \eql@break@test@setall}%
12816 {\let\eql@equations@env@modifier\eql@false
12817 \let\eql@equations@sqr@modifier\eql@false
12818 \let\eql@equations@ang@modifier\eql@false
12819 \let\eql@box@env@modifier\eql@false
12820 \let\eql@box@ang@modifier\eql@false
12821 \eql@multi@cr@test@setopt\eql@break@cr@test@setopt
12822 \eql@columns@amp@test@setopt\eql@break@amp@test@setopt
12823 \eql@box@cr@test@setopt\eql@box@amp@test@setopt
12824 \eql@break@test@setopt}}
12825 \eql@define@key{setup}{modifierenv}[true]{%
12826 \eql@decide@bool{#3}{#2}{#1}\eql@equations@env@modifier
12827 \eql@decide@bool{#3}{#2}{#1}\eql@box@env@modifier}
12828 \eql@define@key{setup}{modifiersqrang}[true]{%
12829 \eql@decide@bool{#3}{#2}{#1}\eql@equations@sqr@modifier
12830 \eql@decide@bool{#3}{#2}{#1}\eql@equations@ang@modifier
12831 \eql@decide@bool{#3}{#2}{#1}\eql@box@ang@modifier}
12832 \eql@define@key{setup}{modifierend}[true]{%
12833 \eql@decide@bool{#3}{#2}{#1}\eql@equations@end@modifier
12834 \eql@decide@bool{#3}{#2}{#1}\eql@box@end@modifier}
12835 \eql@define@key{setup}{modifiereqncr}[true]{\eql@decide@if{#3}{#2}{#1}%
12836 {\eql@multi@cr@test@setall\eql@break@cr@test@setall
12837 \eql@box@cr@test@setall}%
12838 {\eql@multi@cr@test@setopt\eql@break@cr@test@setopt
12839 \eql@box@cr@test@setopt}}
12840 \eql@define@key{setup}{modifiereqnamp}[true]{\eql@decide@if{#3}{#2}{#1}%
12841 {\eql@columns@amp@test@setall\eql@break@amp@test@setall
12842 \eql@box@amp@test@setall}%
12843 {\eql@columns@amp@test@setopt\eql@break@amp@test@setopt
12844 \eql@box@amp@test@setopt}}
12845 \eql@define@key{setup}{modifierbreak}[true]{\eql@decide@if{#3}{#2}{#1}%
12846 \eql@break@test@setall\eql@break@test@setopt}
12847 \eql@define@key{setup}{modifierwarning}[all]{%
12848 \eql@decide@select{#3}{#2}{#1}{%
12849 {\eql@decide@false{\let\eql@parseopt@warn@env\@empty
12850 \let\eql@parseopt@warn@cr\@empty}},%
12851 {{env,-}{\let\eql@parseopt@warn@env\eql@warn@parseopt
12852 \let\eql@parseopt@warn@cr\@empty}},%
12853 {{all,\eql@decide@true}{\let\eql@parseopt@warn@env\eql@warn@parseopt
12854 \let\eql@parseopt@warn@cr\eql@warn@parseopt}},%
12855 {{verbose,+}{\let\eql@parseopt@warn@env\eql@warn@parseopt@verbose
12856 \let\eql@parseopt@warn@cr\eql@warn@parseopt@verbose}}}}
12857 % \end{macrocode}
12858 %
12859 % \begin{macrocode}
12860 \eql@define@key{setup}{modifiereqn}[true]{%
12861 \eql@decide@bool{#3}{#2}{#1}\eql@equations@env@modifier
12862 \eql@decide@bool{#3}{#2}{#1}\eql@equations@sqr@modifier
12863 \eql@decide@bool{#3}{#2}{#1}\eql@equations@ang@modifier}
12864 \eql@define@key{setup}{modifiereqnenv}[true]{%
12865 \eql@decide@bool{#3}{#2}{#1}\eql@equations@env@modifier}
12866 \eql@define@key{setup}{modifiereqnsqr}[true]{%
12867 \eql@decide@bool{#3}{#2}{#1}\eql@equations@sqr@modifier}
12868 \eql@define@key{setup}{modifiereqnang}[true]{%
12869 \eql@decide@bool{#3}{#2}{#1}\eql@equations@ang@modifier}
12870 \eql@define@key{setup}{modifiereqnend}[true]{%
12871 \eql@decide@bool{#3}{#2}{#1}\eql@equations@end@modifier}
12872 \eql@define@key{setup}{modifiereqncr}[true]{\eql@decide@if{#3}{#2}{#1}%
12873 {\eql@multi@cr@test@setall\eql@break@cr@test@setall}%
12874 {\eql@multi@cr@test@setopt\eql@break@cr@test@setopt}}
12875 \eql@define@key{setup}{modifiereqnamp}[true]{\eql@decide@if{#3}{#2}{#1}%
12876 {\eql@columns@amp@test@setall\eql@break@amp@test@setall}%
12877 {\eql@columns@amp@test@setopt\eql@break@amp@test@setopt}}
12878 % \end{macrocode}
12879 %
12880 % \begin{macrocode}
12881 \eql@define@key{setup}{modifierbox}[true]{%
12882 \eql@decide@bool{#3}{#2}{#1}\eql@box@env@modifier
12883 \eql@decide@bool{#3}{#2}{#1}\eql@box@ang@modifier}
12884 \eql@define@key{setup}{modifierboxenv}[true]{%
12885 \eql@decide@bool{#3}{#2}{#1}\eql@box@env@modifier}
12886 \eql@define@key{setup}{modifierboxang}[true]{%
12887 \eql@decide@bool{#3}{#2}{#1}\eql@box@ang@modifier}
12888 \eql@define@key{setup}{modifierboxend}[true]{%
12889 \eql@decide@bool{#3}{#2}{#1}\eql@box@end@modifier}
12890 \eql@define@key{setup}{modifierboxcr}[true]{%
12891 \eql@decide@if{#3}{#2}{#1}\eql@box@cr@test@setall\eql@box@cr@test@setopt}
12892 \eql@define@key{setup}{modifierboxamp}[true]{%
12893 \eql@decide@if{#3}{#2}{#1}\eql@box@amp@test@setall\eql@box@amp@test@setopt}
12894 % \end{macrocode}
12895 %
12896 % \begin{macrocode}
12897 \eql@define@key{equations}{modifierend}[true]{%
12898 \eql@decide@bool{#3}{#2}{#1}\eql@equations@end@modifier}
12899 \eql@define@key{equations}{modifiercr}[true]{\eql@decide@if{#3}{#2}{#1}%
12900 {\eql@multi@cr@test@setall\eql@break@cr@test@setall}%
12901 {\eql@multi@cr@test@setopt\eql@break@cr@test@setopt}}
12902 \eql@define@key{equations}{modifieramp}[true]{\eql@decide@if{#3}{#2}{#1}%
12903 {\eql@columns@amp@test@setall\eql@break@amp@test@setall}%
12904 {\eql@columns@amp@test@setopt\eql@break@amp@test@setopt}}
12905 \eql@define@key{setup,equations}{crrelnext}[true]{%
12906 \eql@decide@bool{#3}{#2}{#1}\eql@multi@cr@relnext}
12907 % \end{macrocode}
12908 %
12909 % \begin{macrocode}
12910 \eql@define@key{box}{modifier}[true]{\eql@decide@if{#3}{#2}{#1}%
12911 {\eql@box@cr@test@setall\eql@box@amp@test@setall
12912 \let\eql@box@end@modifier\eql@true}%
12913 {\eql@box@cr@test@setopt\eql@box@amp@test@setopt
12914 \let\eql@box@end@modifier\eql@false}}
12915 \eql@define@key{box}{modifierend}[true]{%
12916 \eql@decide@bool{#3}{#2}{#1}\eql@box@end@modifier}
12917 \eql@define@key{box}{modifiercr}[true]{%
12918 \eql@decide@if{#3}{#2}{#1}\eql@box@cr@test@setall\eql@box@cr@test@setopt}
12919 \eql@define@key{box}{modifieramp}[true]{%
12920 \eql@decide@if{#3}{#2}{#1}\eql@box@amp@test@setall\eql@box@amp@test@setopt}
12921 % \end{macrocode}
12922 %
12923 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12924 % \paragraph{Vertical Spacing.}
12925 %
12926 % Settings concerning the spacing of lines:
12927 % \TODO set at end of env only!
12928 % \begin{macrocode}
12929 \eql@define@key\eql@keyall{spread}{%
12930 \let\eql@spread@reset\eql@false\def\eql@spread@val{#1}}
12931 \eql@define@key\eql@keyall{spread*}[0pt]{%
12932 \let\eql@spread@reset\eql@true\def\eql@spread@val{#1}}
12933 \eql@define@key\eql@keyall{strut}[true]{\eql@decide@select{#3}{#2}{#1}{%
12934 {\eql@decide@false{\let\eql@strut@cell\relax\let\eql@strut@tag\relax}},%
12935 {{cell}{\let\eql@strut@cell\eql@strut\let\eql@strut@tag\relax}},%
12936 {{tag}{\let\eql@strut@cell\relax\let\eql@strut@tag\eql@strut}},%
12937 {\eql@decide@true
12938 {\let\eql@strut@cell\eql@strut\let\eql@strut@tag\eql@strut}}}}
12939 \eql@define@key{setup}{strutdepth}{\def\eql@strut@depth{#1}}
12940 % \end{macrocode}
12941 %
12942 % Settings to specify the apparent height and depth of equations:
12943 % \begin{macrocode}
12944 \eql@define@key\eql@keyall{displayheight}[strut]{%
12945 \eql@decide@select{#3}{#2}{#1}{%
12946 {\eql@decide@false{\let\eql@display@height\@undefined}},%
12947 {{strut}{\def\eql@display@height{\ht\eql@strutbox@}}},%
12948 {\relax{\def\eql@display@height{#1}}}}}
12949 \eql@define@key\eql@keyall{displaydepth}[strut]{%
12950 \eql@decide@select{#3}{#2}{#1}{%
12951 {\eql@decide@false{\let\eql@display@depth\@undefined}},%
12952 {{strut}{\def\eql@display@depth{\dp\eql@strutbox@}}},%
12953 {\relax{\def\eql@display@depth{#1}}}}}
12954 % \end{macrocode}
12955 %
12956 % Settings concerning page breaks:
12957 % \begin{macrocode}
12958 \eql@define@key{equations}{prebreak}[4]{\eql@decide@select{#3}{#2}{#1}{%
12959 {{force,4,\eql@decide@true}{\eql@displaybreak@pre4}},%
12960 {{high,3}{\eql@displaybreak@pre3}},%
12961 {{med,medium,2}{\eql@displaybreak@pre2}},%
12962 {{low,1}{\eql@displaybreak@pre1}},%
12963 {{0,\eql@decide@false}{\eql@displaybreak@pre0}},%
12964 {{default,inherit,-1}{\eql@displaybreak@pre\m@ne}}}}
12965 \eql@define@key{equations}{postbreak}[4]{\eql@decide@select{#3}{#2}{#1}{%
12966 {{force,4,\eql@decide@true}{\eql@displaybreak@post4}},%
12967 {{high,3}{\eql@displaybreak@post3}},%
12968 {{med,medium,2}{\eql@displaybreak@post2}},%
12969 {{low,1}{\eql@displaybreak@post1}},%
12970 {{0,\eql@decide@false}{\eql@displaybreak@post0}},%
12971 {{default,inherit,-1}{\eql@displaybreak@post\m@ne}}}}
12972 \eql@define@key{equations,setup}{allowbreaks,allowdisplaybreaks}[4]{%
12973 \eql@decide@select{#3}{#2}{#1}{%
12974 {{full,4}{\eql@displaybreak@inter4}},%
12975 {{high,3}{\eql@displaybreak@inter3}},%
12976 {{med,medium,2}{\eql@displaybreak@inter2}},%
12977 {{low,1}{\eql@displaybreak@inter1}},%
12978 {{0,\eql@decide@false}{\eql@displaybreak@inter\z@}}}}
12979 \eql@define@key{equations}{prepenalty}{%
12980 \eql@displaybreak@prepen@\numexpr#1\relax}
12981 \eql@define@key{equations}{postpenalty}{%
12982 \eql@displaybreak@postpen@\numexpr#1\relax}
12983 \eql@define@key{equations,setup}{interpenalty}{%
12984 \interdisplaylinepenalty\numexpr#1\relax}
12985 % \end{macrocode}
12986 %
12987 % \TODO describe
12988 % \begin{macrocode}
12989 \eql@define@key{control}{vspace}[]{\eql@vspace@add{#1}}
12990 \eql@define@key{control}{vspace*}[]{\eql@vspace@addfixedbefore{#1}}
12991 \eql@define@key{control}{vspace!}[]{\eql@vspace@addfixedafter{#1}}
12992 \eql@define@key{control}{break}[4]{\eql@displaybreak@level[{#1}]}
12993 \eql@define@key{control}{penalty}[]{\eql@displaybreak@star{#1}}
12994 % \end{macrocode}
12995 %
12996 % Override vertical spacing situation:
12997 % \TODO short should just apply to above?! or as far as short would apply...
12998 % \begin{macrocode}
12999 \eql@define@key{equations}{noskip}[both]{%
13000 \eql@decide@abovebelow{#3}{#2}{#1}%
13001 {\def\eql@skip@force@above{5}}%
13002 {\def\eql@skip@force@below{5}}}
13003 \eql@define@key{equations}{short}[above]{%
13004 \eql@decide@abovebelow{#3}{#2}{#1}%
13005 {\def\eql@skip@force@above{1}}%
13006 {\def\eql@skip@force@below{1}}}
13007 \eql@define@key{equations}{long}[both]{%
13008 \eql@decide@abovebelow{#3}{#2}{#1}%
13009 {\def\eql@skip@force@above{0}}%
13010 {\def\eql@skip@force@below{0}}}
13011 \eql@define@key{equations}{medskip}[both]{%
13012 \eql@decide@abovebelow{#3}{#2}{#1}%
13013 {\def\eql@skip@force@above{6}}%
13014 {\def\eql@skip@force@below{6}}}
13015 \eql@define@key{equations}{par}[par]{%
13016 \eql@decide@select{#3}{#2}{#1}{%
13017 {{default,\eql@decide@false}{\let\eql@skip@force@leave\@undefined}},%
13018 {{cont,hmode}{\let\eql@skip@force@leave\z@}},%
13019 {{par,vmode}{\let\eql@skip@force@leave\@ne
13020 \ifdefined\eql@skip@force@below\else
13021 \def\eql@skip@force@below{3}%
13022 \fi}},%
13023 {{top}{\let\eql@skip@force@leave\tw@
13024 \ifdefined\eql@skip@force@below\else
13025 \def\eql@skip@force@below{4}%
13026 \fi}}}}
13027 % \end{macrocode}
13028 %
13029 % Specify vertical spacing explicitly:
13030 % \begin{macrocode}
13031 \eql@define@key{equations}{skip}{%
13032 \def\eql@skip@force@above{7}%
13033 \def\eql@skip@custom@above{#1}%
13034 \let\eql@skip@force@below\eql@skip@force@above
13035 \let\eql@skip@custom@below\eql@skip@custom@above}
13036 \eql@define@key{equations}{aboveskip}{%
13037 \def\eql@skip@force@above{7}%
13038 \def\eql@skip@custom@above{#1}}
13039 \eql@define@key{equations}{belowskip}{%
13040 \def\eql@skip@force@below{7}%
13041 \def\eql@skip@custom@below{#1}}
13042 \eql@define@key{equations}{abovespace}{%
13043 \advance\eql@abovespace@\glueexpr#1\relax}
13044 \eql@define@key{equations}{belowspace}{%
13045 \advance\eql@belowspace@\glueexpr#1\relax}
13046 % \end{macrocode}
13047 %
13048 % Vertical spacing for |intertext|:
13049 % \begin{macrocode}
13050 \eql@define@key{intertext}{skip}{%
13051 \def\eql@skip@force@above{7}%
13052 \def\eql@skip@custom@above{#1}%
13053 \let\eql@skip@force@below\eql@skip@force@above
13054 \let\eql@skip@custom@below\eql@skip@custom@above}
13055 \eql@define@key{intertext}{aboveskip}{%
13056 \def\eql@skip@force@below{7}%
13057 \def\eql@skip@custom@below{#1}}
13058 \eql@define@key{intertext}{belowskip}{%
13059 \def\eql@skip@force@above{7}%
13060 \def\eql@skip@custom@above{#1}}
13061 \eql@define@key{intertext}{noskip}[both]{%
13062 \eql@decide@abovebelow{#3}{#2}{#1}%
13063 {\def\eql@skip@force@below{5}}%
13064 {\def\eql@skip@force@above{5}}}
13065 \eql@define@key{intertext}{short}[both]{%
13066 \eql@decide@abovebelow{#3}{#2}{#1}%
13067 {\def\eql@skip@force@below{1}}%
13068 {\def\eql@skip@force@above{1}}}
13069 \eql@define@key{intertext}{long}[both]{%
13070 \eql@decide@abovebelow{#3}{#2}{#1}%
13071 {\def\eql@skip@force@below{0}}%
13072 {\def\eql@skip@force@above{0}}}
13073 \eql@define@key{intertext}{medskip}[both]{%
13074 \eql@decide@abovebelow{#3}{#2}{#1}%
13075 {\def\eql@skip@force@below{6}}%
13076 {\def\eql@skip@force@above{6}}}
13077 % \end{macrocode}
13078 %
13079 % Configure general vertical spacing behaviour for various situations:
13080 % \begin{macrocode}
13081 \eql@define@key{setup}{skip,longskip}{%
13082 \abovedisplayskip\glueexpr#1\relax
13083 \belowdisplayskip\abovedisplayskip
13084 \def\eql@skip@long@above{#1}%
13085 \let\eql@skip@long@below\eql@skip@long@above}
13086 \eql@define@key{setup}{aboveskip,abovelongskip}{%
13087 \abovedisplayskip\glueexpr#1\relax
13088 \def\eql@skip@long@above{#1}}
13089 \eql@define@key{setup}{belowskip,belowlongskip}{%
13090 \belowdisplayskip\glueexpr#1\relax
13091 \def\eql@skip@long@below{#1}}
13092 \eql@define@key{setup}{aboveshortskip}{%
13093 \abovedisplayshortskip\glueexpr#1\relax
13094 \def\eql@skip@short@above{#1}}
13095 \eql@define@key{setup}{belowshortskip}{%
13096 \belowdisplayshortskip\glueexpr#1\relax
13097 \def\eql@skip@short@below{#1}}
13098 \eql@define@key{setup}{tagskip}{%
13099 \def\eql@skip@tag@above{#1}%
13100 \let\eql@skip@tag@below\eql@skip@tag@above}
13101 \eql@define@key{setup}{abovetagskip}{%
13102 \def\eql@skip@tag@above{#1}}
13103 \eql@define@key{setup}{belowtagskip}{%
13104 \def\eql@skip@tag@below{#1}}
13105 \eql@define@key{setup}{medskip}{%
13106 \def\eql@skip@med@above{#1}%
13107 \let\eql@skip@med@below\eql@skip@med@above}
13108 \eql@define@key{setup}{abovemedskip}{%
13109 \def\eql@skip@med@above{#1}}
13110 \eql@define@key{setup}{belowmedskip}{%
13111 \def\eql@skip@med@below{#1}}
13112 \eql@define@key{setup}{abovetopskip}{%
13113 \def\eql@skip@top@above{#1}}
13114 \eql@define@key{setup}{belowtopskip}{%
13115 \def\eql@skip@top@below{#1}}
13116 \eql@define@key{setup}{aboveparskip}{%
13117 \def\eql@skip@par@above{#1}}
13118 \eql@define@key{setup}{belowparskip}{%
13119 \def\eql@skip@par@below{#1}}
13120 \eql@define@key{setup}{abovecontskip}{%
13121 \eql@decide@select{#3}{#2}{#1}{%
13122 {{hide}{\def\eql@skip@cont@above{\eql@spread@val-\eql@skip@long@below}}},%
13123 {\relax{\def\eql@skip@cont@above{#1}}}}}
13124 \eql@define@key{setup}{belowcontskip}{%
13125 \def\eql@skip@cont@below{#1}}
13126 \eql@define@key{setup}{shortmode}{%
13127 \eql@decide@select{#3}{#2}{#1}{%
13128 {{\eql@decide@false,never}{\def\eql@skip@mode@short{0}}},%
13129 {{above,neverbelow,belowoff}{\def\eql@skip@mode@short{1}}},%
13130 {{belowone,belowsingle}{\def\eql@skip@mode@short{2}}},%
13131 {{belowall,always,on}{\def\eql@skip@mode@short{3}}}}}
13132 \eql@define@key{setup}{abovecontmode}{%
13133 \eql@decide@situation{#3}{#2}{#1}\eql@skip@mode@cont@above}
13134 \eql@define@key{setup}{belowcontmode}{%
13135 \eql@decide@situation{#3}{#2}{#1}\eql@skip@mode@cont@below}
13136 \eql@define@key{setup}{aboveparmode}{%
13137 \eql@decide@situation{#3}{#2}{#1}\eql@skip@mode@par@above}
13138 \eql@define@key{setup}{belowparmode}{%
13139 \eql@decide@situation{#3}{#2}{#1}\eql@skip@mode@par@below}
13140 \eql@define@key{setup}{abovetopmode}{%
13141 \eql@decide@situation{#3}{#2}{#1}\eql@skip@mode@top@above}
13142 \eql@define@key{setup}{belowtopmode}{%
13143 \eql@decide@situation{#3}{#2}{#1}\eql@skip@mode@top@below}
13144 % \end{macrocode}
13145 %
13146 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13147 % \paragraph{Labels and Tag Declaration.}
13148 %
13149 % Specify label and tag for equations and subequations:
13150 % \begin{macrocode}
13151 \eql@define@key{equations,subequations}{label}{\eql@tags@addblock@label{#1}}
13152 \eql@define@key{equations,subequations}{labelname}{\eql@tags@addblock@name{#1}}
13153 \eql@define@key{equations,subequations}{tag}{\eql@tags@addblock@tag{#1}}
13154 \eql@define@key{equations,subequations}{tag*}{%
13155 \eql@tags@addblock@tagform@off\eql@tags@addblock@tag{#1}}
13156 \eql@define@key{equations,subequations}{taglabel}{\eql@tags@addblock@ref{#1}}
13157 % \end{macrocode}
13158 %
13159 % \TODO describe
13160 % \begin{macrocode}
13161 \eql@define@key{control}{label}{\eql@tags@add@label{#1}}
13162 \eql@define@key{control}{labelname}{\eql@tags@add@name{#1}}
13163 \eql@define@key{control}{tag}{\eql@tags@add@tag{#1}}
13164 \eql@define@key{control}{tag*}{\eql@tags@add@tagform@off\eql@tags@add@tag{#1}}
13165 \eql@define@key{control}{taglabel}{\eql@tags@add@ref{#1}}
13166 \eql@define@key{control}{shifttag}{\eql@tags@add@raiseshift{#1}}
13167 \eql@define@key{control}{smashtag}{\eql@tags@add@raisesmash{#1}}
13168 \eql@define@key{control}{pushtag}[]{\eql@tags@add@forceraise}
13169 % \end{macrocode}
13170 %
13171 % \TODO describe
13172 % \begin{macrocode}
13173 \eql@define@key{setup}{labelname}{\protected@edef\eql@tags@name@generic{#1}}
13174 \eql@define@key{setup}{autolabel}[true]{%
13175 \eql@decide@bool{#3}{#2}{#1}\eql@tags@autolabel}
13176 \eql@define@key{setup}{autotag}[true]{%
13177 \eql@decide@bool{#3}{#2}{#1}\eql@tags@autotag}
13178 % \end{macrocode}
13179 %
13180 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13181 % \paragraph{Tag Spacing.}
13182 %
13183 % Configure horizontal spacing for equation tags:
13184 % \begin{macrocode}
13185 \eql@define@key{equations,setup}{tagmargin}[auto]{%
13186 \eql@decide@select{#3}{#2}{#1}{%
13187 {{auto,\eql@decide@false}{\let\eql@tagmargin@val\@undefined}},%
13188 {\relax{\def\eql@tagmargin@val{#1}}}}}
13189 \eql@define@key{equations,setup}{tagmargin*}{%
13190 \settowidth\dimen@{#1}\edef\eql@tagmargin@val{\the\dimen@}}
13191 \eql@define@key{equations,setup}{tagmarginratio}{%
13192 \eql@tagmargin@ratio@\dimexpr#1pt\relax}
13193 \eql@define@key{equations,setup}{tagmarginthreshold}{%
13194 \def\eql@tagmargin@threshold{#1}}
13195 \eql@define@key{equations,setup}{mintagsep}{\def\eql@tagsepmin@val{#1}}
13196 \eql@define@key{equations,setup}{mintagwidth}{%
13197 \settowidth\dimen@{#1}\edef\eql@tagsepmin@val{\the\dimen@}}
13198 \eql@define@key{equations,setup}{mintagwidth*}{%
13199 \settowidth\eql@tagwidthmin@{#1}}
13200 \eql@define@key{equations,setup}{tagsnap}{%
13201 \eql@decide@select{#3}{#2}{#1}{%
13202 {\eql@decide@false{\let\eql@tagpos@snap\z@}},%
13203 {\relax{\def\eql@tagpos@snap{#1}}}}}
13204 % \end{macrocode}
13205 %
13206 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13207 % \paragraph{Tag Layout.}
13208 %
13209 % Configure methods to declare equation tag layout:
13210 % \begin{macrocode}
13211 \eql@define@key{equations,setup}{tagbox,taglayout}{%
13212 \eql@tags@taglayout@set{#1}}
13213 \eql@define@key{equations,setup}{tagbox*,taglayout*}{%
13214 \eql@tags@taglayout@set@direct{#1}}
13215 \eql@define@key{equations,setup}{tagform}{%
13216 \eql@tags@tagform@set#1}
13217 \eql@define@key{equations,setup}{tagform*}{%
13218 \eql@tags@tagform@set@direct{#1}}
13219 \eql@define@key{equations,setup}{subeqtemplate}{%
13220 \eql@subequations@template@set{#1}}
13221 % \end{macrocode}
13222 %
13223 % \begin{macrocode}
13224 \eql@define@key{control}{tagbox,taglayout}{%
13225 \global\eql@append\eql@tags@container{\eql@tags@taglayout@set{#1}}}
13226 \eql@define@key{control}{tagbox*,taglayout*}{%
13227 \global\eql@append\eql@tags@container{\eql@tags@taglayout@set@direct{#1}}}
13228 \eql@define@key{control}{tagform}{%
13229 \global\eql@append\eql@tags@container{\eql@tags@tagform@set#1}}
13230 \eql@define@key{control}{tagform*}[{####1}]{%
13231 \global\eql@append\eql@tags@container{\eql@tags@tagform@set@direct{#1}}}
13232 % \end{macrocode}
13233 %
13234 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13235 % \paragraph{Equation Numbering.}
13236 %
13237 % Configure equation numbering schemes:
13238 % \begin{macrocode}
13239 \eql@define@key{equations,setup}{numberline,number,num,numline,n}[all]{%
13240 \eql@decide@select{#3}{#2}{#1}{%
13241 {{\eql@decide@false,0,*}{\let\eql@numbering@active\eql@false}},%
13242 {{\eql@decide@true,!}{\let\eql@numbering@active\eql@true}},%
13243 {{none,n,-}{\let\eql@numbering@mode\eql@numbering@mode@multi
13244 \let\eql@numbering@active\eql@false}},%
13245 {{single,1}{\let\eql@numbering@mode\eql@numbering@mode@single
13246 \let\eql@numbering@active\eql@true}},%
13247 {{multi,@}{\let\eql@numbering@mode\eql@numbering@mode@multi
13248 \let\eql@numbering@active\eql@true}},%
13249 {\relax{\eql@numbering@set{#1}}}}}
13250 \eql@define@key{equations,setup}{nonumber,nn,*}[]{%
13251 \let\eql@numbering@active\eql@false}
13252 \eql@define@key{equations,setup}{donumber,dn,!}[]{%
13253 \let\eql@numbering@active\eql@true}
13254 \eql@define@key{equations,setup}{tagsleft,leqno}[]{%
13255 \let\eql@tagsleft\eql@true}
13256 \eql@define@key{equations,setup}{tagsright,reqno}[]{%
13257 \let\eql@tagsleft\eql@false}
13258 \eql@define@key{equations,setup}{tags,eqno}{%
13259 \eql@decide@select{#3}{#2}{#1}{%
13260 {{right,r}{\let\eql@tagsleft\eql@false}},%
13261 {{left,l}{\let\eql@tagsleft\eql@true}}}}
13262 \eql@define@key{equations,setup}{evadetag,avoidtag}[true]{%
13263 \eql@decide@bool{#3}{#2}{#1}\eql@numbering@best@auto}
13264 \eql@define@key{equations,setup}{tagbetween}[true]{%
13265 \eql@decide@bool{#3}{#2}{#1}\eql@tagpos@doconvert}
13266 % \end{macrocode}
13267 %
13268 % \TODO describe
13269 % \begin{macrocode}
13270 \eql@define@key{control}{nonumber,nn,*}[]{\global\@eqnswfalse}
13271 \eql@define@key{control}{donumber,dn,!}[]{\global\@eqnswtrue}
13272 \eql@define@key{control}{numberhere}[]{\eql@numberhere}
13273 \eql@define@key{control}{numbernext}[]{\eql@numbernext}
13274 % \end{macrocode}
13275 %
13276 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13277 % \paragraph{Horizontal Layout.}
13278 %
13279 % Configure horizontal alignment mode and margin for left alignment:
13280 % \begin{macrocode}
13281 \eql@define@key{equations,setup}{layout}{\eql@decide@select{#3}{#2}{#1}{%
13282 {{center,c}{\let\eql@layoutleft\eql@false}},%
13283 {{left,l}{\let\eql@layoutleft\eql@true}}}}
13284 \eql@define@key{equations,setup}{center}[]{%
13285 \let\eql@layoutleft\eql@false}
13286 \eql@define@key{equations,setup}{flushleft,left}[]{%
13287 \let\eql@layoutleft\eql@true}
13288 \eql@define@key{equations,setup}{leftmargin}{\def\eql@layoutleftmargin{#1}}
13289 \eql@define@key{equations,setup}{leftmargin*}{%
13290 \settowidth\dimen@{#1}\edef\eql@layoutleftmargin{\the\dimen@}}
13291 \eql@define@key{equations,setup}{minleftmargin}{%
13292 \def\eql@layoutleftmarginmin{#1}}
13293 \eql@define@key{equations,setup}{maxleftmargin}{%
13294 \eql@decide@select{#3}{#2}{#1}{%
13295 {\eql@decide@false{\def\eql@layoutleftmarginmax{.5\maxdimen}}},%
13296 {\relax{\def\eql@layoutleftmarginmax{#1}}}}}
13297 % \end{macrocode}
13298 %
13299 % \begin{macrocode}
13300 \eql@define@key{equations,box}{margin}{%
13301 \def\eql@display@marginleft{#1}\def\eql@display@marginright{#1}}
13302 \eql@define@key{equations,box}{marginleft}{\def\eql@display@marginleft{#1}}
13303 \eql@define@key{equations,box}{marginright}{\def\eql@display@marginright{#1}}
13304 \eql@define@key{equations}{linewidth,width}{\def\eql@display@linewidth{#1}}
13305 % \end{macrocode}
13306 %
13307 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13308 % \paragraph{Horizontal Spacing and Columns.}
13309 %
13310 % Configure column spacing and compression threshold:
13311 % \begin{macrocode}
13312 \eql@define@key{equations,setup}{alignshrink}{\eql@decide@select{#3}{#2}{#1}{%
13313 {{max,full,4}{\eql@alignbadness@\inf@bad}},%
13314 {{high,3}{\eql@alignbadness@54\relax}},%
13315 {{med,medium,2}{\eql@alignbadness@18\relax}},%
13316 {{low,1}{\eql@alignbadness@6\relax}},%
13317 {{0,\eql@decide@false}{\eql@alignbadness@\z@}}}}
13318 \eql@define@key{equations,setup}{tagshrink}{\eql@decide@select{#3}{#2}{#1}{%
13319 {{max,full,4}{\eql@tagbadness@\inf@bad}},%
13320 {{high,3}{\eql@tagbadness@54\relax}},%
13321 {{med,medium,2}{\eql@tagbadness@18\relax}},%
13322 {{low,1}{\eql@tagbadness@6\relax}},%
13323 {{0,\eql@decide@false}{\eql@tagbadness@\z@}}}}
13324 \eql@define@key{equations,setup}{alignbadness}{%
13325 \eql@alignbadness@\numexpr#1\relax}
13326 \eql@define@key{equations,setup}{tagbadness}{%
13327 \eql@tagbadness@\numexpr#1\relax}
13328 \eql@define@key{equations,setup}{mincolsep}{\eql@decide@select{#3}{#2}{#1}{%
13329 {{0,\eql@decide@false}{\def\eql@colsepmin@val{0pt}}},%
13330 {\relax{\def\eql@colsepmin@val{#1}}}}}
13331 \eql@define@key{equations,setup}{maxcolsep}{\eql@decide@select{#3}{#2}{#1}{%
13332 {\eql@decide@false{\def\eql@colsepmax@val{.5\maxdimen}}},%
13333 {0{\def\eql@colsepmax@val{0pt}}},%
13334 {\relax{\def\eql@colsepmax@val{#1}}}}}
13335 \eql@define@key{equations,setup}{fulllength}[true]{%
13336 \eql@decide@bool{#3}{#2}{#1}\eql@columns@fulllength}
13337 % \end{macrocode}
13338 %
13339 % \TODO is boxcolsep vs breakcolsep okay??!
13340 % \begin{macrocode}
13341 \eql@define@key{equations,setup}{linesep}{\eql@decide@select{#3}{#2}{#1}{%
13342 {{0,\eql@decide@false}{\def\eql@break@line@sep{0pt}}},%
13343 {\relax{\def\eql@break@line@sep{#1}}}}}
13344 \eql@define@key{equations,setup}{linesep*}{\eql@decide@select{#3}{#2}{#1}{%
13345 {{0,\eql@decide@false}{\def\eql@break@line@shortsep{0pt}}},%
13346 {\relax{\def\eql@break@line@shortsep{#1}}}}}
13347 \eql@define@key{box,setup}{colsep}{\eql@decide@select{#3}{#2}{#1}{%
13348 {{0,\eql@decide@false}{\def\eql@box@colsep{0pt}}},%
13349 {{short,*}{\def\eql@box@colsep{\eql@box@shortsep}}},%
13350 {\relax{\def\eql@box@colsep{#1}}}}%
13351 \let\eql@break@col@sep\eql@box@colsep}
13352 \eql@define@key{equations}{colsep}{\eql@decide@select{#3}{#2}{#1}{%
13353 {{0,\eql@decide@false}{\def\eql@break@col@sep{0pt}}},%
13354 {\relax{\def\eql@break@col@sep{#1}}}}%
13355 \let\eql@colsepmin@val\eql@box@colsep
13356 \let\eql@colsepmax@val\eql@box@colsep
13357 \let\eql@box@colsep\eql@break@col@sep}
13358 \eql@define@key{equations,setup}{colsep*}{\eql@decide@select{#3}{#2}{#1}{%
13359 {{0,\eql@decide@false}{\def\eql@break@col@shortsep{0pt}}},%
13360 {\relax{\def\eql@break@col@shortsep{#1}}}}}
13361 \eql@define@key{box,setup}{colsep*}{\eql@decide@select{#3}{#2}{#1}{%
13362 {{0,\eql@decide@false}{\def\eql@box@shortsep{0pt}}},%
13363 {\relax{\def\eql@box@shortsep{#1}}}}}
13364 \eql@define@key{box,setup}{condsep}{\eql@decide@select{#3}{#2}{#1}{%
13365 {{0,\eql@decide@false}{\def\eql@box@condsep{0pt}}},%
13366 {{short,*}{\def\eql@box@condsep{\eql@box@shortsep}}},%
13367 {\relax{\def\eql@box@condsep{#1}}}}}
13368 \eql@define@key{box,setup}{matrixsep}{\eql@decide@select{#3}{#2}{#1}{%
13369 {{0,\eql@decide@false}{\def\eql@box@matrixsep{0pt}}},%
13370 {{short,*}{\def\eql@box@matrixsep{\eql@box@shortsep}}},%
13371 {\relax{\def\eql@box@matrixsep{#1}}}}}
13372 % \end{macrocode}
13373 %
13374 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13375 % \paragraph{Horizontal Shape.}
13376 %
13377 % Configure horizontal alignment schemes:
13378 % \begin{macrocode}
13379 \eql@define@key\eql@keyall{shape}[default]{\eql@shape@set{#1}}
13380 \eql@define@key\eql@keyall{padding,pad}[indent]{%
13381 \eql@decide@select{#3}{#2}{#1}{%
13382 {{max}{\let\eql@paddingleft@val\@undefined}},%
13383 {{indent}{\def\eql@paddingleft@val{\eql@indent@val}}},%
13384 {{0,\eql@decide@false}{\def\eql@paddingleft@val{0pt}}},%
13385 {\relax{\def\eql@paddingleft@val{#1}}}}%
13386 \let\eql@paddingright@val\eql@paddingleft@val}
13387 \eql@define@key\eql@keyall{padleft}[indent]{%
13388 \eql@decide@select{#3}{#2}{#1}{%
13389 {{max}{\let\eql@paddingleft@val\@undefined}},%
13390 {{indent}{\def\eql@paddingleft@val{\eql@indent@val}}},%
13391 {{0,\eql@decide@false}{\def\eql@paddingleft@val{0pt}}},%
13392 {\relax{\def\eql@paddingleft@val{#1}}}}}
13393 \eql@define@key\eql@keyall{padright}[indent]{%
13394 \eql@decide@select{#3}{#2}{#1}{%
13395 {{max}{\let\eql@paddingright@val\@undefined}},%
13396 {{indent}{\def\eql@paddingright@val{\eql@indent@val}}},%
13397 {{0,\eql@decide@false}{\def\eql@paddingright@val{0pt}}},%
13398 {\relax{\def\eql@paddingright@val{#1}}}}}
13399 \eql@define@key\eql@keyall{indent}[2em]{%
13400 \def\eql@indent@val{#1}}
13401 % \end{macrocode}
13402 %
13403 % \TODO describe
13404 % \begin{macrocode}
13405 \def\eql@shape@rel{\eqncontrol{align=left}}
13406 \def\eql@shape@cont{\eqncontrol{align=left,shift=*}}
13407 \eql@define@key\eql@keyall{shaperel}[]{\def\eql@shape@rel{#1}}
13408 \eql@define@key\eql@keyall{shapecont}[]{\def\eql@shape@cont{#1}}
13409 % \end{macrocode}
13410 %
13411 % \TODO describe
13412 % \begin{macrocode}
13413 \eql@define@key{control}{align}[]{%
13414 \eql@decide@select{#3}{#2}{#1}{%
13415 {{l,left}{\global\eql@append\eql@cell@container{\eql@shape@pos@\z@}}},%
13416 {{c,center}{\global\eql@append\eql@cell@container{\eql@shape@pos@\@ne}}},%
13417 {{r,right}{\global\eql@append\eql@cell@container{\eql@shape@pos@\tw@}}}}}
13418 \eql@define@key{control}{shift,shiftto}[]{%
13419 \eql@decide@select{#3}{#2}{#1}{%
13420 {{*,indent}{\eql@shape@alignamount@set{\eql@indent@}}},%
13421 {{!,outdent}{\eql@shape@alignamount@set{-\eql@indent@}}},%
13422 {\relax{\eql@shape@alignamount@set{#1}}}}}
13423 \eql@define@key{control}{shift*,shiftby}[]{\eql@shape@alignamount@add{#1}}
13424 % \end{macrocode}
13425 %
13426 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13427 % \paragraph{Math Classes at Alignment.}
13428 %
13429 % Configure math classes at alignment marker:
13430 % \begin{macrocode}
13431 \eql@define@key\eql@keyall{classout}{\eql@class@innerleft@set{#1}}
13432 \eql@define@key\eql@keyall{classin}{\eql@class@innerright@set{#1}}
13433 \eql@define@key\eql@keyall{classlead,classin*}{\eql@class@innerlead@set{#1}}
13434 \eql@define@key\eql@keyall{rel}{\def\eql@class@rel@symb{#1}}
13435 \eql@define@key\eql@keyall{classbreak}{\eql@class@rel@break@set{#1}}
13436 \eql@define@key\eql@keyall{classstart}{\eql@class@rel@start@set{#1}}
13437 \eql@define@key\eql@keyall{classbreakskip}[adjust]{%
13438 \eql@decide@select{#3}{#2}{#1}{%
13439 {{0,\eql@decide@false}{\def\eql@class@rel@break@skip{0mu}}},%
13440 {{adjust,*}{\def\eql@class@rel@break@skip{\thickmuskip-\medmuskip}}},%
13441 {\relax{\def\eql@class@rel@break@skip{#1}}}}}
13442 \eql@define@key{control}{rel}[\eql@class@rel@symb]{\eql@class@rel@make{#1}}
13443 \eql@define@key{control}{rel;}[]{\eql@class@rel@make{}}
13444 \eql@define@key{control}{rel*}[]{\eql@class@rel@make{}}
13445 \eql@define@key\eql@keyall{ampeq}[]{\eql@class@ampeq}
13446 \eql@define@key\eql@keyall{eqamp}[]{\eql@class@eqamp}
13447 \eql@define@key\eql@keyall{class}{\eql@decide@select{#3}{#2}{#1}{%
13448 {{ampeq,amprel,eqafter,beforerel}\eql@class@ampeq},%
13449 {{eqamp,relamp,eqbefore,afterrel}\eql@class@eqamp}}}
13450 % \end{macrocode}
13451 %
13452 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13453 % \paragraph{Math Styles.}
13454 %
13455 % Configure math classes at alignment marker:
13456 % \begin{macrocode}
13457 \eql@define@key\eql@keyall{style}[display]{%
13458 \eql@decide@select{#3}{#2}{#1}{%
13459 {{text}{\let\eql@mathstyle\@empty}},%
13460 {{display}{\let\eql@mathstyle\displaystyle}}}}
13461 \eql@define@key{setup}{casesstyle}[display]{%
13462 \eql@decide@select{#3}{#2}{#1}{%
13463 {\eql@decide@false{\let\eql@cases@mathstyle\eql@false}},%
13464 {{text}{\let\eql@cases@mathstyle\@empty}},%
13465 {{display}{\let\eql@cases@mathstyle\displaystyle}}}}
13466 % \end{macrocode}
13467 %
13468 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13469 % \paragraph{Punctuation.}
13470 %
13471 % Configure punctuation defaults:
13472 % \TODO describe
13473 % \begin{macrocode}
13474 \def\eql@punct@all#1#2#3#4#5\eql@punct@end{%
13475 \def\eql@tmp{#4}\def\eql@tmpa{1}%
13476 \ifx\eql@tmp\eql@tmpa
13477 \ifnum#5=1111\relax
13478 \eql@punct@set\eql@punct@col{#1}%
13479 \eql@punct@set\eql@punct@line{#2}%
13480 \eql@punct@set\eql@punct@block{#3}%
13481 \else\ifnum#5=111\relax
13482 \eql@punct@set\eql@punct@line{#1}%
13483 \eql@punct@set\eql@punct@block{#2}%
13484 \else\ifnum#5=11\relax
13485 \eql@punct@set\eql@punct@block{#1}%
13486 \else
13487 \eql@punct@clear
13488 \fi\fi\fi
13489 \else
13490 \eql@error{Too many arguments to punctall}%
13491 \fi
13492 }
13493 % \end{macrocode}
13494 %
13495 % \TODO describe
13496 % \begin{macrocode}
13497 \eql@define@key\eql@keyall{punctsep}[\,]{\def\eql@punct@sep{#1}}
13498 \eql@define@key\eql@keyall{punctclass}[\mathclose{}]{\def\eql@punct@class{#1}}
13499 \eql@define@key\eql@keyall{punct}[.]{\eql@punct@set\eql@punct@block{#1}}
13500 \eql@define@key\eql@keyall{punct*}[]{\eql@punct@set\eql@punct@block\relax}
13501 \eql@define@key\eql@keyall{punctline}[,]{\eql@punct@set\eql@punct@line{#1}}
13502 \eql@define@key\eql@keyall{punctline*}[]{\eql@punct@set\eql@punct@line\relax}
13503 \eql@define@key\eql@keyall{punctcol}[,]{\eql@punct@set\eql@punct@col{#1}}
13504 \eql@define@key\eql@keyall{punctcol*}[]{\eql@punct@set\eql@punct@col\relax}
13505 \eql@define@key{box}{punctcases}[,]{\eql@punct@set\eql@punct@col{#1}}
13506 \eql@define@key{box}{punctcases*}[]{\eql@punct@set\eql@punct@col\relax}
13507 \eql@define@key{setup}{punctcases}[,]{\eql@punct@set\eql@punct@cases{#1}}
13508 \eql@define@key{setup}{punctcases*}[]{\eql@punct@set\eql@punct@cases\relax}
13509 \eql@define@key\eql@keyall{punctall}[,,.]{\eql@punct@all#111111\eql@punct@end}
13510 \eql@define@key{box}{punctterm}[true]{%
13511 \eql@decide@bool{#3}{#2}{#1}\eql@box@punct@term}
13512 % \end{macrocode}
13513 %
13514 % \begin{macrocode}
13515 \eql@define@key{control}{punctsep}[\,]{\def\eql@punct@sep{#1}}
13516 \eql@define@key{control}{setpunct}[.]{\eql@punct@set\eql@punct@next{#1}}
13517 \eql@define@key{control}{setpunct}[.]{\eql@punct@set\eql@punct@next{#1}}
13518 \eql@define@key{control}{setpunct*}[]{\let\eql@punct@next\relax}
13519 \eql@define@key{control}{punct,punctapply}[\relax]{%
13520 \eql@punct@set\eql@punct@next{#1}\eql@punct@apply@top}
13521 \eql@define@key{control}{punctline}[]{\eql@punct@print@line}
13522 \eql@define@key{control}{punctcol}[]{\eql@punct@print@col}
13523 % \end{macrocode}
13524 %
13525 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13526 % \paragraph{Frames.}
13527 %
13528 % \TODO describe
13529 % \begin{macrocode}
13530 \eql@define@key{box}{frame}[\fbox]{%
13531 \def\eql@box@frame{#1}%
13532 \ifx\eql@box@frame\@empty\let\eql@box@frame\@firstofone\fi}
13533 \eql@define@key{box}{wrap}{\eql@box@wrap#1}
13534 \eql@define@key{box}{delim}[r]{\eql@decide@delim{#3}{#2}{#1}}
13535 \eql@define@key{box}{ldelim}{\eql@box@ldelim#1}
13536 \eql@define@key{box}{rdelim}{\eql@box@rdelim#1}
13537 \eql@define@key{box}{lbrace}[]{\eql@box@ldelim\lbrace}
13538 \eql@define@key{box}{rbrace}[]{\eql@box@rdelim\rbrace}
13539 \eql@define@key{box}{lrbrace,lrbraces}[]{\eql@box@delim\lbrace\rbrace}
13540 \eql@define@key{box}{braces}[lr]{%
13541 \eql@decide@select{#3}{#2}{#1}{%
13542 {{\eql@decide@false}{\eql@box@wrap{}{}}},%
13543 {{l,left}{\eql@box@ldelim\lbrace}},%
13544 {{r,right}{\eql@box@rdelim\rbrace}},%
13545 {{\eql@decide@true,lr,both}{\eql@box@delim\lbrace\rbrace}}}}
13546 % \end{macrocode}
13547 %
13548 % \TODO describe
13549 % \begin{macrocode}
13550 \eql@define@key{control}{framecell}[\fbox]{%
13551 \global\eql@append\eql@cell@container{\def\eql@frame@cmd{#1}}}
13552 \eql@define@key{control}{frametag}[\fbox]{%
13553 \global\eql@append\eql@tags@container{\def\eql@tags@frame@cmd{#1}}}
13554 % \end{macrocode}
13555 %
13556 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13557 % \paragraph{Alternative Content Description.}
13558 %
13559 % Alternative content description for accessibility or documentation purposes:
13560 % \TODO implement in PDF tagging
13561 % \begin{macrocode}
13562 \eql@define@key{equations,box}{alt}{}
13563 % \end{macrocode}
13564 %
13565 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13566 % \paragraph{Injections.}
13567 %
13568 % \begin{macrocode}
13569 \eql@define@key{control}{inject}{%
13570 \global\eql@append\eql@interline@container{%
13571 \eql@append\eql@display@injectbefore{#1}}}
13572 \eql@define@key{control}{inject*}{%
13573 \global\eql@append\eql@interline@container{%
13574 \eql@append\eql@display@injectafter{#1}}}
13575 \eql@define@key{control}{markline}[]{\eql@markline@inject{#1}}
13576 \eql@define@key{control}{markline*}[]{\eql@markline@inject{push,#1}}
13577 \eql@define@key{control}{qed}[]{\eql@markline@inject{qed,#1}}
13578 \eql@define@key{control}{qed*}[]{\eql@markline@inject{qed,push,#1}}
13579 % \end{macrocode}
13580 %
13581 % \TODO describe
13582 % \begin{macrocode}
13583 \eql@define@key{markline}{pos}{%
13584 \eql@decide@select{#3}{#2}{#1}{%
13585 {{below,push}{\let\eql@markline@pos\eql@markline@pos@below}},%
13586 {{baseline}{\let\eql@markline@pos\eql@markline@pos@baseline}},%
13587 {{bottom}{\let\eql@markline@pos\eql@markline@pos@bottom}}}}
13588 \eql@define@key{markline}{below,push}[]{%
13589 \let\eql@markline@pos\eql@markline@pos@below}
13590 \eql@define@key{markline}{baseline}[]{%
13591 \let\eql@markline@pos\eql@markline@pos@baseline}
13592 \eql@define@key{markline}{bottom}[]{%
13593 \let\eql@markline@pos\eql@markline@pos@bottom}
13594 \eql@define@key{markline}{shift}{\def\eql@markline@shift{#1}}
13595 \eql@define@key{markline}{symbol}{\def\eql@markline@symbol{#1}}
13596 \eql@define@key{markline}{qed}[]{\let\eql@markline@symbol\eql@markline@qed}
13597 \eql@define@key{setup}{marksymbol}{\def\eql@markline@symbol{#1}}
13598 \eql@define@key{setup}{qedsymbol}{\def\eql@markline@qed{#1}}
13599 \eql@define@key{setup}{markpos}{%
13600 \eql@decide@select{#3}{#2}{#1}{%
13601 {{below}{\let\eql@markline@pos\eql@markline@pos@below}},%
13602 {{baseline}{\let\eql@markline@pos\eql@markline@pos@baseline}},%
13603 {{bottom}{\let\eql@markline@pos\eql@markline@pos@bottom}}}}
13604 % \end{macrocode}
13605 %
13606 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13607 % \paragraph{Global Switches.}
13608 %
13609 % Set global switches:
13610 % \begin{macrocode}
13611 \let\eql@multi@linesfallback\eql@false
13612 \let\eql@scan@par\eql@false
13613 \let\eql@single@cr@mode\eql@false
13614 \let\eql@amp@mode\eql@true
13615 \let\eql@ampproof@active\eql@false
13616 \let\eql@parseopt@warn@env\eql@warn@parseopt
13617 \let\eql@parseopt@warn@cr\@empty
13618 % \end{macrocode}
13619 %
13620 % \begin{macrocode}
13621 \eql@define@key{equations,setup}{linesfallback}[true]{%
13622 \eql@decide@select{#3}{#2}{#1}{%
13623 {\eql@decide@false{\let\eql@multi@linesfallback\eql@false}},%
13624 {{reuse,lean}{\let\eql@multi@linesfallback\z@}},%
13625 {{measure,full,\eql@decide@true}{\let\eql@multi@linesfallback\eql@true}}}}
13626 \eql@define@key{setup}{ampproof}[true]{%
13627 \eql@decide@bool{#3}{#2}{#1}\eql@ampproof@active}
13628 \eql@define@key{equations,setup}{equationcr}[true]{%
13629 \eql@decide@select{#3}{#2}{#1}{%
13630 {\eql@decide@false{\let\eql@single@cr@mode\eql@false}},%
13631 {{\eql@decide@true,break}{\let\eql@single@cr@mode\eql@break@cr}},%
13632 {{error,verbose}{\let\eql@single@cr@mode\eql@single@cr@error}}}}
13633 \eql@define@key\eql@keyall{amp}[true]{%
13634 \eql@decide@bool{#3}{#2}{#1}{\eql@amp@mode}}
13635 \eql@define@key\eql@keyall{rescan}[true]{%
13636 \eql@decide@if{#3}{#2}{#1}%
13637 {\let\eql@scan@body\eql@scan@body@rescan}%
13638 {\let\eql@scan@body\eql@scan@body@dump}}
13639 \eql@define@key\eql@keyall{scanpar}[true]{%
13640 \eql@decide@bool{#3}{#2}{#1}\eql@scan@par}
13641 \eql@define@key{setup}{defaults}{%
13642 \eql@decide@select{#3}{#2}{#1}{%
13643 {{classic}{\eql@defaults@classic}},%
13644 {{eqnlines}{\eql@defaults@eqnlines}}}}
13645 \eql@define@key\eql@keyall{verbose}[true]{%
13646 \eql@decide@if{#3}{#2}{#1}\eql@verbose@on\eql@verbose@off}
13647 % \end{macrocode}
13648 %
13649 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13650 % \paragraph{Package Options.}
13651 %
13652 % Declare choices available at loading of package only:
13653 % \TODO adjust
13654 % \begin{macrocode}
13655 \let\eql@provide@opt@env\tw@
13656 \let\eql@provide@opt@amsmathpatch\eql@false
13657 \let\eql@provide@opt@backup\eql@false
13658 \let\eql@provide@opt@ang\eql@true
13659 \let\eql@provide@opt@eqref\eql@true
13660 \let\eql@provide@opt@matrix\eql@true
13661 % \end{macrocode}
13662 %
13663 % \begin{macrocode}
13664 \eql@define@key{setup}{amsmathends,amsmathpatch}[true]{%
13665 \eql@error@packageoption{#2}%
13666 \eql@decide@bool{#3}{#2}{#1}\eql@provide@opt@amsmathpatch}
13667 \eql@define@key{setup}{backup}[true]{%
13668 \eql@error@packageoption{#2}%
13669 \eql@decide@bool{#3}{#2}{#1}\eql@provide@opt@backup}
13670 \eql@define@key{setup}{env}[equation]{%
13671 \eql@error@packageoption{#2}%
13672 \eql@decide@select{#3}{#2}{#1}{%
13673 {{none,\eql@decide@false}{\let\eql@provide@opt@env\z@}},%
13674 {{equation,latex}{\let\eql@provide@opt@env\@ne}},%
13675 {{amsmath,all,\eql@decide@true}{\let\eql@provide@opt@env\tw@}}}}
13676 \eql@define@key{setup}{ang}[true]{%
13677 \eql@error@packageoption{#2}%
13678 \eql@decide@bool{#3}{#2}{#1}\eql@provide@opt@ang}
13679 \eql@define@key{setup}{eqref}[true]{%
13680 \eql@error@packageoption{#2}%
13681 \eql@decide@bool{#3}{#2}{#1}\eql@provide@opt@eqref}
13682 \eql@define@key{setup}{matrix}[true]{%
13683 \eql@error@packageoption{#2}%
13684 \eql@decide@bool{#3}{#2}{#1}\eql@provide@opt@matrix}
13685 % \end{macrocode}
13686 %
13687 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13688 % \paragraph{Shortcut Options.}
13689 %
13690 % \TODO describe
13691 % \begin{macrocode}
13692 \def\eql@parseopt@nonumber#1{\eqnaddopt{nonumber}\eql@parseopt@peek}
13693 \def\eql@parseopt@donumber#1{\eqnaddopt{donumber}\eql@parseopt@peek}
13694 \def\eql@parseopt@single#1{\eqnaddopt{single}\eql@parseopt@peek}
13695 \def\eql@parseopt@lines#1{\eqnaddopt{lines}\eql@parseopt@peek}
13696 \def\eql@parseopt@eqamp#1{\eqnaddopt{eqamp}\eql@parseopt@peek}
13697 \def\eql@parseopt@ampeq#1{\eqnaddopt{ampeq}\eql@parseopt@peek}
13698 \def\eql@parseopt@columns#1{\eqnaddopt{columns}\eql@parseopt@peek}
13699 \def\eql@parseopt@transpose#1{\eqnaddopt{columns,transpose}\eql@parseopt@peek}
13700 \def\eql@parseopt@opt[#1]{\eqnaddopt{#1}\eql@parseopt@peek}
13701 \def\eql@parseopt@label#1#2{\eqnaddopt{label={#2}}\eql@parseopt@peek}
13702 \def\eql@parseopt@punctpass{\eql@parseopt@peek`}
13703 \def\eql@parseopt@punctclear#1{\eql@parseopt@peek`~}
13704 \def\eql@parseopt@punctopt#1#2{\eqnaddopt{punctall={#2}}\eql@parseopt@peek}
13705 \def\eql@parseopt@punctnext#1#2{%
13706 \eql@punct@set\eql@punct@next{#2}\eql@parseopt@peek}
13707 \def\eql@parseopt@punctblock#1#2{%
13708 \eql@punct@set\eql@punct@block{#2}\eql@parseopt@peek}
13709 \def\eql@parseopt@punctterm#1{\let\eql@punct@term\eql@true\eql@parseopt@peek}
13710 \def\eql@parseopt@relsymb#1{\eql@parseopt@peek?\eql@class@rel@symb}
13711 \def\eql@parseopt@relcont#1{\eql@parseopt@peek?{}}
13712 \def\eql@parseopt@relstart#1{\eql@parseopt@peek?\relax}
13713 \def\eql@parseopt@relord#1{\eql@parseopt@peek?{{}}}
13714 \def\eql@parseopt@vspace[#1]{%
13715 \advance\eql@vspaceskip@\glueexpr#1\relax\eql@parseopt@peek}
13716 % \end{macrocode}
13717 %
13718 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13719 % \subsection{Parameter Presets}
13720 %
13721 % The package offers two parameter presets
13722 % which lead to somewhat different layout.
13723 % Instead of setting the internal parameters directly,
13724 % we expose them as public settings so that
13725 % they are easier to read and such that individual settings
13726 % can be used to compose own layouts.
13727 %
13728 % \macro{\eql@defaults@classic}
13729 % The preset |classic| aims to reproduce
13730 % the \tex/, \latex/ and \amsmath/ layout closely.
13731 % These presets mostly use fixed dimensions:
13732 % \begin{macrocode}
13733 \def\eql@defaults@classic{%
13734 \eqnlinesset{numberline=all}%
13735 \eqnlinesset{condsep={1em}}%
13736 \eqnlinesset{matrixsep={2\arraycolsep}}%
13737 \eqnlinesset{mintagsep={.5\fontdimen6\textfont2}}%
13738 \eqnlinesset{maxcolsep=off}%
13739 \eqnlinesset{spread={\jot}}%
13740 \eqnlinesset{tagmargin}%
13741 \eqnlinesset{tagmarginratio=1}%
13742 \eqnlinesset{tagmarginthreshold=0.5}%
13743 \eqnlinesset{leftmargin={\leftmargini}}%
13744 \eqnlinesset{padding=max}%
13745 \eqnlinesset{evadetag=off}%
13746 \eqnlinesset{displayheight=off}%
13747 \eqnlinesset{displaydepth=off}%
13748 \eqnlinesset{shortmode=belowsingle}%
13749 \eqnlinesset{abovecontmode=short}%
13750 \eqnlinesset{belowcontmode=short}%
13751 \eqnlinesset{aboveparmode=long}%
13752 \eqnlinesset{belowparmode=long}%
13753 \eqnlinesset{abovetopmode=long}%
13754 \eqnlinesset{belowtopmode=long}%
13755 \eqnlinesset{abovelongskip={\abovedisplayskip}}%
13756 \eqnlinesset{belowlongskip={\belowdisplayskip}}%
13757 \eqnlinesset{aboveshortskip={\abovedisplayshortskip}}%
13758 \eqnlinesset{belowshortskip={\belowdisplayshortskip}}%
13759 \eqnlinesset{abovemedskip={.5\abovedisplayskip}}%
13760 \eqnlinesset{belowmedskip={.5\belowdisplayskip}}%
13761 \eqnlinesset{abovecontskip=0pt}%
13762 \eqnlinesset{belowcontskip=0pt}%
13763 \eqnlinesset{aboveparskip=0pt}%
13764 \eqnlinesset{belowparskip=0pt}%
13765 \eqnlinesset{abovetopskip=0pt}%
13766 \eqnlinesset{belowtopskip=0pt}%
13767 \eqnlinesset{abovetagskip=0pt}%
13768 \eqnlinesset{belowtagskip=0pt}%
13769 \eqnlinesset{allowbreaks=0}%
13770 \eqnlinesset{equationcr=off}%
13771 \eqnlinesset{amp=off}%
13772 \eqnlinesset{modifier=off}%
13773 \eqnlinesset{linesfallback=false}%
13774 \eqnlinesset{casesstyle=text}%
13775 \eqnlinesset{sqropt=nonumber}%
13776 \eqnlinesset{angopt=nonumber}%
13777 }
13778 % \end{macrocode}
13779 %
13780 % values based on 10pt vs 12pt
13781 % \macro{\eql@defaults@eqnlines}
13782 % The (default) preset |eqnlines| implements a layout
13783 % that scales with the font size by using the units |em|
13784 % and |\normalbaselineskip| for horizontal and vertical spacing, respectively.
13785 % It aims to approximately reproduce the |classic| spacing
13786 % for a 12\,pt computer modern font such that 10\,pt fonts
13787 % will lead to slightly reduced spacing.
13788 % Apart from that, the |eqnlines| setting makes some
13789 % deliberate layout choices that deviate significantly
13790 % from |classic| (maximum column separation,
13791 % no shortening below equations):
13792 % \begin{macrocode}
13793 \def\eql@defaults@eqnlines{%
13794 \eqnlinesset{numberline=all}%
13795 \eqnlinesset{condsep=short}%
13796 \eqnlinesset{matrixsep=short}%
13797 \eqnlinesset{mintagsep=.5em}%
13798 \eqnlinesset{maxcolsep=2em}%
13799 \eqnlinesset{spread={0.2\normalbaselineskip}}%
13800 \eqnlinesset{tagmargin}%
13801 \eqnlinesset{tagmarginratio=.334}%
13802 \eqnlinesset{tagmarginthreshold=0.5}%
13803 \eqnlinesset{leftmargin={\leftmargini}}%
13804 \eqnlinesset{padding=0pt}%
13805 \eqnlinesset{evadetag}%
13806 \eqnlinesset{displayheight=strut}%
13807 \eqnlinesset{displaydepth=strut}%
13808 \eqnlinesset{shortmode=above}%
13809 \eqnlinesset{abovecontmode=noskip}%
13810 \eqnlinesset{belowcontmode=long}%
13811 \eqnlinesset{aboveparmode=long}%
13812 \eqnlinesset{belowparmode=long}%
13813 \eqnlinesset{abovetopmode=noskip}%
13814 \eqnlinesset{belowtopmode=long}%
13815 \eqnlinesset{longskip={0.75\normalbaselineskip
13816 plus 0.25\normalbaselineskip minus 0.4\normalbaselineskip}}%
13817 \eqnlinesset{aboveshortskip={0.0\normalbaselineskip
13818 plus 0.25\normalbaselineskip}}%
13819 \eqnlinesset{belowshortskip={0.0\normalbaselineskip
13820 plus 0.25\normalbaselineskip}}%
13821 \eqnlinesset{medskip={0.4\normalbaselineskip
13822 plus 0.2\normalbaselineskip minus 0.2\normalbaselineskip}}%
13823 \eqnlinesset{abovecontskip=0pt}%
13824 \eqnlinesset{belowcontskip=0pt}%
13825 \eqnlinesset{aboveparskip=0pt}%
13826 \eqnlinesset{belowparskip=0pt}%
13827 \eqnlinesset{abovetopskip=0pt}%
13828 \eqnlinesset{belowtopskip=0pt}%
13829 \eqnlinesset{abovetagskip={0.25\normalbaselineskip
13830 minus 0.25\normalbaselineskip}}%
13831 \eqnlinesset{belowtagskip={0.25\normalbaselineskip
13832 minus 0.25\normalbaselineskip}}%
13833 \eqnlinesset{allowbreaks=3}%
13834 \eqnlinesset{equationcr=break}%
13835 \eqnlinesset{amp=on}%
13836 \eqnlinesset{modifier=on,modifierenv=off}%
13837 \eqnlinesset{linesfallback=true}%
13838 \eqnlinesset{casesstyle=false}%
13839 \eqnlinesset{sqropt=}%
13840 \eqnlinesset{angopt=}%
13841 }
13842 % \end{macrocode}
13843 %
13844 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13845 % \subsection{Component Selection}
13846 %
13847 % The following routines provide several additional math environments
13848 % beyond |equations|. They also backup and overwrite the original routines
13849 % of \latex/ and \amsmath/ carefully.
13850 %
13851 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13852 % \paragraph{Tools.}
13853 %
13854 % \macro{\eql@provide@movecmd}
13855 % \macro{\eql@provide@moveenv}
13856 % \macro{\eql@provide@undefinecmd}
13857 % \macro{\eql@provide@undefineenv}
13858 % We introduce a couple of tools to rename and undefine
13859 % commands and environments:
13860 % \begin{macrocode}
13861 \def\eql@provide@movecmd#1#2{%
13862 \eql@letcs{#1\expandafter}\csname#2\endcsname
13863 }
13864 \def\eql@provide@moveenv#1#2{%
13865 \eql@provide@movecmd{#1}{#2}%
13866 \ifcsname end#2\endcsname
13867 \eql@provide@movecmd{end#1}{end#2}%
13868 \fi
13869 }
13870 \def\eql@provide@undefinecmd#1{%
13871 \eql@letcs{#1}\@undefined
13872 }
13873 \def\eql@provide@undefineenv#1{%
13874 \eql@provide@undefinecmd{#1}%
13875 \eql@provide@undefinecmd{end#1}%
13876 }
13877 % \end{macrocode}
13878 %
13879 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13880 % \paragraph{Fix Endings for amsmath Environments.}
13881 %
13882 % The \amsmath/ derived environments forward their ending routines
13883 % directly to the ending routines for the main environments
13884 % |gather|, |multline|, |align|, |aligned|.
13885 % This causes a problem when the main environments are replaced
13886 % but the derived ones are still used. We fix the potential problem
13887 % by copying the ending routines of the main environments
13888 % to the ending routines of the derived environments.
13889 %
13890 % \macro{\eql@amsmath@endfix}
13891 % Check whether the original forwarding
13892 % of an ending routine is still in place
13893 % (other packages or future updates to \amsmath/ might change the behaviour).
13894 % If so, copy the ending routine into place:
13895 % \begin{macrocode}
13896 \def\eql@amsmath@endfix#1#2{%
13897 \long\edef\eql@tmpa{\expandafter\noexpand\csname end#2\endcsname}%
13898 \expandafter\ifx\csname end#1\endcsname\eql@tmpa
13899 \eql@provide@movecmd{end#1}{end#2}%
13900 \fi
13901 }
13902 % \end{macrocode}
13903 %
13904 % \macro{\eql@amsmath@fixmatrix}
13905 % \macro{\eql@amsmath@fixmatrixend}
13906 % \TODO describe
13907 % \begin{macrocode}
13908 \def\eql@amsmath@fixmatrix#1{%
13909 \expandafter\let\expandafter\eql@tmp\csname#1\endcsname
13910 \begingroup
13911 \let\matrix@check\@gobble
13912 \def\env@matrix{\noexpand\env@matrix}%
13913 \def\env@cases{\noexpand\env@cases}%
13914 \global\edef\eql@tmp{\eql@tmp}%
13915 \endgroup
13916 \eql@letcs{#1}\eql@tmp
13917 }
13918 \def\eql@amsmath@fixmatrixend#1{%
13919 \expandafter\let\expandafter\eql@tmp\csname end#1\endcsname
13920 \begingroup
13921 \expandafter\def\expandafter\endmatrix\expandafter{%
13922 \expandafter\unexpanded\expandafter{\endmatrix}}%
13923 \global\long\edef\eql@tmp{\eql@tmp}%
13924 \endgroup
13925 \eql@letcs{end#1}\eql@tmp
13926 }
13927 % \end{macrocode}
13928 %
13929 % \macro{\eql@amsmath@fixends}
13930 % Perform the replacement for all \amsmath/ environments
13931 % whenever \amsmath/ is loaded:
13932 % \begin{macrocode}
13933 \def\eql@amsmath@fixends{%
13934 \eql@amsmath@after{%
13935 \eql@amsmath@endfix{flalign}{align}%
13936 \eql@amsmath@endfix{alignat}{align}%
13937 \eql@amsmath@endfix{xalignat}{align}%
13938 \eql@amsmath@endfix{xxalignat}{align}%
13939 \eql@amsmath@endfix{gather*}{gather}%
13940 \eql@amsmath@endfix{multline*}{multline}%
13941 \eql@amsmath@endfix{align*}{align}%
13942 \eql@amsmath@endfix{flalign*}{align}%
13943 \eql@amsmath@endfix{alignat*}{align}%
13944 \eql@amsmath@endfix{xalignat*}{align}%
13945 \eql@amsmath@endfix{gathered}{aligned}%
13946 \eql@amsmath@endfix{alignedat}{aligned}%
13947 }
13948 }
13949 % \end{macrocode}
13950 %
13951 % \macro{\eql@amsmath@fixmatrices}
13952 % Perform the replacement for all \amsmath/ environments
13953 % whenever \amsmath/ is loaded:
13954 % \begin{macrocode}
13955 \def\eql@amsmath@fixmatrices{%
13956 \eql@amsmath@after{%
13957 \eql@amsmath@fixmatrix{cases}%
13958 \eql@amsmath@fixmatrix{matrix}%
13959 \eql@amsmath@fixmatrix{pmatrix}%
13960 \eql@amsmath@fixmatrixend{pmatrix}%
13961 \eql@amsmath@fixmatrixend{bmatrix}%
13962 \eql@amsmath@fixmatrixend{Bmatrix}%
13963 \eql@amsmath@fixmatrixend{vmatrix}%
13964 \eql@amsmath@fixmatrixend{Vmatrix}%
13965 }
13966 }
13967 % \end{macrocode}
13968 %
13969 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13970 % \paragraph{Backup amsmath Environments.}
13971 %
13972 % We can backup all \amsmath/ environments \textit{env} to |ams|\textit{env}
13973 % so that they can be used in parallel if needed.
13974 %
13975 % \macro{\eql@provide@backup@amsenv}
13976 % Copy an \amsmath/ environment \textit{env} to |ams|\textit{env}
13977 % whenever \amsmath/ is loaded:
13978 % \TODO describe
13979 % \begin{macrocode}
13980 \def\eql@provide@backup@amsenv#1{%
13981 \eql@amsmath@after{%
13982 \eql@provide@moveenv{ams#1}{#1}%
13983 \eql@tagging@register@luamml{ams#1}%
13984 \eql@markline@amsthm@move{ams#1}{#1}%
13985 }%
13986 }
13987 % \end{macrocode}
13988 %
13989 % \macro{\eql@provide@backup@amsbox}
13990 % \TODO describe
13991 % \begin{macrocode}
13992 \def\eql@provide@backup@amsbox#1{%
13993 \eql@amsmath@after{%
13994 \eql@provide@moveenv{ams#1}{#1}%
13995 }%
13996 }
13997 % \end{macrocode}
13998 %
13999 % \macro{\eql@provide@backup@eqref}
14000 % Copy an |eqref| to |amseqref| whenever \amsmath/ is loaded:
14001 % \begin{macrocode}
14002 \def\eql@provide@backup@eqref{%
14003 \eql@amsmath@after{%
14004 \eql@provide@movecmd{amseqref}{eqref}%
14005 }%
14006 }
14007 % \end{macrocode}
14008 %
14009 % \macro{\eql@provide@backup@multlined}
14010 % The environment |multlined| is supplied by \ctanpkg{mathtools}.
14011 % We copy it to |amsmultlined| anyway,
14012 % but whenever \ctanpkg{mathtools} is loaded:
14013 % \begin{macrocode}
14014 \def\eql@provide@backup@multlined{%
14015 \AddToHook{package/mathtools/after}{%
14016 \eql@provide@moveenv{amsmultlined}{multlined}}%
14017 }
14018 % \end{macrocode}
14019 %
14020 % \macro{\eql@provide@backup@equation}
14021 % The \latex/ environment |equation| is overwritten by several packages
14022 % to implement their adjustments.
14023 % Here we cater for adjustments through \amsmath/, \ctanpkg{hyperref}
14024 % and the PDF tagging mechanism.
14025 % Copy |equation| and |equation*| whenever \amsmath/ is loaded.
14026 % Whenever \ctanpkg{hyperref} is loaded,
14027 % and \amsmath/ is not yet present,
14028 % backup the original \latex/ and \ctanpkg{hyperref} versions of |equation|.
14029 % If neither \ctanpkg{hyperref} nor \amsmath/ are present,
14030 % just backup the original \latex/ |equation|.
14031 % The PDF tagging mechanism registers |equation| upon |\begin{document}|.
14032 % We thus need to register all copies of |equation| on our own,
14033 % so that they can be used with their new names:
14034 % \begin{macrocode}
14035 \def\eql@provide@backup@equation{%
14036 \eql@amsmath@after{%
14037 \eql@provide@moveenv{amsequation}{equation}%
14038 \eql@provide@moveenv{amsequation*}{equation*}%
14039 \eql@tagging@register@env{amsequation}%
14040 \eql@tagging@register@env{amsequation*}%
14041 \eql@tagging@register@luamml{amsequation}%
14042 \eql@tagging@register@luamml{amsequation*}%
14043 \eql@markline@amsthm@move{amsequation}{equation}%
14044 \eql@markline@amsthm@move{amsequation*}{equation*}%
14045 }%
14046 \AddToHook{package/hyperref/after}{%
14047 \@ifpackageloaded{amsmath}{}{%
14048 \eql@provide@moveenv{hyperrefequation}{equation}%
14049 \eql@tagging@register@env{hyperrefequation}%
14050 \eql@tagging@register@luamml{hyperrefequation}%
14051 \eql@markline@amsthm@move{hyperequation}{equation}%
14052 }%
14053 }%
14054 \@ifpackageloaded{amsmath}{}{%
14055 \@ifpackageloaded{hyperref}{%
14056 \let\latexequation\H@equation
14057 \let\endlatexequation\H@endequation
14058 }{\eql@provide@moveenv{latexequation}{equation}}%
14059 \eql@tagging@register@env{latexequation}%
14060 \eql@tagging@register@luamml{latexequation}%
14061 \eql@markline@amsthm@move{latexequation}{equation}%
14062 }%
14063 }
14064 % \end{macrocode}
14065 %
14066 % \macro{\eql@provide@backup@displaymath}
14067 % \TODO describe
14068 % \begin{macrocode}
14069 \def\eql@provide@backup@displaymath{%
14070 \eql@provide@moveenv{latexdisplaymath}{displaymath}%
14071 \eql@markline@amsthm@move{latexdisplaymath}{displaymath}%
14072 }
14073 % \end{macrocode}
14074 %
14075 % \macro{\eql@provide@backup@subequations}
14076 % The \amsmath/ |subequations| environment is adjusted by
14077 % \ctanpkg{hyperref} through an environment hook,
14078 % but this hook gets applied only later at |\begin{document}|.
14079 % Hence, we need to supply the hook routine to the new routine ourselves:
14080 % \begin{macrocode}
14081 \def\eql@provide@backup@subequations{%
14082 \eql@amsmath@after{%
14083 \eql@provide@moveenv{amssubequations}{subequations}%
14084 }%
14085 \AddToHook{package/hyperref/after}{%
14086 \AddToHook{cmd/amssubequations/before}%
14087 {%
14088 \stepcounter{equation}%
14089 \protected@edef\theHparentequation{\theHequation}%
14090 \addtocounter{equation}{-1}%
14091 }%
14092 \AddToHook{cmd/amssubequations/after}%
14093 {%
14094 \def\theHequation{\theHparentequation\alph{equation}}%
14095 \ignorespaces
14096 }%
14097 }%
14098 }
14099 % \end{macrocode}
14100 %
14101 % \macro{\eql@provide@backup}
14102 % Backup all \amsmath/ environments:
14103 % \begin{macrocode}
14104 \def\eql@provide@backup{%
14105 \eql@provide@backup@eqref
14106 \eql@provide@backup@equation
14107 \eql@provide@backup@displaymath
14108 \eql@provide@backup@amsenv{gather}%
14109 \eql@provide@backup@amsenv{multline}%
14110 \eql@provide@backup@amsenv{align}%
14111 \eql@provide@backup@amsenv{flalign}%
14112 \eql@provide@backup@amsenv{alignat}%
14113 \eql@provide@backup@amsenv{xalignat}%
14114 \eql@provide@backup@amsenv{xxalignat}%
14115 \eql@provide@backup@amsenv{gather*}%
14116 \eql@provide@backup@amsenv{multline*}%
14117 \eql@provide@backup@amsenv{align*}%
14118 \eql@provide@backup@amsenv{flalign*}%
14119 \eql@provide@backup@amsenv{alignat*}%
14120 \eql@provide@backup@amsenv{xalignat*}%
14121 \eql@provide@backup@amsbox{gathered}%
14122 \eql@provide@backup@multlined
14123 \eql@provide@backup@amsbox{aligned}%
14124 \eql@provide@backup@amsbox{alignedat}%
14125 \eql@provide@backup@amsbox{cases}%
14126 \eql@provide@backup@amsbox{matrix}%
14127 \eql@provide@backup@amsbox{pmatrix}%
14128 \eql@provide@backup@amsbox{bmatrix}%
14129 \eql@provide@backup@amsbox{Bmatrix}%
14130 \eql@provide@backup@amsbox{vmatrix}%
14131 \eql@provide@backup@amsbox{Vmatrix}%
14132 \eql@provide@backup@subequations
14133 }
14134 % \end{macrocode}
14135 %
14136 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14137 % \paragraph{Replacement amsmath Environments.}
14138 %
14139 % \TODO describe
14140 % \begin{macrocode}
14141 \def\eql@alignat@gobblecol#1{%
14142 \eql@ifnextchar@tight\bgroup{\@firstoftwo{#1}}{#1}}
14143 % \end{macrocode}
14144 %
14145 % \environment{eql@gathered}
14146 % \environment{eql@multlined}
14147 % \environment{eql@aligned}
14148 % Define replacement versions for boxed environments
14149 % |gathered|, |multlined| and |aligned|
14150 % which forward to |equationsbox|
14151 % with specific presets:
14152 % \begin{macrocode}
14153 \newenvironment{eql@gathered}%
14154 {\eqnaddopt{lines}\equationsbox}{\endequationsbox}
14155 \newenvironment{eql@multlined}%
14156 {\eqnaddopt{lines,padding,shape=steps}\equationsbox}{\endequationsbox}
14157 \newenvironment{eql@aligned}%
14158 {\eqnaddopt{columns}\equationsbox}{\endequationsbox}
14159 \newenvironment{eql@alignedat}%
14160 {\eqnaddopt{columns,colsep=off}\eql@alignat@gobblecol\equationsbox}%
14161 {\endequationsbox}
14162 \newenvironment{eql@cases}%
14163 {\eqnaddopt{cases}\equationsbox}{\endequationsbox}
14164 \newenvironment{eql@matrix}%
14165 {\eqnlinesset{modifierboxenv=false}\eqnaddopt{matrix=.}\equationsbox}%
14166 {\endequationsbox}
14167 \newenvironment{eql@pmatrix}%
14168 {\eqnlinesset{modifierboxenv=false}\eqnaddopt{matrix=r}\equationsbox}%
14169 {\endequationsbox}
14170 \newenvironment{eql@bmatrix}%
14171 {\eqnlinesset{modifierboxenv=false}\eqnaddopt{matrix=s}\equationsbox}%
14172 {\endequationsbox}
14173 \newenvironment{eql@Bmatrix}%
14174 {\eqnlinesset{modifierboxenv=false}\eqnaddopt{matrix=c}\equationsbox}%
14175 {\endequationsbox}
14176 \newenvironment{eql@vmatrix}%
14177 {\eqnlinesset{modifierboxenv=false}\eqnaddopt{matrix=v}\equationsbox}%
14178 {\endequationsbox}
14179 \newenvironment{eql@Vmatrix}%
14180 {\eqnlinesset{modifierboxenv=false}\eqnaddopt{matrix=d}\equationsbox}%
14181 {\endequationsbox}
14182 % \end{macrocode}
14183 %
14184 % \environment{eql@equation}
14185 % \environment{eql@gather}
14186 % \environment{eql@multline}
14187 % \environment{eql@align}
14188 % Define replacement versions for display environments
14189 % |equation|, |gather|, |multline|, |aligned| and derivatives
14190 % which forward to |equations| with specific presets:
14191 % \TODO amsmath at variants would need predefined columns for full operation
14192 % \begin{macrocode}
14193 \newenvironment{eql@equation}%
14194 {\eqnaddopt{equation,donumber}\equations}{\endequations}
14195 \newenvironment{eql@equation*}%
14196 {\eqnaddopt{equation,nonumber}\equations}{\endequations}
14197 \newenvironment{eql@displaymath}%
14198 {\eqnaddopt{equation,nonumber}\equations}{\endequations}
14199 \newenvironment{eql@gather}%
14200 {\eqnaddopt{lines,donumber}\equations}{\endequations}
14201 \newenvironment{eql@gather*}%
14202 {\eqnaddopt{lines,nonumber}\equations}{\endequations}
14203 \newenvironment{eql@multline}%
14204 {\eqnaddopt{lines,padding=max,shape=steps,numberline=out,donumber}%
14205 \equations}{\endequations}
14206 \newenvironment{eql@multline*}%
14207 {\eqnaddopt{lines,padding=max,shape=steps,numberline=out,nonumber}%
14208 \equations}{\endequations}
14209 \newenvironment{eql@align}%
14210 {\eqnaddopt{columns,donumber}\equations}{\endequations}
14211 \newenvironment{eql@align*}%
14212 {\eqnaddopt{columns,nonumber}\equations}{\endequations}
14213 \newenvironment{eql@flalign}%
14214 {\eqnaddopt{columns,fulllength,donumber}\equations}{\endequations}
14215 \newenvironment{eql@flalign*}%
14216 {\eqnaddopt{columns,fulllength,nonumber}\equations}{\endequations}
14217 \newenvironment{eql@alignat}%
14218 {\eqnaddopt{columns,colsep=off,donumber}%
14219 \eql@alignat@gobblecol\equations}{\endequations}
14220 \newenvironment{eql@xalignat}%
14221 {\eqnaddopt{columns,donumber}%
14222 \eql@alignat@gobblecol\equations}{\endequations}
14223 \newenvironment{eql@xxalignat}%
14224 {\eqnaddopt{columns,fulllength,donumber}%
14225 \eql@alignat@gobblecol\equations}{\endequations}
14226 \newenvironment{eql@alignat*}%
14227 {\eqnaddopt{columns,colsep=off,nonumber}%
14228 \eql@alignat@gobblecol\equations}{\endequations}
14229 \newenvironment{eql@xalignat*}%
14230 {\eqnaddopt{columns,nonumber}%
14231 \eql@alignat@gobblecol\equations}{\endequations}
14232 % \end{macrocode}
14233 %
14234 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14235 % \paragraph{Install Additional Environments.}
14236 %
14237 % The additional environments need to be installed
14238 % at their intended names which can be adjusted by the user.
14239 %
14240 % \macro{\eql@provide@onlyonce}
14241 % Process arguments for providing a specific environment.
14242 % |#1| describes the environment using the \amsmath/ name.
14243 % |#2| specifies the desired target name.
14244 % If |#2| is empty or equals |#1|,
14245 % overwrite the \amsmath/ environment in place
14246 % making sure that the replacement is robust against
14247 % loading \amsmath/ before or after.
14248 % If |#2| equals `|*|', just overwrite the \amsmath/ environment
14249 % in place immediately (e.g.\ within a block in the document body):
14250 % \begin{macrocode}
14251 \def\eql@provide@onlyonce#1#2{%
14252 \def\eql@tmp{#2}\def\eql@tmpa{#1}%
14253 \ifx\eql@tmp\eql@tmpa
14254 \let\eql@tmp\@empty
14255 \fi
14256 \ifx\eql@tmp\@empty
14257 \let\eql@tmp\@undefined
14258 \ifx\@nodocument\relax
14259 \def\eql@tmp{#1}%
14260 \fi
14261 \ifcsname eql@provided@#1\endcsname
14262 \def\eql@tmp{#1}%
14263 \fi
14264 \eql@letcs{eql@provided@#1}\eql@true
14265 \else
14266 \def\eql@tmpa{*}%
14267 \ifx\eql@tmp\eql@tmpa
14268 \def\eql@tmp{#1}%
14269 \fi
14270 \fi
14271 }
14272 % \end{macrocode}
14273 %
14274 % \macro{\eql@provide@eqref}
14275 % Provide |\eqref| as the macro |#1|.
14276 % We have to check whether |#1| is empty or equals |\eqref|
14277 % or takes the value `|*|'. If not, we should strip the backslash
14278 % for further processing.
14279 % Copy the macro into place, and copy again
14280 % when \amsmath/ or \ctanpkg{mathtools} are loaded.
14281 % Remove definition before \amsmath/ is loaded in the future
14282 % to avoid a potential error:
14283 % \begin{macrocode}
14284 \def\eql@provide@eqref#1{%
14285 \def\eql@tmp{#1}\def\eql@tmpa{\eqref}%
14286 \ifx\eql@tmp\eql@tmpa
14287 \let\eql@tmp\@empty
14288 \fi
14289 \ifx\eql@tmp\@empty
14290 \eql@provide@onlyonce{eqref}{}%
14291 \else
14292 \def\eql@tmpa{*}%
14293 \ifx\eql@tmp\eql@tmpa
14294 \def\eql@tmp{eqref}%
14295 \else
14296 \edef\eql@tmp{\expandafter\@gobble\string#1}%
14297 \fi
14298 \fi
14299 \ifdefined\eql@tmp
14300 \expandafter\eql@provide@movecmd\expandafter{\eql@tmp}{eql@eqref}%
14301 \else
14302 \eql@amsmath@after{%
14303 \eql@provide@movecmd{eqref}{eql@eqref}%
14304 }%
14305 \AddToHook{package/mathtools/after}{%
14306 \eql@provide@movecmd{eqref}{eql@eqref}%
14307 }%
14308 \eql@provide@movecmd{eqref}{eql@eqref}%
14309 \eql@amsmath@undefine\eqref
14310 \fi
14311 }
14312 % \end{macrocode}
14313 %
14314 % \macro{\eql@provide@amsenv}
14315 % Provide one of the \amsmath/ environments.
14316 % Copy into place, and copy again when \amsmath/ is loaded.
14317 % Remove definition before \amsmath/ is loaded in the future
14318 % to avoid an error:
14319 % \begin{macrocode}
14320 \def\eql@provide@amsenv#1#2{%
14321 \eql@provide@onlyonce{#1}{#2}%
14322 \ifdefined\eql@tmp
14323 \eql@provide@moveenv{\eql@tmp}{eql@#1}%
14324 \eql@tagging@register@luamml{\eql@tmp}%
14325 \eql@markline@amsthm@register{\eql@tmp}%
14326 \else
14327 \eql@amsmath@after{%
14328 \eql@provide@moveenv{#1}{eql@#1}%
14329 \eql@markline@amsthm@register{#1}%
14330 }%
14331 \AddToHook{package/mathtools/after}{%
14332 \eql@provide@moveenv{#1}{eql@#1}%
14333 \eql@markline@amsthm@register{#1}%
14334 }%
14335 \eql@provide@moveenv{#1}{eql@#1}%
14336 \eql@markline@amsthm@register{#1}%
14337 \eql@amsmath@before{\eql@provide@undefineenv{#1}}%
14338 \fi
14339 }
14340 % \end{macrocode}
14341 %
14342 % \macro{\eql@provide@amsbox}
14343 % Provide one of the \amsmath/ subequation structures.
14344 % Copy into place, and copy again when \amsmath/ is loaded.
14345 % Remove definition before \amsmath/ is loaded in the future
14346 % to avoid an error:
14347 % \begin{macrocode}
14348 \def\eql@provide@amsbox#1#2{%
14349 \eql@provide@onlyonce{#1}{#2}%
14350 \ifdefined\eql@tmp
14351 \eql@provide@moveenv{\eql@tmp}{eql@#1}%
14352 \else
14353 \eql@amsmath@after{%
14354 \eql@provide@moveenv{#1}{eql@#1}}%
14355 \AddToHook{package/mathtools/after}{%
14356 \eql@provide@moveenv{#1}{eql@#1}}%
14357 \eql@provide@moveenv{#1}{eql@#1}%
14358 \eql@amsmath@before{\eql@provide@undefineenv{#1}}%
14359 \fi
14360 }
14361 % \end{macrocode}
14362 %
14363 % \macro{\eql@provide@multlined}
14364 % Provide \ctanpkg{mathtools} environment |multlined|.
14365 % Copy into place, and copy again when \ctanpkg{mathtools} is loaded.
14366 % Remove definition before \ctanpkg{mathtools} is loaded in the future
14367 % to avoid an error:
14368 % \begin{macrocode}
14369 \def\eql@provide@multlined#1{%
14370 \eql@provide@onlyonce{multlined}{#1}%
14371 \ifdefined\eql@tmp
14372 \eql@provide@moveenv{\eql@tmp}{eql@multlined}%
14373 \else
14374 \AddToHook{package/mathtools/after}{%
14375 \eql@provide@moveenv{multlined}{eql@multlined}}%
14376 \eql@provide@moveenv{multlined}{eql@multlined}%
14377 \@ifpackageloaded{mathtools}{}{\AddToHook{package/mathtools/before}{%
14378 \eql@provide@undefineenv{multlined}}}%
14379 \fi
14380 }
14381 % \end{macrocode}
14382 %
14383 % \macro{\eql@provide@matrix}
14384 % Provide the |cases| and |matrix| environments.
14385 % Copy into place, and copy again when \amsmath/ is loaded:
14386 % \begin{macrocode}
14387 \def\eql@provide@matrix#1#2#3{%
14388 \eql@provide@onlyonce{#1}{#3}%
14389 \ifdefined\eql@tmp
14390 \eql@provide@moveenv{\eql@tmp}{eql@#1}%
14391 \eql@tagging@register@luamml{\eql@tmp}%
14392 \else
14393 \eql@amsmath@after{%
14394 \eql@provide@moveenv{#1}{eql@#1}%
14395 }%
14396 \eql@provide@moveenv{#1}{eql@#1}%
14397 \ifdefined#2\eql@amsmath@before{\eql@provide@undefineenv{#1}}\fi%
14398 \fi
14399 }
14400 % \end{macrocode}
14401 %
14402 % \macro{\eql@provide@equation}
14403 % Provide the environment |equation|.
14404 % Copy into place, and copy again
14405 % when \amsmath/ or \ctanpkg{hyperref} are loaded.
14406 % When PDF tagging is active, the environment is modified
14407 % at |\begin{document}| in an undesirable fashion,
14408 % so copy the definition again:
14409 % \begin{macrocode}
14410 \def\eql@provide@equation#1{%
14411 \eql@provide@onlyonce{equation}{#1}%
14412 \ifdefined\eql@tmp
14413 \eql@provide@moveenv{\eql@tmp}{eql@equation}%
14414 \eql@tagging@register@luamml{\eql@tmp}%
14415 \eql@markline@amsthm@register{\eql@tmp}%
14416 \else
14417 \eql@amsmath@after{%
14418 \eql@provide@moveenv{equation}{eql@equation}%
14419 \eql@markline@amsthm@register{equation}%
14420 }%
14421 \AddToHook{package/hyperref/after}{%
14422 \@ifpackageloaded{amsmath}{}{%
14423 \eql@provide@moveenv{equation}{eql@equation}%
14424 \eql@markline@amsthm@register{equation}%
14425 }%
14426 }%
14427 \eql@provide@moveenv{equation}{eql@equation}%
14428 \eql@markline@amsthm@register{equation}%
14429 \ifdefined\eql@tagging@on
14430 \AddToHook{begindocument/end}{%
14431 \eql@provide@moveenv{equation}{eql@equation}%
14432 \eql@markline@amsthm@register{equation}%
14433 }%
14434 \fi
14435 \fi
14436 }
14437 % \end{macrocode}
14438 %
14439 % \macro{\eql@provide@equationstar}
14440 % Provide the environment |equation*|.
14441 % Copy into place, and copy again
14442 % when \amsmath/ or \ctanpkg{hyperref} are loaded.
14443 % Remove definition of |equation*|
14444 % before \ctanpkg{amsmath} is loaded in the future to avoid an error.
14445 % When PDF tagging is active, the environment is modified
14446 % at |\begin{document}| in an undesirable fashion,
14447 % so copy the definition again:
14448 % \begin{macrocode}
14449 \def\eql@provide@equationstar#1{%
14450 \eql@provide@onlyonce{equation*}{#1}%
14451 \ifdefined\eql@tmp
14452 \eql@provide@moveenv{\eql@tmp}{eql@equation*}%
14453 \eql@tagging@register@luamml{\eql@tmp}%
14454 \eql@markline@amsthm@register{\eql@tmp}%
14455 \else
14456 \eql@amsmath@after{%
14457 \eql@provide@moveenv{equation*}{eql@equation*}%
14458 \eql@markline@amsthm@register{equation*}%
14459 }%
14460 \eql@provide@moveenv{equation*}{eql@equation*}%
14461 \eql@markline@amsthm@register{equation*}%
14462 \eql@amsmath@before{\eql@provide@undefineenv{equation*}}%
14463 \ifdefined\eql@tagging@on
14464 \AddToHook{begindocument/end}{%
14465 \eql@provide@moveenv{equation*}{eql@equation*}%
14466 \eql@markline@amsthm@register{equation*}%
14467 }%
14468 \fi
14469 \fi
14470 }
14471 % \end{macrocode}
14472 %
14473 % \macro{\eql@provide@displaymath}
14474 % \TODO describe
14475 % \begin{macrocode}
14476 \def\eql@provide@displaymath#1{%
14477 \eql@provide@onlyonce{displaymath}{#1}%
14478 \ifdefined\eql@tmp
14479 \eql@provide@moveenv{\eql@tmp}{eql@displaymath}%
14480 \eql@markline@amsthm@register{\eql@tmp}%
14481 \eql@tagging@register@luamml{\eql@tmp}%
14482 \else
14483 \eql@provide@moveenv{displaymath}{eql@displaymath}%
14484 \eql@markline@amsthm@register{displaymath}%
14485 \ifdefined\eql@tagging@on
14486 \AddToHook{begindocument/end}{%
14487 \eql@provide@moveenv{displaymath}{eql@displaymath}}%
14488 \fi
14489 \fi
14490 }
14491 % \end{macrocode}
14492 %
14493 % \macro{\eql@provide@subequations}
14494 % Provide the \amsmath/ environment |subequations|.
14495 % Copy into place, and copy again
14496 % when \amsmath/ is loaded.
14497 % \ctanpkg{hyperref} adds a hook to the command
14498 % which messes up the parsing of optional arguments
14499 % (even if the hook is emptied).
14500 % The hook placement happens at |\begin{document}|,
14501 % so we copy the environment again afterwards.
14502 % We also remove the hook (after adding an empty hook to avoid errors).
14503 % Remove definition before \amsmath/ is loaded in the future
14504 % to avoid an error:
14505 % \begin{macrocode}
14506 \def\eql@provide@subequations#1{%
14507 \eql@provide@onlyonce{subequations}{#1}%
14508 \ifdefined\eql@tmp
14509 \eql@provide@moveenv{\eql@tmp}{eql@subequations}%
14510 \else
14511 \eql@amsmath@after{%
14512 \eql@provide@moveenv{subequations}{eql@subequations}%
14513 }%
14514 \AddToHook{package/hyperref/after}{%
14515 \AddToHook{cmd/subequations/before}[hyperref]{}%
14516 \AddToHook{cmd/subequations/after}[hyperref]{}%
14517 \RemoveFromHook{cmd/subequations/before}[hyperref]%
14518 \RemoveFromHook{cmd/subequations/after}[hyperref]%
14519 \AddToHook{begindocument/end}{%
14520 \eql@provide@moveenv{subequations}{eql@subequations}}%
14521 }%
14522 \eql@provide@moveenv{subequations}{eql@subequations}%
14523 \eql@amsmath@before{\eql@provide@undefineenv{subequations}}%
14524 \fi
14525 }
14526 % \end{macrocode}
14527 %
14528 % \macro{\eql@provide@sqr}
14529 % Provide the symbolic environment |\[|\,\ldots|\]|.
14530 % Copy into place, and copy again when \amsmath/ is loaded.
14531 % If PDF tagging is active, some undesired modifications
14532 % happen at |\begin{document}|, so copy again afterwards:
14533 % \begin{macrocode}
14534 \def\eql@provide@sqr{%
14535 \let\[\eql@sqr@open
14536 \let\]\eql@sqr@close
14537 \eql@amsmath@after{%
14538 \let\[\eql@sqr@open
14539 \let\]\eql@sqr@close
14540 }%
14541 \ifdefined\eql@tagging@on
14542 \AddToHook{begindocument/end}{%
14543 \let\[\eql@sqr@open
14544 \let\]\eql@sqr@close
14545 }%
14546 \fi
14547 }
14548 % \end{macrocode}
14549 %
14550 % \macro{\eql@provide@ang}
14551 % Provide the symbolic environment |\<|\,\ldots|\>|.
14552 % This is easy because none of the other packages uses this structure:
14553 % \begin{macrocode}
14554 \def\eql@provide@ang{%
14555 \let\<\eql@ang@open
14556 \let\>\eql@ang@close
14557 }
14558 % \end{macrocode}
14559 %
14560 % \TODO describe
14561 % \begin{macrocode}
14562 \def\eql@provide@tagform{%
14563 \def\tagform@##1{\maketag@@@{\eql@tags@tagform{##1}}}}
14564 \def\eql@provide@maketag{%
14565 \def\maketag@@@##1{\eql@tags@taglayout{##1}}}
14566 % \end{macrocode}
14567 %
14568 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14569 % \paragraph{Interface.}
14570 %
14571 % \key{provide}
14572 % We provide the additional environments via key-value pairs,
14573 % where the value specifies the intended name:
14574 % \begin{macrocode}
14575 \eql@define@key{provide}{equation}[]{\eql@provide@equation{#1}}
14576 \eql@define@key{provide}{equation*}[]{\eql@provide@equationstar{#1}}
14577 \eql@define@key{provide}{displaymath}[]{\eql@provide@displaymath{#1}}
14578 \eql@define@key{provide}{gather}[]{\eql@provide@amsenv{gather}{#1}}
14579 \eql@define@key{provide}{multline}[]{\eql@provide@amsenv{multline}{#1}}
14580 \eql@define@key{provide}{align}[]{\eql@provide@amsenv{align}{#1}}
14581 \eql@define@key{provide}{flalign}[]{\eql@provide@amsenv{flalign}{#1}}
14582 \eql@define@key{provide}{alignat}[]{\eql@provide@amsenv{alignat}{#1}}
14583 \eql@define@key{provide}{xalignat}[]{\eql@provide@amsenv{xalignat}{#1}}
14584 \eql@define@key{provide}{xxalignat}[]{\eql@provide@amsenv{xxalignat}{#1}}
14585 \eql@define@key{provide}{gather*}[]{\eql@provide@amsenv{gather*}{#1}}
14586 \eql@define@key{provide}{multline*}[]{\eql@provide@amsenv{multline*}{#1}}
14587 \eql@define@key{provide}{align*}[]{\eql@provide@amsenv{align*}{#1}}
14588 \eql@define@key{provide}{flalign*}[]{\eql@provide@amsenv{flalign*}{#1}}
14589 \eql@define@key{provide}{alignat*}[]{\eql@provide@amsenv{alignat*}{#1}}
14590 \eql@define@key{provide}{xalignat*}[]{\eql@provide@amsenv{xalignat*}{#1}}
14591 \eql@define@key{provide}{gathered}[]{\eql@provide@amsbox{gathered}{#1}}
14592 \eql@define@key{provide}{multlined}[]{\eql@provide@multlined{#1}}
14593 \eql@define@key{provide}{aligned}[]{\eql@provide@amsbox{aligned}{#1}}
14594 \eql@define@key{provide}{alignedat}[]{\eql@provide@amsbox{alignedat}{#1}}
14595 \eql@define@key{provide}{cases}[]{\eql@provide@matrix{cases}\eql@false{#1}}
14596 \eql@define@key{provide}{matrix}[]{\eql@provide@matrix{matrix}\eql@false{#1}}
14597 \eql@define@key{provide}{pmatrix}[]{\eql@provide@matrix{pmatrix}\eql@false{#1}}
14598 \eql@define@key{provide}{bmatrix}[]{\eql@provide@matrix{bmatrix}\eql@true{#1}}
14599 \eql@define@key{provide}{Bmatrix}[]{\eql@provide@matrix{Bmatrix}\eql@true{#1}}
14600 \eql@define@key{provide}{vmatrix}[]{\eql@provide@matrix{vmatrix}\eql@true{#1}}
14601 \eql@define@key{provide}{Vmatrix}[]{\eql@provide@matrix{Vmatrix}\eql@true{#1}}
14602 \eql@define@key{provide}{subequations}[]{\eql@provide@subequations{#1}}
14603 \eql@define@key{provide}{sqr}[]{\eql@provide@sqr}
14604 \eql@define@key{provide}{ang}[]{\eql@provide@ang}
14605 \eql@define@key{provide}{eqref}[]{\eql@provide@eqref{#1}}
14606 \eql@define@key{provide}{tagform}[]{\eql@provide@tagform}
14607 \eql@define@key{provide}{maketag}[]{\eql@provide@maketag}
14608 % \end{macrocode}
14609 %
14610 % \imacro{\eqnlinesprovide}
14611 % Provide an additional environment or macro via key-value interface:
14612 % \begin{macrocode}
14613 \newcommand{\eqnlinesprovide}[1]{%
14614 \eql@setkeys{provide}{#1}%
14615 \ignorespaces
14616 }
14617 % \end{macrocode}
14618 %
14619 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14620 % \subsection{Global and Package Options}
14621 %
14622 % Handle global and package options:
14623 %
14624 % Disable error message for exclusive package options:
14625 % \begin{macrocode}
14626 \let\eql@error@packageoption\@gobble
14627 % \end{macrocode}
14628 %
14629 % Declare math layout options |leqno| and |fleqn| for common \latex/ classes:
14630 % \begin{macrocode}
14631 \DeclareOption{leqno}{\eqnlinesset{tagsleft}}
14632 \DeclareOption{fleqn}{\eqnlinesset{left}}
14633 % \end{macrocode}
14634 %
14635 % Pass undeclared options on to \ctanpkg{keyval} processing:
14636 % \begin{macrocode}
14637 \DeclareOption*{\expandafter\eqnlinesset\expandafter{\CurrentOption}}
14638 % \end{macrocode}
14639 %
14640 % Set defaults for package:
14641 % \begin{macrocode}
14642 \eql@defaults@eqnlines
14643 \eql@equations@columns@set
14644 \eql@box@columns@set
14645 % \end{macrocode}
14646 %
14647 % Make sure that the \amsmath/ conditionals
14648 % |\iftagsleft@| and |\if@fleqn| are declared
14649 % without spelling out their name
14650 % which may upset the \tex/ conditional parsing mechanism:
14651 % \begin{macrocode}
14652 \ifdefined\tagsleft@true\else
14653 \expandafter\newif\csname iftagsleft@\endcsname
14654 \fi
14655 \ifdefined\@fleqntrue\else
14656 \expandafter\newif\csname if@fleqn\endcsname
14657 \fi
14658 % \end{macrocode}
14659 %
14660 % Import \amsmath/ switches |leqno| as |tagsleft|
14661 % and |fleqn| as |left|:
14662 % \begin{macrocode}
14663 \eql@amsmath@after{%
14664 \ifnum\eql@provide@opt@env=\tw@
14665 \iftagsleft@
14666 \eqnlinesset{tags=left}%
14667 \else
14668 \eqnlinesset{tags=right}%
14669 \fi
14670 \if@fleqn
14671 \eqnlinesset{layout=left}%
14672 \else
14673 \eqnlinesset{layout=center}%
14674 \fi
14675 \fi
14676 }
14677 % \end{macrocode}
14678 %
14679 % Process package options:
14680 % \begin{macrocode}
14681 \ProcessOptions
14682 % \end{macrocode}
14683 %
14684 % \macro{\eql@error@packageoption}
14685 % Enable error message for exclusive package options:
14686 % \begin{macrocode}
14687 \def\eql@error@packageoption#1{%
14688 \eql@error{may only use '#1' as a package option}%
14689 }
14690 % \end{macrocode}
14691 %
14692 % Make the ending statements for \amsmath/ environments independent
14693 % if desired, so that they may be overwritten individually:
14694 % \begin{macrocode}
14695 \ifnum\eql@provide@opt@env=\tw@
14696 \ifdefined\eql@provide@opt@matrix
14697 \let\eql@provide@opt@amsmathpatch\eql@false
14698 \fi\fi
14699 \ifdefined\eql@provide@opt@backup
14700 \let\eql@provide@opt@amsmathpatch\eql@true
14701 \fi
14702 \ifdefined\eql@provide@opt@amsmathpatch
14703 \eql@amsmath@fixends
14704 \eql@amsmath@fixmatrices
14705 \fi
14706 % \end{macrocode}
14707 %
14708 % Backup all \amsmath/ environments that may be overwritten to |ams...|.
14709 % This will happen before any replacements:
14710 % \begin{macrocode}
14711 \ifdefined\eql@provide@opt@backup\eql@provide@backup\fi
14712 % \end{macrocode}
14713 %
14714 % Provide native \latex/ environment |equation|
14715 % and symbolic shortcut |\[|\,\ldots|\]| if desired:
14716 % \begin{macrocode}
14717 \ifnum\eql@provide@opt@env>\z@
14718 \eqnlinesprovide{equation,equation*,sqr,displaymath}
14719 \fi
14720 % \end{macrocode}
14721 %
14722 % Provide \amsmath/ equation environments if desired:
14723 % \begin{macrocode}
14724 \ifnum\eql@provide@opt@env=\tw@
14725 \eqnlinesprovide{%
14726 multline,gather,align,flalign,alignat,xalignat,xxalignat,%
14727 multline*,gather*,align*,flalign*,alignat*,xalignat*,%
14728 multlined,gathered,aligned,alignedat,%
14729 subequations}
14730 \fi
14731 % \end{macrocode}
14732 %
14733 % Provide symbolic shortcut |\<|\,\ldots|\>| if desired:
14734 % \begin{macrocode}
14735 \ifdefined\eql@provide@opt@ang\eqnlinesprovide{ang}\fi
14736 % \end{macrocode}
14737 %
14738 % Provide equation reference |\eqref| if desired:
14739 % \begin{macrocode}
14740 \ifdefined\eql@provide@opt@eqref\eqnlinesprovide{eqref}\fi
14741 % \end{macrocode}
14742 %
14743 % Provide |cases| and |matrix| environments if desired:
14744 % \begin{macrocode}
14745 \ifdefined\eql@provide@opt@matrix
14746 \eqnlinesprovide{cases,matrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix}
14747 \fi
14748 % \end{macrocode}
14749 %
14750 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14751 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14752 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14753 % \iffalse
14754 %</package>
14755 % \fi
14756 %
14757 \endinput