1 % \iffalse meta-comment
3 % Copyright (C) 1997-2003 by Michael J. Downes
4 % Copyright (C) 2007 by Morten Hoegholm <mh.ctan@gmail.com>
6 % This work may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either
8 % version 1.3 of this license or (at your option) any later
9 % version. The latest version of this license is in
10 % http://www.latex-project.org/lppl.txt
11 % and version 1.3 or later is part of all distributions of
12 % LaTeX version 2005/12/01 or later.
14 % This work has the LPPL maintenance status "maintained".
16 % This Current Maintainer of this work is Morten Hoegholm.
18 % This work consists of the main source file breqn.dtx
19 % and the derived files
20 % breqn.sty, breqn.pdf, breqn.ins, breqn.drv.
23 % CTAN:macros/latex/contrib/mh/breqn.dtx
24 % CTAN:macros/latex/contrib/mh/breqn.pdf
27 % (a) If breqn.ins is present:
29 % (b) Without breqn.ins:
31 % (c) If you insist on using LaTeX
32 % latex \let\install=y\input{breqn.dtx}
33 % (quote the arguments according to the demands of your shell)
36 % (a) If breqn.drv is present:
38 % (b) Without breqn.drv:
39 % latex breqn.dtx; ...
40 % The class ltxdoc loads the configuration file ltxdoc.cfg
41 % if available. Here you can specify further options, e.g.
42 % use A4 as paper format:
43 % \PassOptionsToClass{a4paper}{article}
45 % Programm calls to get the documentation (example):
47 % makeindex -s gind.ist breqn.idx
49 % makeindex -s gind.ist breqn.idx
53 % TDS:tex/latex/mh/breqn.sty
54 % TDS:doc/latex/mh/breqn.pdf
55 % TDS:source/latex/mh/breqn.dtx
61 \ifcase 0\ifx\install y1\fi\expandafter
62 \ifx\csname processbatchFile\endcsname\relax\else1\fi
63 \ifx\fmtname\x\else 1\fi\relax
64 \else\csname fi\endcsname
68 \Msg{************************************************************************}
70 \Msg{* Package: breqn 2007/12/22 v0.97a Breqn (MH)}
71 \Msg{************************************************************************}
78 This is a generated file.
80 Copyright (C) 1997-2003 by Michael J. Downes
81 Copyright (C) 2007 by Morten Hoegholm <mh.ctan@gmail.com>
83 This work may be distributed and/or modified under the
84 conditions of the LaTeX Project Public License, either
85 version 1.3 of this license or (at your option) any later
86 version. The latest version of this license is in
87 http://www.latex-project.org/lppl.txt
88 and version 1.3 or later is part of all distributions of
89 LaTeX version 2005/12/01 or later.
91 This work has the LPPL maintenance status "maintained".
93 This Current Maintainer of this work is Morten Hoegholm.
95 This work consists of the main source file breqn.dtx
97 breqn.sty, breqn.pdf, breqn.ins, breqn.drv.
102 \file{breqn.ins}{\from{breqn.dtx}{install}}%
103 \file{breqn.drv}{\from{breqn.dtx}{driver}}%
104 \usedir{tex/latex/mh}%
105 \file{breqn.sty}{\from{breqn.dtx}{package}}%
109 \Msg{************************************************************************}
111 \Msg{* To finish the installation you have to move the following}
112 \Msg{* file into a directory searched by TeX:}
116 \Msg{* To produce the documentation run the file `breqn.drv'}
117 \Msg{* through LaTeX.}
119 \Msg{* Happy TeXing!}
121 \Msg{************************************************************************}
129 \NeedsTeXFormat{LaTeX2e}
130 \ProvidesFile{breqn.drv}%
131 [2007/12/22 v0.97a breqn (MH)]
132 \documentclass{ltxdoc}
135 \setcounter{IndexColumns}{2}
136 \usepackage{color,verbatim,xspace,varioref,listings,amsmath,trace}
138 \definecolor{hilite}{rgb}{0.2,0.4,0.7}
139 \def\theCodelineNo{\textcolor{hilite}{\sffamily\tiny\arabic{CodelineNo}}}
141 \lstloadlanguages{[AlLaTeX]TeX}
143 \lstnewenvironment{literalcode}
144 {\lstset{gobble=2,columns=fullflexible,basicstyle=\color{hilite}\ttfamily}}
149 \long\gdef\@gobble@percent@space#1{\ifx
150 #1%\expandafter\@gobble\else\expandafter#1\fi}}
153 \AtBeginDocument{\def\verbatim@processline{\expandafter\check@percent
154 \the\verbatim@line\par}}
157 \newenvironment{xio}{% example input and output
158 \par\addvspace\bigskipamount
160 \refstepcounter{xio}\kern-\p@ Example \thexio}\@nobreaktrue
161 \immediate\openout\tmp@out\jobname.tmp \relax
163 \let\do\@makeother\dospecials\catcode`\^^M\active
164 \def\verbatim@processline{
165 \immediate\write\tmp@out{\expandafter\@gobble@percent@space
166 \the\verbatim@line}}%
169 \immediate\closeout\tmp@out
170 \@verbatim\frenchspacing\@vobeyspaces
171 \@@input \jobname.tmp \relax
174 \noindent\ignorespaces
175 \@@input \jobname.tmp \relax
182 \providecommand*\pkg[1]{\textsf{#1}}
183 \providecommand*\cls[1]{\textsf{#1}}
184 \providecommand*\opt[1]{\texttt{#1}}
185 \providecommand*\env[1]{\texttt{#1}}
186 \providecommand*\fn[1]{\texttt{#1}}
189 \providecommand*\cn[1]{\cs{#1}}
190 \providecommand*\csarg[1]{\texttt{\char`\{#1\char`\}}}
192 \providecommand*\tex{\TeX\xspace}
193 \providecommand*\latex{\LaTeX\xspace}
194 \providecommand*\dbldollars{\texttt{\detokenize{$$}}}%$$
195 \providecommand*\arg{}
196 \edef\arg{\expandafter\@gobble\string\#}
198 \newenvironment{aside}{\begin{quote}\bfseries}{\end{quote}}
199 \newenvironment{dn}{\begin{quote}\bfseries}{\end{quote}}
201 \newcommand\dash{\textemdash}
202 \newcommand\dbslash[1]{\texttt{\string\\}}
203 \newcommand\thepkg{the \pkg{breqn} package\xspace}
205 \providecommand*\texbook{\textsl{The \protect\TeX{}book}\xspace}
207 \providecommand*\dotsc{\ldots}
208 \providecommand*\eqref[1]{(\ref{#1})}
210 \providecommand*\qq[1]{\textquotedblleft#1\textquotedblright}
211 \providecommand*\quoted[1]{\textquoteleft#1\textquoteright}
212 \providecommand*\dquoted[1]{\textquotedblleft#1\textquotedblright}
214 \providecommand*\ie{i.e.,\xspace}
215 \providecommand*\eg{e.g.,\xspace}
216 \providecommand*\etc{etc.\xspace}
217 \providecommand*\cf{cf.\xspace}
219 \providecommand*\ndash{\unskip\textendash\ignorespaces}
220 \providecommand*\mdash{\unskip\textemdash\ignorespaces}
232 % \title{The \pkg{breqn} package}
233 % \date{2007/12/22 v0.97a}
234 % \author{Morten H\o gholm \\\texttt{mh.ctan@gmail.com}}
238 % The \pkg{breqn} package facilitates automatic line-breaking of
239 % displayed math expressions.
242 % \part*{User's guide}
244 % \section{A bit of history}
246 % Originally \pkg{breqn}, \pkg{flexisym}, and \pkg{mathstyle} were
247 % created by Michael J.~Downes from the American Mathematical Society
248 % during the 1990's up to late 2002. Sadly---and much to the shock of
249 % the \TeX\ world---Michael passed away in early 2003 at the age of
252 % The American Mathematical Society has kindly allowed me to assume
253 % maintainership of this part of his work and I wish to express my
254 % gratitude to them and to Barbara Beeton in particular for providing
255 % me with the files I needed.
257 % I hope to continue Michael's work, thereby allowing users to create
258 % more \emph{masterpieces of the publishing art} as I think he would
263 % \section{Package loading}
266 % The recommended way of loading the \pkg{breqn} package is to load it
267 % \emph{after} other packages dealing with math, \ie, after
268 % \pkg{amsmath}, \pkg{amssymb}, or packages such as \pkg{mathpazo} or
271 % The \pkg{flexisym} package (described in section \vref{flexisym}) is
272 % required by \pkg{breqn} and ensures the math symbols are set up
273 % correctly. By default \pkg{breqn} loads it with support for Computer
274 % Modern but if you use a different math package requiring slightly
275 % different definitions, it must be loaded before \pkg{breqn}. Below
276 % is an example of how you enable \pkg{breqn} to work with the widely
277 % used \pkg{mathpazo} package.
279 %\usepackage{mathpazo}
280 %\usepackage[mathpazo]{flexisym}
283 % Currently, the packages \pkg{mathpazo} and \pkg{mathptmx} are
284 % supported. Despair not: Chances are that the package will work using
285 % the default settings. If you find that a particular math font
286 % package doesn't work then please see implementation in
287 % \fn{flexisym.dtx} for how to create a support file---it is easier
288 % than one might think. Contributions welcome.
290 % The documentation for the package was formerly found in
291 % \fn{breqndoc}. It has now been added to this implementation
292 % file. Below follows the contents of the original \pkg{breqn}
293 % documentation. Not all details hold anymore but I have prioritized
294 % fixing the package.
299 % \item Handling of QED
300 % \item Space between \verb'\end{dmath}' and following punctuation will
301 % prevent the punctuation from being drawn into the equation.
302 % \item Overriding the equation layout
303 % \item Overriding the placement of the equation number
304 % \item \qq{alignid} option for more widely separated equations where
305 % shared alignment is desired (requires two passes)
306 % \item Or maybe provide an \qq{alignwidths} option where you give
307 % lhs/rhs width in terms of ems? And get feedback later on discrepancies
308 % with the actual measured contents?
309 % \item \cs{intertext} not needed within dgroup! But currently there are
310 % limitations on floating objects within dgroup.
311 % \item \verb'align={1}' or 2, 3, 4 expressing various levels of demand
312 % for group-wide alignment. Level 4 means force alignment even if some
313 % lines then have to run over the right margin! Level 1, the default,
314 % means first break LHS-RHS equations as if it occurred by itself, then
315 % move them left or right within the current line width to align them if
316 % possible. Levels 2 and 3 mean try harder to align but give up if
317 % overfull lines result.
318 % \item Need an \cs{hshift} command to help with alignment of
319 % lines broken at a discretionary times sign. Also useful for adjusting
320 % inside-delimiter breaks.
323 % \section{Introduction}
325 % The \pkg{breqn} package for \LaTeX\ provides solutions to a number of
326 % common difficulties in writing displayed equations and getting
327 % high-quality output. For example, it is a well-known inconvenience that
328 % if an equation must be broken into more than one line, \cs{left} \dots\
329 % \cs{right} constructs cannot span lines. The \pkg{breqn} package makes
330 % them work as one would expect whether or not there is an intervening
333 % The single most ambitious goal of the \pkg{breqn} package, however, is
334 % to support automatic linebreaking of displayed equations. Such
335 % linebreaking cannot be done without substantial changes under the hood
336 % in the way math formulas are processed. For this reason, especially in
337 % the alpha release, users should proceed with care and keep an eye out
338 % for unexpected glitches or side effects.
340 % \section{Principal features}
341 % The principal features of the \pkg{breqn} package are:
342 % \begin{description}
344 % \item[semantically oriented structure] The way in which compound
345 % displayed formulas are subdivided matches the logical structure more
346 % closely than, say, the standard \env{eqnarray} environment. Separate
347 % equations in a group of equations are written as separate environments
348 % instead of being bounded merely by \dbslash/ commands. Among other
349 % things, this clears up a common problem of wrong math symbol spacing at
350 % the beginning of continuation lines. It also makes it possible to
351 % specify different vertical space values for the space between lines of a
352 % long, broken equation and the space between separate equations in a
353 % group of equations.
355 % \item[automatic line breaking] Overlong equations will be broken
356 % automatically to the prevailing column width, and continuation lines
357 % will be indented following standard conventions.
359 % \item[line breaks within delimiters] Line breaks within \cs{left} \dots\
360 % \cs{right} delimiters work in a natural way. Line breaks can be
361 % forbidden below a given depth of delimiter nesting through a package
364 % \item[mixed math and text] Display equations that contain mixed
365 % math and text, or even text only, are handled naturally by means of a
366 % \env{dseries} environment that starts out in text mode instead of math
369 % \item[ending punctuation] The punctuation at the end of a displayed
370 % equation can be handled in a natural way that makes it easier to promote
371 % or demote formulas from\slash to inline math, and to apply special
372 % effects such as adding space before the punctuation.
374 % \item[flexible numbering] Equation numbering is handled in a natural
375 % way, with all the flexibility of the \pkg{amsmath} package and with no
376 % need for a special \cs{nonumber} command.
378 % \item[special effects] It is easy to apply special effects to individual
379 % displays, e.g., changing the type size or adding a frame.
381 % \item[using available space] Horizontal shrink is made use of
382 % whenever feasible. With most other equation macros it is frozen when it
383 % occurs between \cs{left} \dots\ \cs{right} delimiters, or in any sort of
384 % multiline structure, so that some expressions require two lines that would
385 % otherwise fit on one.
387 % \item[high-quality spacing] The \cs{abovedisplayshortskip} is used when
388 % applicable (other equation macros fail to apply it in equations of more
391 % \item[abbreviations] Unlike the \pkg{amsmath} equation environments, the
392 % \pkg{breqn} environments can be called through user-defined abbreviations
393 % such as \cs{beq} \dots\ \cs{eeq}.
397 % \section{Shortcomings of the package}
398 % The principal known deficiencies of the \pkg{breqn} package are:
400 % \subsection{Incompatibilities} As it pushes the envelope
401 % of what is possible within the context of \LaTeXe, \thepkg will tend
402 % to break other packages when used in combination with them, or to fail
403 % itself, when there are any areas of internal overlap; successful use may
404 % in some cases depend on package loading order.
408 % \subsection{Indention of delimited fragments} When line breaks within
409 % delimiters are involved, the automatic indention of continuation lines
410 % is likely to be unsatisfactory and need manual adjustment. I don't see
411 % any easy way to provide a general solution for this, though I have some
412 % ideas on how to attain partial improvements.
414 % \subsection{Math symbol subversion}
415 % In order for automatic line breaking to work, the operation of all the
416 % math symbols of class 2, 3, 4, and 5 must be altered (relations, binary
417 % operators, opening delimiters, closing delimiters). This is done by an
418 % auxiliary package \pkg{flexisym}. As long as you stick to the advertised
419 % \LaTeX\ interface for defining math symbols (\cs{DeclareMathSymbol}),
420 % things should work OK most of the time. Any more complex math symbol
421 % setup is quite likely to quarrel with the \pkg{flexisym} package.
422 % See Section~\vref{flexisym} for further information.
424 % \subsection{Subscripts and superscripts}
426 % Because of the changes to math symbols of class 2--5, writing certain
427 % combinations such as \verb'^+' or \verb'_\pm' or \verb'^\geq' without
428 % braces would lead to error messages; (The problem described here
429 % already exists in standard \LaTeX\ to a lesser extent, as you may know
430 % if you ever tried \verb'^\neq' or \verb'^\cong'; and indeed there are
431 % no examples in the \LaTeX\ book to indicate any sanction for omitting
432 % braces around a subscript or superscript.)
434 % The \pkg{flexisym} package therefore calls, as of version 0.92, another
435 % package called \pkg{mathstyle} which turns \verb'^' and \verb'_' into
436 % active characters. This is something that I believe is desirable in any
437 % case, in the long run, because having a proper mathstyle variable
438 % eliminates some enormous burdens that affect almost any
439 % nontrivial math macros, as well as many other things where the
440 % connection is not immediately obvious, e.g., the \LaTeX\ facilities for
441 % loading fonts on demand.
443 % Not that this doesn't introduce new and interesting problems of its
444 % own---for example, you don't want to put usepackage statements
445 % after flexisym for any package that refers to, e.g., \verb'^^J' or
447 % internally (too bad that the \LaTeX\ package loading code does not
448 % include automatic defenses to ensure normal catcodes in the interior of
449 % a package; but it only handles the \verb'@' character).
451 % But I took a random AMS journal article, with normal end-user kind of
452 % \LaTeX\ writing, did some straightforward substitutions to change all
453 % the equations into dmath environments, and ran it with active math
454 % sub/sup: everything worked OK. This suggests to me that it can work in
455 % the real world, without an impossible amount of compatibility work.
457 % \section{Incomplete}
458 % In addition, in the \textbf{alpha release [1997/10/30]} the following
459 % gaps remain to be filled in:
460 % \begin{description}
461 % \item[documentation]
462 % The documentation could use amplification, especially more
463 % illustrations, and I have undoubtedly overlooked more than a few errors.
465 % \item[group alignment] The algorithm for doing alignment
466 % of mathrel symbols across equations in a \env{dgroup} environment
467 % needs work. Currently the standard and \opt{noalign} alternatives
468 % produce the same output.
470 % \item[single group number] When a \env{dgroup} has a group number and
471 % the individual equations are unnumbered, the handling and placement of
472 % the group number aren't right.
474 % \item[group frame] Framing a group doesn't work, you might be able to
475 % get frames on the individual equations at best.
477 % \item[group brace] The \opt{brace} option for \env{dgroup} is intended
478 % to produce a large brace encompassing the whole group. This hasn't been
481 % \item[darray environment] The \env{darray} environment is unfinished.
483 % \item[dseries environment] The syntax and usage for the \env{dseries}
484 % environment are in doubt and may change.
486 % \item[failure arrangements] When none of the line-breaking passes for a
487 % \env{dmath} environment succeeds\dash i.e., at least one line is
488 % overfull\dash the final arrangement is usually rather poor. A better
489 % fall-back arrangement in the failure case is needed.
493 % \section{Package options}
495 % Many of the package options for \thepkg are the same as options of the
496 % \env{dmath} or \env{dgroup} environments, and some of them require an
497 % argument, which is something that cannot be done through the normal
498 % package option mechanism. Therefore most of the \pkg{breqn} package
499 % options are designed to be set with a \cs{setkeys} command after the
500 % package is loaded. For example, to load the package and set the
501 % maximum delimiter nesting depth for line breaks to~1:
504 % \setkeys{breqn}{breakdepth={1}}
507 % See the discussion of environment options, Section~\vref{envopts}, for
510 % Debugging information is no longer available as a package
511 % option. Instead, the tracing information has been added in a fashion
512 % so that it can be enabled as a docstrip option:
514 % \generate{\file{breqn.sty}{\from{breqn.dtx}{package,trace}}}
518 % \section{Environments and commands}
519 % \subsection{Environments}
520 % All of the following environments take an optional argument for
521 % applying local effects such as changing the typesize or adding a
522 % frame to an individual equation.
524 % \begin{description}
525 % \item[\env{dmath}] Like \env{equation} but supports line breaking and variant
528 % \item[\env{dmath*}] Unnumbered; like \env{displaymath} but supports line
531 % \item[\env{dseries}] Like \env{equation} but starts out in text mode;
532 % intended for series of mathematical expressions of the form `A, B, and
533 % C'. As a special feature, if you use
535 % \begin{math} ... \end{math}
537 % for each expression in the series, a suitable amount of inter-expression
538 % space will be automatically added. This is a small step in the direction of
539 % facilitating conversion of display math to inline math, and vice versa: If
540 % you write a display as
543 % \begin{math}A\end{math},
544 % \begin{math}B\end{math},
546 % \begin{math}C\end{math}.
549 % then conversion to inline form is simply a matter of removing the
550 % \verb'\begin{dseries}' and \verb'\end{dseries}' lines; the contents of the
551 % display need no alterations.
553 % It would be nice to provide the same feature for \verb'$' notation but
554 % there is no easy way to do that because the \verb'$' function has no
555 % entry point to allow changing what happens before math mode is entered.
556 % Making it work would therefore require turning \verb'$' into an active
557 % character, something that I hesitate to do in a \LaTeXe\ context.
559 % \item[\env{dseries*}] Unnumbered variant of \env{dseries}
561 % \item[\env{dgroup}] Like the \env{align} environment of \pkg{amsmath},
562 % but with each constituent equation wrapped in a \env{dmath},
563 % \env{dmath*}, \env{dseries}, or \env{dseries*} environment instead of being
564 % separated by \dbslash/. The equations are numbered with a group number.
565 % When the constituent environments are the numbered forms (\env{dmath} or
566 % \env{dseries}) they automatically switch to `subequations'-style
567 % numbering, i.e., something like (3a), (3b), (3c), \dots, depending on
568 % the current form of non-grouped equation numbers. See also
571 % \item[\env{dgroup*}] Unnumbered variant of \env{dgroup}. If the
572 % constituent environments are the numbered forms, they get normal
573 % individual equation numbers, i.e., something like (3), (4), (5), \dots~.
575 % \item[\env{darray}] Similar to \env{eqnarray} but with an argument like
576 % \env{array} for giving column specs. Automatic line breaking is not
579 % \item[\env{darray*}] Unnumbered variant of \env{darray}, rather like
580 % \env{array} except in using \cs{displaystyle} for all column
583 % \item[\env{dsuspend}] Suspend the current display in order to print
584 % some text, without loss of the alignment. There is also a command
585 % form of the same thing, \cs{intertext}.
588 % \subsection{Commands}
590 % The commands provided by \thepkg are:
591 % \begin{description}
592 % \item[\cs{condition}] This command is used for
593 % a part of a display which functions as a condition on the main
594 % assertion. For example:
597 % f(x)=\frac{1}{x} \condition{for $x\neq 0$}
601 % f(x)=\frac{1}{x} \condition{for $x\neq 0$}
603 % The \cs{condition} command automatically switches to text mode (so that
604 % interword spaces function the way they should), puts in a comma, and
605 % adds an appropriate amount of space. To facilitate promotion\slash
606 % demotion of formulas, \cs{condition} \qq{does the right thing} if used
607 % outside of display math.
609 % To substitute a different punctuation mark instead of the default comma,
610 % supply it as an optional argument for the \cs{condition} command:
614 % (Thus, to get no punctuation: \verb'\condition[]{...}'.)
616 % For conditions that contain no text, you can use the starred form of the
617 % command, which means to stay in math mode:
620 % f(x)=\frac{1}{x} \condition*{x\neq 0}
623 % If your material contains a lot of conditions like these, you might like
624 % to define shorter abbreviations, e.g.,
626 % \newcommand{\mc}{\condition*}% math condition
627 % \newcommand{\tc}{\condition}% text condition
629 % But \thepkg refrains from predefining such abbreviations in order that
630 % they may be left to the individual author's taste.
632 % \item[\cs{hiderel}] In a compound equation it is sometimes desired to
633 % use a later relation symbol as the alignment point, rather than the
634 % first one. To do this, mark all the relation symbols up to the desired
635 % one with \cs{hiderel}:
637 % T(n) \hiderel{\leq} T(2^n) \leq c(3^n - 2^n) ...
641 % \section{Various environment options}\label{envopts}
643 % The following options are recognized for the \env{dmath}, \env{dgroup},
644 % \env{darray}, and \env{dseries} environments; some of the options do not
645 % make sense for all of the environments, but if an option is used where
646 % not applicable it is silently ignored rather than treated as an error.
649 % \begin{dmath}[style={\small}]
650 % \begin{dmath}[number={BV}]
651 % \begin{dmath}[label={xyz}]
652 % \begin{dmath}[relindent={1em}]
653 % \begin{dmath}[compact]
654 % \begin{dmath}[spread={1pt}]
655 % \begin{dmath}[frame]
656 % \begin{dmath}[frame={1pt},framesep={2pt}]
657 % \begin{dmath}[background={red}]
658 % \begin{dmath}[color={purple}]
659 % \begin{dmath}[breakdepth={0}]
662 % Use the \opt{style} option to change the type size of an individual
663 % equation. This option can also serve as a catch-all option for
664 % altering the equation style in other ways; the contents are simply
665 % executed directly within the context of the equation.
667 % Use the \opt{number} option if you want the number for a particular
668 % equation to fall outside of the usual sequence. If this option is used
669 % the equation counter is not incremented. If for some reason you need to
670 % increment the counter and change the number at the same time, use the
671 % \opt{style} option in addition to the \opt{number} option:
673 % style={\refstepcounter{equation}}
676 % Use of the normal \cs{label} command instead of the \opt{label} option
677 % works, I think, most of the time (untested).
679 % Use the \opt{relindent} option to specify something other than the
680 % default amount for the indention of relation symbols. The default is
683 % Use the \opt{compact} option in compound equations to inhibit line
684 % breaks at relation symbols. By default a line break will be taken before
685 % each relation symbol except the first one. With the \opt{compact} option
686 % \LaTeX\ will try to fit as much material as possible on each line, but
687 % breaks at relation symbols will still be preferred over breaks at binary
690 % Use the \opt{spread} option to increase (or decrease) the amount of
691 % interline space in an equation. See the example given above.
693 % Use the \opt{frame} option to produce a frame around the body of the
694 % equation. The thickness of the frame can optionally be specified by
695 % giving it as an argument of the option. The default thickness is
698 % Use the \opt{framesep} option to change the amount of space separating
699 % the frame from what it encloses. The default space is \cs{fboxsep}.
701 % Use the \opt{background} option to produce a colored background for the
702 % equation body. The \pkg{breqn} package doesn't automatically load the
703 % \pkg{color} package, so this option won't work unless you remember
704 % to load the \pkg{color} package yourself.
706 % Use the \opt{color} option to specify a different color for the contents
707 % of the equation. Like the \opt{background} option, this doesn't work if
708 % you forgot to load the \pkg{color} package.
710 % Use the \opt{breakdepth} option to change the level of delimiter nesting
711 % to which line breaks are allowed. To prohibit line breaks within
712 % delimiters, set this to 0:
714 % \begin{dmath}[breakdepth={0}]
716 % The default value for breakdepth is 2. Even when breaks are allowed
717 % inside delimiters, they are marked as less desirable than breaks outside
718 % delimiters. Most of the time a break will not be taken within delimiters
719 % until the alternatives have been exhausted.
721 % Options for the \env{dgroup} environment: all of the above, and also
723 % \begin{dgroup}[noalign]
724 % \begin{dgroup}[brace]
727 % By default the equations in a \env{dgroup} are mutually aligned on their
728 % relation symbols ($=$, $<$, $\geq$, and the like). With the
729 % \opt{noalign} option each equation is placed individually without
730 % reference to the others.
732 % The \opt{brace} option means to place a large brace encompassing the
733 % whole group on the same side as the equation number.
735 % Options for the \env{darray} environment: all of the above (where
736 % sensible), and also
738 % \begin{darray}[cols={lcr@{\hspace{2em}}lcr}]
740 % The value of the \opt{cols} option for the darray environment should be
741 % a series of column specs as for the \env{array} environment, with the
742 % following differences:
744 % \item For l, c, and r what you get is not text, but math, and
745 % displaystyle math at that. To get text you must use a 'p' column
746 % specifier, or put an \cs{mbox} in each of the individual cells.
748 % \item Vertical rules don't connect across lines.
751 % \section{The \pkg{flexisym} package}\label{flexisym}
753 % The \pkg{flexisym} package does some radical changes in the setup for
754 % math symbols to allow their definitions to change dynamically throughout
755 % a document. The \pkg{breqn} package uses this to make symbols of classes
756 % 2, 3, 4, 5 run special functions inside an environment such as
757 % \env{dmath} that provide the necessary support for automatic line
760 % The method used to effect these changes is to change the definitions of
761 % \cs{DeclareMathSymbol} and \cs{DeclareMathDelimiter}, and then
762 % re-execute the standard set of \LaTeX\ math symbol definitions.
763 % Consequently, additional mathrel and mathbin symbols defined by other
764 % packages will get proper line-breaking behavior if the other package is
765 % loaded after the \pkg{flexisym} package and the symbols are defined
766 % through the standard interface.
770 % \section{Caution! Warning!}
771 % Things to keep in mind when writing documents with \thepkg:
774 % \item The notation $:=$ must be written with the command \cs{coloneq}.
775 % Otherwise the $:$ and the $=$ will be treated as two separate relation
776 % symbols with an \qq{empty RHS} between them, and they will be printed
779 % \item Watch out for constructions like \verb'^+' where a single binary
780 % operator or binary relation symbol is subscripted or superscripted. When
781 % the \pkg{breqn} or \pkg{flexisym} package is used, braces are mandatory
782 % in such constructions: \verb'^{+}'. This applies for both display and
785 % \item If you want \LaTeX\ to make intelligent decisions about line
786 % breaks when vert bars are involved, use proper pairing versions of the
787 % vert-bar symbols according to context: \verb'\lvert n\rvert' instead of
788 % \verb'|n|'. With the nondirectional \verb'|' there is no way for \LaTeX\
789 % to reliably deduce which potential breakpoints are inside delimiters
790 % (more highly discouraged) and which are not.
792 % \item If you use the \pkg{german} package or some other package that
793 % turns double quote \verb'"' into a special character, you may encounter
794 % some problems with named math symbols of type mathbin, mathrel,
795 % mathopen, or mathclose in moving arguments. For example, \cs{leq} in a
796 % section title will be written to the \fn{.aux} file as something like
797 % \verb'\mathchar "3214'. This situation probably ought to be improved,
798 % but for now use \cs{protect}.
800 % \item Watch out for the \texttt{[} character at the beginning of a
801 % \env{dmath} or similar environment, if it is supposed to be interpreted
802 % as mathematical content rather than the start of the environment's
811 % This will not work as expected:
813 % \begin{dmath}[\lambda,1]...\end{dmath}
816 % \item Watch out for unpaired delimiter symbols (in display math only):
818 % ( ) [ ] \langle \rangle \{ \} \lvert \rvert ...
820 % If an open delimiter is used without a close delimiter, or vice versa,
821 % it is normally harmless but may adversely affect line breaking. This is only
822 % for symbols that have a natural left or right directionality. Unpaired
823 % \cs{vert} and so on are fine.
825 % When a null delimiter is used as the other member of the pair
826 % (\verb'\left.' or \verb'\right.') this warning doesn't apply.
828 % \item If you inadvertently apply \cs{left} or \cs{right} to something
829 % that is not a delimiter, the error messages are likely to be a bit
830 % more confusing than usual. The normal \LaTeX\ response to an error such
835 % is an immediate message
837 % ! Missing delimiter (. inserted).
839 % When \thepkg is in use, \LaTeX\ will fail to realize anything is wrong
840 % until it hits the end of the math formula, or a closing delimiter
841 % without a matching opening delimiter, and then the first message is an
842 % apparently pointless
844 % ! Missing \endgroup inserted.
851 % \renewcommand\theequation{\thesection.\arabic{equation}}
854 % Replace $j$ by $h-j$ and by $k-j$ in these sums to get [cf.~(26)]
855 % \begin{dmath}[label={sna74}]
856 % \frac{1}{6} \left(\sigma(k,h,0) +\frac{3(h-1)}{h}\right)
857 % +\frac{1}{6} \left(\sigma(h,k,0) +\frac{3(k-1)}{k}\right)
858 % =\frac{1}{6} \left(\frac{h}{k} +\frac{k}{h} +\frac{1}{hk}\right)
859 % +\frac{1}{2} -\frac{1}{2h} -\frac{1}{2k},
861 % which is equivalent to the desired result.
864 % % Knuth, SNA 4.6.2, p387
866 % \newcommand\mx[1]{\begin{math}#1\end{math}}% math expression
868 % Now every column which has no circled entry is completely zero;
869 % so when $k=6$ and $k=7$ the algorithm outputs two more vectors,
871 % \begin{dseries}[frame]
872 % \mx{v^{[2]} =(0,5,5,0,9,5,1,0)},
873 % \mx{v^{[3]} =(0,9,11,9,10,12,0,1)}.
875 % From the form of the matrix $A$ after $k=5$, it is evident that
876 % these vectors satisfy the equation $vA =(0,\dotsc,0)$.
881 % T(n) \hiderel{\leq} T(2^{\lceil\lg n\rceil})
882 % \leq c(3^{\lceil\lg n\rceil}
883 % -2^{\lceil\lg n\rceil})
890 % The reduced minimal Gr\"obner basis for $I^q_3$ consists of
893 % H_1^3 = x_1 + x_2 + x_3
896 % H_2^2 = x_1^2 + x_1 x_2 + x_2^2 - q_1 - q_2
902 % H_3^1 = x_1^3 - 2x_1 q_1 - x_2 q_1
909 % \part*{Implementation}
912 % The package version here is Michael's v0.90 updated by Bruce
913 % Miller. Michael's changes between v0.90 and his last v0.94 will be
914 % incorporated where applicable.
917 % The original sources of \pkg{breqn} and related files exist in a
918 % non-dtx format devised by Michael Downes himself.
919 % Lars Madsen has kindly written a Perl script for transforming the
920 % original source files into near-perfect dtx state, requiring only
921 % very little hand tuning. Without his help it would have been nigh
922 % impossible to incorporate the original sources with Michael's
923 % comments. A big, big thank you to him.
927 % \section{Introduction}
928 % The \pkg{breqn} package provides environments
929 % \env{dmath}, \env{dseries}, and \env{dgroup} for
930 % displayed equations with \emph{automatic line breaking},
931 % including automatic indention of relation symbols and binary operator
932 % symbols at the beginning of broken lines. These environments
933 % automatically pull in following punctuation so that it can be written in
934 % a natural way. The \pkg{breqn} package also provides a
935 % \env{darray} environment similar to the \env{array}
936 % environment but using \cs{displaystyle} for all the array cells and
937 % providing better interline spacing (because the vertical ruling
938 % feature of \env{array} is dropped).
939 % These are all autonumbered environments like \env{equation}
940 % and have starred forms that don't add a number. For a more
941 % comprehensive and detailed description of the features and intended
942 % usage of the \pkg{breqn} package see \fn{breqndoc.tex}.
948 % Features of particular note are the ability to have
949 % linebreaks even within a \cs{left} \ndash \cs{right} pair of
950 % delimiters, and the automatic alignment on relations and binary
951 % operators of a split equation. To make \env{dmath} handle
952 % all this, we begin by setting the body of the equation in a special
953 % paragraph form with strategic line breaks whose purpose is not to
954 % produce line breaks in the final printed output but rather to mark
955 % significant points in the equation and give us entry points for
956 % unpacking \cn{left} \ndash \cn{right} boxes.
957 % After the initial typesetting, we take the resulting stack of line
958 % fragments and, working backward, splice them into a new, single-line
959 % paragraph; this will eventually be poured into a custom parshape, after
960 % we do some measuring to calculate what that parshape should be.
961 % This streamlined horizontal list may contain embedded material
962 % from user commands intended to alter line breaks, horizontal alignment,
963 % and interline spacing; such material requires special handling.
965 % To make the `shortskip' possibility work even for
966 % multiline equations, we must plug in a dummy \tex display to give us
967 % the value of \cs{predisplaysize}, and calculate for ourselves when
968 % to apply the short skips.
970 % In order to measure the equation body and do various
971 % enervating calculations on whether the equation number will fit and so
972 % on, we have to set it in a box. Among other things, this means
973 % that we can't unhbox it inside \dbldollars \dots \dbldollars , or
974 % even \verb"$" \dots \verb"$": \tex doesn't allow you to
975 % \cs{unhbox} in math mode. But we do want to unhbox it rather
976 % than just call \cs{box}, otherwise we can't take advantage of
977 % available shrink from \cs{medmuskip} to make equations shrink to
978 % fit in the available width. So even for simple one-line equations
979 % we are forced to fake a whole display without going through \tex 's
980 % primitive display mechanism (except for using it to get
981 % \cs{predisplaysize} as mentioned above).
984 % In the case of a framed equation body, the current implementation is
985 % to set the frame in a separate box, of width zero and height zero,
986 % pinned to the upper left corner of the equation body, and then print the
987 % equation body on top of it.
988 % For attaching an equation number it would be much simpler to wrap
989 % the equation body in the frame and from then on treat the body as a
990 % single box instead of multiple line boxes.
991 % But I had a notion that it might be possible some day to support
992 % vertical stretching of the frame.
999 % This package doesn't work with \latex 2.09, nor with other
1000 % versions of \latex earlier than 1994/12/01.
1003 \NeedsTeXFormat{LaTeX2e}
1006 % Declare package name and date.
1008 \ProvidesPackage{breqn}[2007/12/22 v0.97a]
1012 % \section{Package options}
1014 % Most options are set with the \cs{options} command (which
1015 % calls \cs{setkeys}) because the standard package option
1016 % mechanism doesn't provide support for key-value syntax.
1018 % First we need to get the catcodes sorted out.
1020 \edef\breqnpopcats{%
1021 \catcode\number`\"=\number\catcode`\"
1023 \AtEndOfPackage{\breqnpopcats}%
1024 \catcode`\^=7 \catcode`\_=8 \catcode`\"=12 \relax
1025 \DeclareOption{mathstyleoff}{%
1026 \PassOptionsToPackage{mathstyleoff}{flexisym}%
1031 \ProcessOptions\relax
1037 % \section{Required packages}
1038 % The \pkg{flexisym} package makes it possible to attach
1039 % extra actions to math symbols, in particular mathbin, mathrel, mathopen,
1040 % and mathclose symbols.
1041 % Normally it would suffice to call \cs{RequirePackage} without
1042 % any extra testing, but the nature of the package is such that it is
1043 % likely to be called earlier with different (no) options.
1044 % Then is it really helpful to be always warning the user about
1045 % \quoted{Incompatible Package Options!}?
1048 \@ifpackageloaded{flexisym}{}{%
1049 \RequirePackage{flexisym}[2007/12/19]
1050 \edef\breqnpopcats{\breqnpopcats
1051 \catcode\number`\^=\number\catcode`\^
1052 \catcode\number`\_=\number\catcode`\_
1054 \catcode`\^=7 \catcode`\_=8 \catcode`\"=12 \relax
1057 % The \pkg{keyval} package for handling equation options and
1058 % \pkg{calc} to ease writing computations.
1060 \RequirePackage{keyval,calc}\relax
1064 % And add an \cs{options} cmd for processing package
1065 % options that require an argument. Maybe this will get added to
1066 % the \pkg{keyval} package eventually.
1068 \@ifundefined{options}{%
1072 % \begin{macro}{\options}
1073 % Get the package options and run setkeys on them.
1075 \newcommand{\options}[2]{%
1076 \expandafter\options@a\csname opt@#1.sty\endcsname{#2}%
1083 % \begin{macro}{\options@a}
1084 % \begin{macro}{\options@b}
1085 % \begin{macro}{\options@c}
1086 % \begin{macro}{\options@d}
1087 % Redefine \cs{opt@pkgname.sty} as we go along to take out
1088 % the options that are handled and leave the ones that are not.
1090 \def\options@a#1#2{%
1091 \edef\@tempa{\options@b#2,\@empty\@nil}%
1092 \ifx#1\relax \let#1\@empty\fi
1093 \xdef#1{#1\ifx#1\@empty\@xp\@gobble\@tempa\@empty\else\@tempa \fi}%
1096 % Add the next option, and recurse if there remain more
1099 \def\options@b#1,#2#3\@nil{%
1101 \ifx#2\@empty \else\options@b#2#3\@nil\fi
1104 % Discard everything after the first space.
1106 \def\options@c#1 #2\@nil{\options@d#1=\@nil}
1108 % Discard everything after the first = sign; add a comma only if the
1109 % remainder is not empty.
1111 \def\options@d#1=#2\@nil{\ifx\@empty #1\@empty\else,\fi#1}
1120 % The tail of the \cs{@ifundefined} test.
1122 }{}% end @ifundefined test
1128 % \section{Some useful tools}
1130 % \begin{macro}{\@nx}
1131 % \begin{macro}{\@xp}
1132 % The comparative brevity of \cs{@nx} and \cs{@xp} is
1133 % valuable not so much for typing convenience as for reducing visual
1134 % clutter in code sections that require a lot of expansion control.
1137 \let\@xp\expandafter
1143 % \begin{macro}{\@emptytoks}
1144 % Constant empty token register, analogous to \cs{@empty}.
1146 \@ifundefined{@emptytoks}{\newtoks\@emptytoks}{}
1151 % \begin{macro}{\f@ur}
1152 % Constants 0\ndash 3 are provided in plain \tex , but not 4.
1159 % \begin{macro}{\inf@bad}
1160 % \cs{inf@bad} is for testing box badness.
1162 \newcount\inf@bad \inf@bad=1000000
1167 % \begin{macro}{\maxint}
1169 % We want to use \cs{maxint} rather than coerced
1170 % \cs{maxdimen} for \cs{linepenalty} in one place.
1172 \newcount\maxint \maxint=2147483647
1178 % \begin{macro}{\int@a}
1179 % \begin{macro}{\int@b}
1180 % \begin{macro}{\int@b}
1182 % Provide some shorter aliases for various scratch registers.
1184 \let\int@a=\@tempcnta
1185 \let\int@b=\@tempcntb
1194 % \begin{macro}{\dim@a}
1195 % \begin{macro}{\dim@b}
1196 % \begin{macro}{\dim@c}
1197 % \begin{macro}{\dim@d}
1198 % \begin{macro}{\dim@e}
1199 % \begin{macro}{\dim@A}
1201 % Same for dimen registers.
1203 \let\dim@a\@tempdima
1204 \let\dim@b\@tempdimb
1205 \let\dim@c\@tempdimc
1219 % \begin{macro}{\skip@a}
1220 % \begin{macro}{\skip@b}
1221 % \begin{macro}{\skip@c}
1223 % Same for skip registers.
1225 \let\skip@a\@tempskipa
1226 \let\skip@b\@tempskipb
1235 % \begin{macro}{\toks@a}
1236 % \begin{macro}{\toks@b}
1237 % \begin{macro}{\toks@c}
1238 % \begin{macro}{\toks@d}
1239 % \begin{macro}{\toks@e}
1240 % \begin{macro}{\toks@f}
1242 % Same for token registers.
1244 \let\toks@a\@temptokena
1260 % \begin{macro}{\abs@num}
1261 % We need an absolute value function for comparing
1264 \def\abs@num#1{\ifnum#1<\z@-\fi#1}
1269 % \begin{macro}{\@ifnext}
1270 % \begin{macro}{\@ifnexta}
1271 % The \cs{@ifnext} function is a variation of
1272 % \cs{@ifnextchar} that doesn't skip over intervening whitespace.
1273 % We use it for the optional arg of \dbslash inside
1274 % \env{dmath} \etc because we don't want
1275 % unwary users to be tripped up by an unexpected attempt on \latex 's part
1276 % to interpret a bit of math as an optional arg:
1277 % \begin{literalcode}
1285 \def\@ifnext#1#2#3{%
1286 \let\@tempd= #1\def\@tempa{#2}\def\@tempb{#3}%
1287 \futurelet\@tempc\@ifnexta
1290 % Switch to \cs{@tempa} iff the next token matches.
1292 \def\@ifnexta{\ifx\@tempc\@tempd \let\@tempb\@tempa \fi \@tempb}
1299 % \begin{macro}{\@ifstar}
1300 % Similarly let's remove space-skipping from \cs{@ifstar}
1301 % because in some rare case of \dbslash inside an equation, followed by
1302 % a space and a \verb"*" where the \verb"*" is intended as the math
1303 % binary operator, it would be a disservice to gobble the star as an
1304 % option of the \dbslash command. In all other contexts the chance
1305 % of having a space \emph{before} the star is extremely small: either
1306 % the command is a control word which will get no space token after it in
1307 % any case because of \tex 's tokenization rules; or it is a control
1308 % symbol such as \dbslash \verb"*" which is exceedingly unlikely to be
1309 % written as \dbslash \verb"*" by any one who really wants the
1310 % \verb"*" to act as a modifier for the \dbslash command.
1313 \let\@tempd*\def\@tempa*{#1}\def\@tempb{#2}%
1314 \futurelet\@tempc\@ifnexta
1320 % \begin{macro}{\@optarg}
1321 % Utility function for reading an optional arg
1322 % \emph{without} skipping over any intervening spaces.
1324 \def\@optarg#1#2{\@ifnext[{#1}{#1[#2]}}
1330 % \begin{macro}{\@True}
1331 % \begin{macro}{\@False}
1332 % \begin{macro}{\@Not}
1333 % \begin{macro}{\@And}
1334 % After \verb"\let\foo\@True" the test
1335 % \begin{literalcode}
1338 % evaluates to true. Would rather avoid \cs{newif} because it
1339 % uses three csnames per Boolean variable; this uses only one.
1343 \def\@Not#1{0\ifcase#11 \or\@xp 1\else \@xp 0\fi}
1344 \def\@And#1#2{0\ifcase#1#2 \@xp 0\else \@xp 1\fi}
1345 \def\@Or#1#2{0\ifnum#1#2<101 \@xp 0\else \@xp 1\fi}
1355 \def\theb@@le#1{\if#1 True\else False\fi}
1357 % \begin{macro}{\freeze@glue}
1359 % Remove the stretch and shrink from a glue register.
1361 \def\freeze@glue#1{#11#1\relax}
1365 % \begin{macro}{\z@rule}
1366 % \begin{macro}{\keep@glue}
1368 % the intentional absence of \cs{relax} at the end of the replacement
1369 % text of \cs{z@rule}; use it with care.
1371 \def\z@rule{\vrule\@width\z@}% no \relax ! use with care
1373 % Different ways to keep a bit of glue from disappearing at the
1374 % beginning of a line after line breaking:
1376 % \item Zero-thickness rule
1377 % \item Null character
1378 % \item \cs{vadjust}\verb"{}" (\texbook , Exercise ??)
1380 % The null character idea would be nice except it
1381 % creates a mathord which then screws up math spacing for \eg a following
1382 % unary minus sign. (the vrule \emph{is} transparent to
1383 % the math spacing). The vadjust is the cheapest in terms of box
1384 % memory\mdash it vanishes after the pass through \tex 's
1386 % It is what I would have used, except that the equation contents get
1387 % run through two paragraphing passes, once for breaking up LR boxes and
1388 % once for the real typesetting.
1389 % If \cs{keep@glue} were done with an empty vadjust, it would
1390 % disappear after the first pass and\mdash in particular\mdash the
1391 % pre-bin-op adjustment for relation symbols would disappear at a line break.
1393 \def\keep@glue{\z@rule\relax}
1399 % \begin{macro}{\replicate}
1401 % This is a fully expandable way of making N copies of a token
1403 % Based on a post of David Kastrup to comp.text.tex circa January
1405 % The extra application of \cs{number} is needed for maximal
1406 % robustness in case the repeat count N is given in some weird \tex form
1407 % such as \verb|"E9| or \verb|\count9|.
1409 % usage: \message{H\replicate{5}{i h}ow de doo dee!}
1410 \begingroup \catcode`\&=11
1412 \csname &\expandafter\replicate@a\romannumeral\number\number#1 000q\endcsname
1419 % \begin{macro}{\replicate@a}
1421 \long\def\replicate@a#1#2\endcsname#3{#1\endcsname{#3}#2}
1426 % \begin{macro}{\8m}% fix
1428 \begingroup \catcode`\&=11
1429 \long\gdef\&m#1#2{#1\csname \endcsname{#1}}
1435 % \begin{macro}{\8q}% fix
1437 \@xp\let\csname\string &q\endcsname\@gobble
1441 % \begin{macro}{\mathchars@reset}
1443 % Need to patch up this function from flexisym a little, to better
1444 % handle certain constructed symbols like \cs{neq}.
1446 \g@addto@macro\mathchars@reset{%
1447 \let\@symRel\@secondoftwo \let\@symBin\@secondoftwo
1448 \let\@symDeL\@secondoftwo \let\@symDeR\@secondoftwo
1449 \let\@symDeB\@secondoftwo
1455 % \begin{macro}{\eq@cons}
1457 % \latex 's \cs{@cons} appends to the end of a list, but we need
1458 % a function that adds material at the beginning.
1461 \begingroup \let\@elt\relax \xdef#1{\@elt{#2}#1}\endgroup
1466 % \begin{macro}{\@saveprimitive}
1467 % If some preceding package redefined one of the
1468 % primitives that we must change, we had better do some checking to make
1469 % sure that we are able to save the primitive meaning for internal use.
1470 % This is handled by the \cs{@saveprimitive} function. We
1471 % follow the example of \cs{@@input} where the primitive meaning is
1472 % stored in an internal control sequence with a \verb"@@" prefix.
1473 % Primitive control sequences can be distinguished by the fact that
1474 % \cs{string} and \cs{meaning} return the same information.
1475 % Well, not quite all: \cs{nullfont} and \cs{topmark}
1476 % and the other \cs{...mark} primitives being the exceptions.
1478 \providecommand{\@saveprimitive}[2]{%
1480 \edef\@tempa{\string#1}\edef\@tempb{\meaning#1}%
1481 \ifx\@tempa\@tempb \global\let#2#1%
1484 % If [arg1] is no longer primitive, then we are in trouble unless
1485 % [arg2] was already given the desired primitive meaning somewhere
1488 \edef\@tempb{\meaning#2}%
1490 \else \@saveprimitive@a#1#2%
1496 % Aux function, check for the special cases.
1497 % Most of the time this branch will be skipped so we can
1498 % stuff a lot of work into it without worrying about speed costs.
1500 \providecommand\@saveprimitive@a[2]{%
1502 \def\@tempb##1#1##2{\edef\@tempb{##2}\@car{}}%
1503 \@tempb\nullfont{select font nullfont}%
1504 \topmark{\string\topmark:}%
1505 \firstmark{\string\firstmark:}%
1506 \botmark{\string\botmark:}%
1507 \splitfirstmark{\string\splitfirstmark:}%
1508 \splitbotmark{\string\splitbotmark:}%
1510 \edef\@tempa{\expandafter\strip@prefix\meaning\@tempb}%
1511 \edef\@tempb{\meaning#1}%
1512 \ifx\@tempa\@tempb \global\let#2#1%
1514 \PackageError{breqn}%
1515 {Unable to properly define \string#2; primitive
1516 \noexpand#1no longer primitive}\@eha
1525 % \begin{macro}{\@@math}
1526 % \begin{macro}{\@@endmath}
1527 % \begin{macro}{\@@display}
1528 % \begin{macro}{\@@enddisplay}
1529 % Move the math-start and math-end functions into control
1530 % sequences. If I were redesigning \tex I guess I'd put these
1531 % functions into primitive control words instead of linking them to a
1532 % catcode. That way \tex would not have to do the special
1533 % lookahead at a \verb"$" to see if there's another one coming up.
1534 % Of course that's related to the question of how to provide user
1535 % shorthand for common constructions: \tex , or an editing interface of
1538 \begingroup \catcode`\$=\thr@@ % just to make sure
1539 \global\let\@@math=$ \gdef\@@display{$$}% $$$
1541 \let\@@endmath=\@@math
1542 \let\@@enddisplay=\@@display
1550 % \begin{macro}{\@@insert}
1551 % \begin{macro}{\@@mark}
1552 % \begin{macro}{\@@vadjust}
1553 % Save the primitives \cs{vadjust}, \cs{insert},
1554 % \cs{mark} because we will want to change them locally during
1555 % equation measuring to keep them from getting in the way of our vertical
1556 % decomposition procedures. We follow the example of
1557 % \cs{@@input}, \cs{@@end}, \cs{@@par} where the primitive
1558 % meaning is stored in an internal control sequence with a \verb"@@"
1561 \@saveprimitive\vadjust\@@vadjust
1562 \@saveprimitive\insert\@@insert
1563 \@saveprimitive\mark\@@mark
1572 % \section{Debugging}
1576 \errorcontextlines=2000\relax
1579 % \begin{macro}{\breqn@debugmsg}
1580 % Print a debugging message.
1582 \long\def\breqn@debugmsg#1{\GenericInfo{||}{||=\space#1}}
1586 % \begin{macro}{\debugwr}
1587 % Sometimes the newline behavior of \cs{message} is
1588 % unsatisfactory; this provides an alternative.
1590 \def\debugwr#1{\immediate\write\sixt@@n{||= #1}}
1595 % \begin{macro}{\debug@box}
1596 % Record the contents of a box in the log file, without stopping.
1599 \batchmode{\showboxbreadth\maxdimen\showboxdepth99\showbox#1}%
1606 % \begin{macro}{\eqinfo}
1607 % Show lots of info about the material before launching into the
1612 \wlog{!! EQ@copy: \the\wd\EQ@copy\space x
1613 \the\ht\EQ@copy+\the\dp\EQ@copy
1620 % \begin{macro}{\debug@para}
1621 % Check params that affect line breaking.
1624 \debugwr{\hsize\the\hsize, \parfillskip\the\parfillskip}%
1625 \breqn@debugmsg{\leftskip\the\leftskip, \rightskip\the\rightskip}%
1626 \breqn@debugmsg{\linepenalty\the\linepenalty, \adjdemerits\the\adjdemerits}%
1627 \breqn@debugmsg{\pretolerance\the\pretolerance, \tolerance\the\tolerance,
1628 \parindent\the\parindent}%
1641 % \section{The \cs{listwidth} variable}
1642 % The dimen variable \cs{listwidth} is \cs{linewidth}
1643 % plus \cs{leftmargin} plus \cs{rightmargin}, which is typically
1644 % less than \cs{hsize} if the list depth is greater than one.
1645 % In case a future package will provide this variable, define it only
1646 % if not yet defined.
1648 \@ifundefined{listwidth}{\newdimen\listwidth}{}
1655 % \section{Parameters}
1657 % Here follows a list of parameters needed.
1659 % \begin{macro}{\eqfontsize}
1660 % \begin{macro}{\eqcolor}
1661 % \begin{macro}{\eqmargin}
1662 % \begin{macro}{\eqindent}
1663 % \begin{macro}{\eqbinoffset}
1664 % \begin{macro}{\eqnumside}
1665 % \begin{macro}{\eqnumplace}
1666 % \begin{macro}{\eqnumsep}
1667 % \begin{macro}{\eqnumfont}
1668 % \begin{macro}{\eqnumform}
1669 % \begin{macro}{\eqnumsize}
1670 % \begin{macro}{\eqnumcolor}
1671 % \begin{macro}{\eqlinespacing}
1672 % \begin{macro}{\eqlineskip}
1673 % \begin{macro}{\eqlineskiplimit}
1674 % \begin{macro}{\eqstyle}
1675 % \begin{macro}{\eqinterlinepenalty}
1676 % \begin{macro}{\intereqpenalty}
1677 % \begin{macro}{\intereqskip}
1679 % Note: avoid M, m, P, p because they look like they might be the
1680 % start of a keyword \quoted{minus} or \quoted{plus}. Then
1681 % \tex looks further to see if the next letter is i or l. And if
1682 % the next thing is an undefined macro, the attempt to expand the macro
1683 % results in an error message.
1685 \def\eqfontsize{} % Inherit from context [NOT USED?]
1686 \def\eqcolor{black} % Default to black [NOT USED?]
1687 \newdimen\eqnumsep \eqnumsep=10pt % Min space between equ number and body
1688 \newdimen\eqmargin \eqmargin=8pt % For `multline' gap emulation
1690 % The \cs{eqindent} and \cs{eqnumside} variables need to
1691 % have their values initialized from context, actually. But
1692 % that takes a bit of work, which is postponed till later.
1694 \def\eqindent{C}% % C or I, centered or indented
1695 \def\eqnumside{R}% % R or L, right or left
1696 \def\eqnumplace{M}% % M or T or B, middle top or bottom
1698 % Typesetting the equation number is done thus:
1699 % \begin{literalcode}
1700 % {\eqnumcolor \eqnumsize \eqnumfont{\eqnumform{\eq@number}}}
1704 %d\eqnumfont{\upshape}% % Upright even when surrounding text is slanted
1705 \def\eqnumfont{}% % Null for easier debugging [mjd,1997/09/26]
1706 \def\eqnumform#1{(#1\@@italiccorr)} % Add parens
1707 \def\eqnumsize{} % Allow numbers to have different typesize ...
1709 % Tricky questions on \cs{eqnumsize}. Should the default
1710 % be \cs{normalsize}? Then the user can scale down the
1711 % equation body with \cs{small} and not affect the equation
1712 % number. Or should the default be empty? Then in large
1713 % sections of smaller text, like the dangerous bend stuff in
1714 % \emph{\TeX book}, the equation number size will keep in synch
1716 % Maybe need an \cs{eqbodysize} param as well to allow separating
1719 \def\eqnumcolor{} % ... or color than eq body e.g. \color{blue}
1720 \newlength\eqlinespacing \eqlinespacing=14pt plus2pt % Base-to-base space between lines
1721 \newlength\eqlineskip \eqlineskip=3pt plus2pt % Min space if eqlinespacing too small
1722 \newdimen\eqlineskiplimit \eqlineskiplimit=2pt % Threshold for switching to eqlineskip
1724 % The value of \cs{eqbinoffset} should include a negative shrink
1725 % component that cancels the shrink component of medmuskip, otherwise
1726 % there can be a noticeable variation in the indent of adjacent lines if
1727 % one is shrunken a lot and the other isn't.
1729 \newmuskip \eqbinoffset \eqbinoffset=15mu minus-3mu % Offset from mathrel alignment pt for mathbins
1730 \newmuskip\eqdelimoffset \eqdelimoffset=2mu % Additional offset for break inside delims
1731 \newdimen\eqindentstep \eqindentstep=8pt % Indent used when LHS wd is n/a or too large
1732 \newtoks\eqstyle % Customization hook
1733 \newcount\eqbreakdepth \eqbreakdepth=2 % Allow breaks within delimiters to this depth
1734 \newcount \eqinterlinepenalty \eqinterlinepenalty=10000 % No page breaks between equation lines
1735 \newcount \intereqpenalty \intereqpenalty=1000 % Pagebreak penalty between equations [BRM: Was \@M]
1736 \newlength \intereqskip \intereqskip=3pt plus2pt % Additional vert space between equations
1737 \newcount\prerelpenalty \prerelpenalty=-\@M % Linebreak penalty before mathrel symbols
1738 \newcount\prebinoppenalty \prebinoppenalty=888 % Linebreak penalty before mathbins
1740 % When breaking equations we never right-justify, so a stretch
1741 % component of the muskip is never helpful and sometimes it is definitely
1742 % undesirable. Note that thick\slash medmuskips frozen inside a
1743 % fraction or radical may turn out noticeably larger than neighboring
1744 % unfrozen ones. Nonetheless I think this way is the best
1745 % compromise short of a new \tex that can make those built-up objects
1746 % shrink horizontally in proportion; the alternative is to pretty much
1747 % eliminate the shrink possibility completely in displays.
1749 \newmuskip \Dmedmuskip \Dmedmuskip=4mu minus 3mu % medmuskip in displays
1750 \newmuskip \Dthickmuskip \Dthickmuskip=5mu minus 2mu % thickmuskip in displays
1773 % And now some internal variables. 1997/10/22: some of
1774 % these are dead branches that need to be pruned.
1776 % MH: Started cleaning up a bit. No more funny loops.
1778 \def\eq@number{} % Internal variable
1779 \newlength\eqleftskip \eqleftskip=\@centering % Space on the left [NOT USED?]
1780 \newlength\eqrightskip \eqrightskip=\@centering % Space on the right [NOT USED?]
1781 \newlength\eq@vspan \eq@vspan=\z@skip % Glue used to vcenter the eq number
1782 \newmuskip\eq@binoffset \eq@binoffset=\eqbinoffset % Roughly, \eqbinoffset + \eqdelimoffset
1783 \newsavebox\EQ@box % Storage for equation body
1784 \newsavebox\EQ@copy % For eq body sans vadjust/insert/mark material
1785 \newsavebox\EQ@numbox % For equation number
1786 \newdimen\eq@wdNum % width of number + separation [NEW]
1787 \newsavebox\GRP@numbox % For group number [NEW]
1788 \newdimen\grp@wdNum % width of number + separation [NEW]
1789 %%B\EQ@vimbox % Vadjust, insert, or mark material
1790 %%B\EQ@vimcopy % Spare copy of same
1791 %%B\eq@impinging % Temporary box for measuring number placement
1792 \newcount \eq@lines % Internal counter, actual number of lines
1793 \newcount \eq@curline % Loop counter
1794 \newcount \eq@badness % Used in testing for overfull lines
1795 \newcount \EQ@vims % For bookkeeping
1796 \def\@eq@numbertrue{\let\eq@hasNumber\@True}%
1797 \def\@eq@numberfalse{\let\eq@hasNumber\@False}%
1798 \let\eq@hasNumber\@False
1800 % Here for the dimens, it would be advisable to do some more careful
1801 % management to conserve dimen registers. First of all, most of the
1802 % dimen registers are needed in the measuring phase, which is a tightly
1803 % contained step that happens after the contents of the equation have been
1804 % typeset into a box and before any external functions have a chance to
1805 % regain control\mdash \eg , the output routine.
1806 % Therefore it is possible to make use of the the dimen registers 0--9,
1807 % reserved by convention for scratch use, without fear of conflict with
1808 % other macros. But I don't want to use them directly with the
1810 % \begin{literalcode}
1811 % \dimen@ \dimen@i \dimen@ii \dimen3 \dimen4 ... \dimen9
1813 % . It would be much more useful to have names for these registers
1814 % indicative of way they are used.
1816 % Another source whence dimen registers could be borrowed is the
1817 % \pkg{amsmath} package, which allocates six registers for
1818 % equation-measuring purposes. We can reuse them under different
1819 % names since the \pkg{amsmath} functions and our functions will
1820 % never be used simultaneously.
1821 % \begin{literalcode}
1822 % \eqnshift@ \alignsep@ \tagshift@ \tagwidth@ \totwidth@ \lineht@
1825 \newdimen\eq@dp % Depth of last line
1826 \newdimen\eq@wdL % Width of the left-hand-side
1827 \newdimen\eq@wdT % Total width for framing
1828 \newdimen\eq@wdMin % Width of narrowest line in equation
1829 \newdimen\grp@wdL % Max width of LHS's in a group
1830 \newdimen\grp@wdR % Max RHS of all equations in a group
1833 \newdimen\eq@firstht % Height of first line
1835 % BRM: measure the condition too.
1838 \newdimen\eq@indentstep % Indent amount when LHS is not present
1839 \newdimen\eq@linewidth % Width actually used for display
1840 \newdimen\grp@linewidth % Max eq@linewidth over a group
1842 % Maybe \cs{eq@hshift} could share the same register as
1843 % \cs{mathindent} [mjd,1997/10/22].
1846 \let\eq@isIntertext\@False
1848 % Init \cs{eq@indentstep} to a nonzero value so that we can
1849 % detect and refrain from clobbering a user setting of zero.
1850 % And \cs{eq@sidespace} to \cs{maxdimen} because
1851 % that is the right init before computing a min.
1853 \eq@indentstep=\maxdimen
1854 \newdimen\eq@given@sidespace
1857 % \begin{macro}{\eq@overrun}
1858 % MH: Appears to be unused.
1860 % Not a dimen register; don't need to advance it.
1862 \def\eq@overrun{0pt}
1868 % To initialize \cs{eqnumside} and \cs{eqindent} properly,
1869 % we may need to grub around a bit in \cs{@filelist}. However,
1870 % if the \pkg{amsmath} package was used, we can use its option
1871 % data. More trouble: if a documentclass sends an option of
1872 % \opt{leqno} to \pkg{amsmath} by default, and it gets
1873 % overridden by the user with a \opt{reqno} documentclass option,
1874 % then \pkg{amsmath} believes itself to have received
1875 % \emph{both} options.
1877 \@ifpackagewith{amsmath}{leqno}{%
1878 \@ifpackagewith{amsmath}{reqno}{}{\def\eqnumside{L}}%
1881 % If the \pkg{amsmath} package was not used, the next
1882 % method for testing the \opt{leqno} option is to see if
1883 % \fn{leqno.clo} is present in \cs{@filelist}.
1885 \def\@tempa#1,leqno.clo,#2#3\@nil{%
1886 \ifx @#2\relax\else \def\eqnumside{L}\fi
1888 \@xp\@tempa\@filelist,leqno.clo,@\@nil
1890 % Even that test may fail in the case of \cls{amsart} if it does
1891 % not load \pkg{amsmath}. Then we have to look whether
1892 % \cs{iftagsleft@} is defined, and if so whether it is true.
1893 % This is tricky if you want to be careful about conditional nesting
1894 % and don't want to put anything in the hash table unnecessarily.
1898 \@ifundefined{iftagsleft@}{}{%
1900 \if TT\csname fi\endcsname\csname iftagsleft@\endcsname
1907 % A similar sequence of tests handles the \quoted{fleqn or not fleqn}
1908 % question for the \cls{article} and \cls{amsart}
1911 \@ifpackagewith{amsmath}{fleqn}{%
1914 \def\@tempa#1,fleqn.clo,#2#3\@nil{%
1915 \ifx @#2\relax\else \def\eqindent{I}\fi
1917 \@xp\@tempa\@filelist,fleqn.clo,@\@nil
1920 \@ifundefined{if@fleqn}{}{%
1922 \if TT\csname fi\endcsname\csname if@fleqn\endcsname
1929 % BRM: This conditional implies we must use ALL indented or ALL centered?
1932 \@ifundefined{mathindent}{%
1933 \newdimen\mathindent
1935 \@ifundefined{@mathmargin}{}{%
1936 \mathindent\@mathmargin
1945 % \section{Measuring equation components}
1946 % Measure the left-hand side of an equation. This
1947 % function is called by mathrel symbols. For the first mathrel we
1948 % want to discourage a line break more than for following mathrels; so
1949 % \cs{mark@lhs} gobbles the following \cs{rel@break} and
1950 % substitutes a higher penalty.
1952 % Maybe the LHS should be kept in a separate box.
1957 % \begin{macro}{\EQ@hasLHS}
1959 % Boolean: does this equation have a \dquoted{left-hand side}?
1961 \let\EQ@hasLHS=\@False
1966 % \begin{macro}{\EQ@QED}
1968 % If nonempty: the qed material that should be incorporated into this
1969 % equation after the final punctuation.
1976 % \begin{macro}{\mark@lhs}
1980 \ifnum\lr@level<\@ne
1982 \global\let\EQ@hasLHS=\@True
1983 \global\let\EQ@prebin@space\EQ@prebin@space@a
1986 % But the penalty for the first mathrel should still be lower than a
1987 % binoppenalty. If not, when the LHS contains a binop, the split
1988 % will occur inside the LHS rather than at the mathrel.
1989 % On the other hand if we end up with a multline sort of equation
1990 % layout where the RHS is very short, the break before the relation symbol
1991 % should be made \emph{less} desirable than the breakpoints inside
1993 % Since a lower penalty takes precedence over a higher one, we start
1994 % by putting in the highest relpenalty; during subsequent measuring if we
1995 % find that that RHS is not excessively short then we put in an extra
1996 % \dquoted{normal} relpenalty when rejoining the LHS and RHS.
1998 \penalty9999 % instead of normal \rel@break
1999 % else no penalty = forbid break
2006 % \begin{macro}{\mark@lhs@a}
2008 % Temporarily add an extra thickmuskip to the LHS; it will be removed
2009 % later. This is necessary to compensate for the disappearance of
2010 % the thickmuskip glue preceding a mathrel if a line break is taken at
2011 % that point. Otherwise we would have to make our definition of
2012 % mathrel symbols more complicated, like the one for mathbins. The
2013 % penalty of $2$ put in with vadjust is a flag for
2014 % \cs{eq@repack} to suggest that the box containing this line should
2015 % be measured to find the value of \cs{eq@wdL}. The
2016 % second vadjust ensures that the normal prerelpenalty and thickmuskip
2017 % will not get lost at the line break during this preliminary pass.
2019 % BRM: I originally thought the \verb"\mskip\thickmuskip" was messing
2020 % up summation limits in LHS. But I may have fixed that problem by
2021 % fixing other things\ldots
2024 \mskip\thickmuskip \@@vadjust{\penalty\tw@}\penalty-\@Mi\@@vadjust{}%
2031 % \begin{macro}{\hiderel}
2032 % If you want the LHS to extend past the first mathrel symbol to a
2033 % following one, mark the first one with \cs{hiderel}:
2034 % \begin{literalcode}
2035 % a \hiderel{=} b = c...
2039 % I'm not sure now why I didn't use \cs{begingroup}
2040 % \cs{endgroup} here \begin{dn}
2047 \newcommand\hiderel[1]{\mathrel{\advance\lr@level\@ne#1}}
2052 % \begin{macro}{\m@@Bin}
2053 % \begin{macro}{\m@@Rel}
2054 % \begin{macro}{\bin@break}
2055 % \begin{macro}{\rel@break}
2056 % \begin{macro}{\bin@mark}
2057 % \begin{macro}{\rel@mark}
2058 % \begin{macro}{\d@@Bin}
2059 % \begin{macro}{\d@@Rel}
2061 % \cf \pkg{flexisym} handling of mathbins and mathrels. These
2062 % are alternate definitions of \cs{m@Bin} and \cs{m@Rel},
2063 % activated by \cs{display@setup}.
2067 \let\EQ@prebin@space\relax
2068 \def\EQ@prebin@space@a{\mskip-\eq@binoffset \keep@glue \mskip\eq@binoffset}
2069 \def\bin@break{\ifnum\lastpenalty=\z@\penalty\prebinoppenalty\fi
2072 \ifnum\abs@num\lastpenalty <\abs@num\prerelpenalty
2073 \penalty\prerelpenalty
2076 \def\d@@Bin{\bin@break \m@@Bin}
2077 \def\d@@Rel{\mark@lhs \rel@break \m@@Rel}
2079 % The difficulty of dealing properly with the subscripts and
2080 % superscripts sometimes appended to mathbins and mathrels is one of the
2081 % reasons that we do not attempt to handle the mathrels as a separate
2082 % \quoted{column} a la \env{eqnarray}.
2094 % \begin{macro}{\m@@symRel}
2095 % \begin{macro}{\d@@symRel}
2096 % \begin{macro}{\m@@symBin}
2097 % \begin{macro}{\d@@symBin}
2098 % \begin{macro}{\m@@symDel}
2099 % \begin{macro}{\d@@symDel}
2100 % \begin{macro}{\m@@symDeR}
2101 % \begin{macro}{\d@@symDeR}
2102 % \begin{macro}{\m@@symDeB}
2103 % \begin{macro}{\d@@symDeB}
2104 % \begin{macro}{\m@@symDeA}
2105 % \begin{macro}{\d@@symDeA}
2109 \let\m@@symRel\@symRel \def\d@@symRel{\mark@lhs \rel@break \m@@symRel}
2110 \let\m@@symBin\@symBin \def\d@@symBin{\bin@break \m@@symBin}
2111 \let\m@@symDel\@symDel
2112 \let\m@@symDeR\@symDeR
2113 \let\m@@symDeB\@symDeB
2114 \let\m@@symDeA\@symDeA
2131 % \begin{macro}{\display@setup}
2132 % \begin{macro}{\everydisplay}
2133 % Setup. Note that \latex reserves the primitive
2134 % \cs{everydisplay} under the name \cs{frozen@everydisplay}.
2135 % BRM: Disable this! It also affects non-breqn math!!!!
2137 %\global\everydisplay\expandafter{\the\everydisplay \display@setup}
2139 % Change some math symbol function calls.
2141 \def\display@setup{%
2142 \medmuskip\Dmedmuskip \thickmuskip\Dthickmuskip
2143 \let\m@Bin\d@@Bin \let\m@Rel\d@@Rel
2144 \let\@symRel\d@@symRel \let\@symBin\d@@symBin
2145 \let\m@DeL\d@@DeL \let\m@DeR\d@@DeR \let\m@DeB\d@@DeB
2147 \let\@symDeL\d@@symDeL \let\@symDeR\d@@symDeR
2148 \let\@symDeB\d@@symDeB \let\@symDeA\d@@symDeA
2149 \let\left\eq@left \let\right\eq@right \global\lr@level\z@
2150 \global\eq@wdCond\z@ %BRM: new
2152 % If we have an embedded array environment (for example), we
2153 % don't want to have each math cell within the array resetting
2154 % \cs{lr@level} globally to 0\mdash not good!
2155 % And in general I think it is safe to say that whenever we have a
2156 % subordinate level of boxing we want to revert to a normal math setup.
2158 \everyhbox{\everyhbox\@emptytoks
2159 \let\display@setup\relax \textmath@setup \let\textmath@setup\relax
2161 \everyvbox{\everyvbox\@emptytoks
2162 \let\display@setup\relax \textmath@setup \let\textmath@setup\relax
2166 % The \cs{textmath@setup} function is needed for embedded inline
2167 % math inside text inside a display.
2169 % BRM: DS Experiment: Variant of \cs{display@setup} for use within
2170 % dseries environmnents
2172 \def\dseries@display@setup{%
2173 \medmuskip\Dmedmuskip \thickmuskip\Dthickmuskip
2176 % \let\@symRel\d@@symRel
2177 \let\@symBin\d@@symBin
2178 \let\m@DeL\d@@DeL \let\m@DeR\d@@DeR \let\m@DeB\d@@DeB
2180 \let\@symDeL\d@@symDeL \let\@symDeR\d@@symDeR
2181 \let\@symDeB\d@@symDeB \let\@symDeA\d@@symDeA
2182 \let\left\eq@left \let\right\eq@right \global\lr@level\z@
2183 \everyhbox{\everyhbox\@emptytoks
2184 \let\display@setup\relax \textmath@setup \let\textmath@setup\relax
2186 \everyvbox{\everyvbox\@emptytoks
2187 \let\display@setup\relax \textmath@setup \let\textmath@setup\relax
2194 \def\textmath@setup{%
2195 \let\m@Bin\m@@Bin \let\m@Rel\m@@Rel
2196 \let\@symRel\m@@symRel \let\@symBin\m@@symBin
2197 \let\m@DeL\m@@DeL \let\m@DeR\m@@DeR \let\m@DeB\m@@DeB
2199 \let\@symDeL\m@@symDeL \let\@symDeR\m@@symDeR
2200 \let\@symDeB\m@@symDeB \let\@symDeA\m@@symDeA
2201 \let\left\@@left \let\right\@@right
2208 % \begin{macro}{\if@display}
2209 % \begin{macro}{\everydisplay}
2210 % The test \cs{ifinner} is unreliable for distinguishing
2211 % whether we are in a displayed formula or an inline formula: any display
2212 % more complex than a simple one-line equation typically involves the use
2213 % of \verb"$" \cs{displaystyle} \dots \verb"$" instead of
2214 % \dbldollars \dots \dbldollars . So we provide a more reliable
2215 % test. But it might have been provided already by the
2216 % \pkg{amsmath} package.
2218 \@ifundefined{@displaytrue}{%
2219 \@xp\newif\csname if@display\endcsname
2220 \everydisplay\@xp{\the\everydisplay \@displaytrue}%
2225 % Is there any reason to maintain separate
2226 % \cs{everydisplay} and \cn{eqstyle}?
2237 % \section{The \env{dmath} and \env{dmath*} environments}
2239 % Options for the \env{dmath} and \env{dmath*}
2241 % \begin{literalcode}
2242 % \begin{dmath}[label={xyz}]
2245 \define@key{breqn}{label}{\def\next@label{\label{#1}}}
2246 \global\let\next@label\@empty
2248 % Allow a variant number.
2249 % \begin{literalcode}
2250 % \begin{dmath}[number={\nref{foo}\textprime}]
2253 \define@key{breqn}{number}{\def\eq@number{#1}%
2254 \let\@currentlabel\eq@number
2257 % \begin{literalcode}
2258 % \begin{dmath}[shiftnumber]
2259 % \begin{dmath}[holdnumber]
2261 % Holding or shifting the number.
2263 \define@key{breqn}{shiftnumber}{\let\eq@shiftnumber\@True}
2264 \define@key{breqn}{holdnumber}{\let\eq@holdnumber\@True}
2266 % \begin{literalcode}
2267 % \begin{dmath}[density={.5}]
2270 \define@key{breqn}{density}{\def\eq@density@factor{#1}}
2272 % \begin{literalcode}
2273 % \begin{dmath}[indentstep={1em}]
2275 % To change the amount of indent for post-initial lines. Note:
2276 % for lines that begin with a mathbin symbol there is a fixed amount of
2277 % indent already built in (\cs{eqbinoffset}) and it cannot be
2278 % reduced through this option. The indentstep amount is the indent
2279 % used for lines that begin with a mathrel symbol.
2281 \define@key{breqn}{indentstep}{\eqindentstep#1\relax}
2283 % \begin{literalcode}
2284 % \begin{dmath}[compact]
2285 % \begin{dmath}[compact=-2000]
2287 % To make mathrels stay inline to the extent possible, use the compact
2289 % Can give a numeric value in the range $-10000 \dots 10000$
2290 % to adjust the behavior.
2291 % $-10000$: always break at a rel symbol; $10000$: never
2292 % break at a rel symbol.
2294 \define@key{breqn}{compact}[-99]{\prerelpenalty=#1\relax}
2296 % \begin{literalcode}
2297 % \begin{dmath}[layout={S}]%
2299 % Specify a particular layout.
2300 % We take care to ensure that \cs{eq@layout} ends up containing
2301 % one and only one letter.
2303 \define@key{breqn}{layout}[?]{%
2304 \edef\eq@layout{\@car#1?\@nil}%
2307 % \begin{literalcode}
2308 % \begin{dmath}[spread={1pt}]
2310 % To change the interline spacing in a particular equation.
2312 \define@key{breqn}{spread}{%
2313 \addtolength\eqlinespacing{#1}%
2314 \addtolength\eqlineskip{#1}%
2315 \eqlineskiplimit\eqlineskip
2318 % To change the amount of space on the side for \dquoted{multline} layout.
2320 \define@key{breqn}{sidespace}{%
2321 \setlength\eq@given@sidespace{#1}%
2324 % \begin{literalcode}
2325 % \begin{dmath}[style={\small}]
2327 % The \opt{style} option is mainly intended for changing the
2328 % type size of an equation but as a matter of fact you could put arbitrary
2329 % \latex code here \mdash thus the option name is \quoted{style} rather
2330 % than just \quoted{typesize}. In order for this option to work when
2331 % setting options globally, we need to put the code in
2332 % \cs{eqstyle} rather than execute it directly.
2334 \define@key{breqn}{style}{\eqstyle\@xp{\the\eqstyle #1}}
2336 % \begin{literalcode}
2337 % \begin{dmath}[shortskiplimit={1em}]
2339 % If the line immediately preceding a display has length $l$, the
2340 % first line of the display is indented $i$, and a shortskip limit $s$
2341 % is set, then the spacing above the display is equal to
2342 % \cs{abovedisplayshortskip} if $l+s < i $ and \cs{abovedisplayskip}
2343 % otherwise. The default shortskip limit is 2\,em which is what \TeX\
2344 % hardcodes but this parameter overrides that.
2346 \define@key{breqn}{shortskiplimit}{\def\eq@shortskiplimit{#1}}
2347 \def\eq@shortskiplimit{2em}
2350 % \begin{literalcode}
2351 % \begin{dmath}[frame]
2353 % The \opt{frame} option merely puts a framebox around the body
2354 % of the equation. To change the thickness of the frame, give the
2355 % thickness as the argument of the option. For greater control, you
2356 % can change the appearance of the frame by redefining
2357 % \cs{eqframe}. It must be a command taking two arguments, the
2358 % width and height of the equation body. The top left corner of the
2359 % box produced by \cs{eqframe} will be pinned to the top-left corner
2360 % of the equation body.
2362 \define@key{breqn}{frame}[\fboxrule]{\def\eq@frame{T}%
2363 \dim@a#1\relax\edef\eq@framewd{\the\dim@a}%
2365 % Until such time as we provide a frame implementation that allows the
2366 % frame to stretch and shrink, we'd better remove any stretch/shrink from
2367 % the interline glue in this case.
2369 \freeze@glue\eqlinespacing \freeze@glue\eqlineskip
2371 \define@key{breqn}{fullframe}[]{\def\eq@frame{U}%
2372 \freeze@glue\eqlinespacing \freeze@glue\eqlineskip
2374 \def\eq@frame{F} % no frame
2375 \def\eq@framewd{\fboxrule}
2378 % \begin{literalcode}
2379 % \begin{dmath}[frame={width={2pt},color={blue},sep={2pt}}]
2381 % To change the space between the frame and the equation there is a
2384 \define@key{breqn}{framesep}[\fboxsep]{%
2385 \if\eq@frame F\def\eq@frame{T}\fi
2386 \dim@a#1\relax \edef\eq@framesep{\the\dim@a}%
2387 \freeze@glue\eqlinespacing \freeze@glue\eqlineskip
2389 \def\eq@framesep{\fboxsep}
2391 % \begin{literalcode}
2392 % \begin{dmath}[background={red}]
2394 % Foreground and background colors for the equation. By default
2395 % the background area that is colored is the size of the equation, plus
2396 % fboxsep. If you need anything fancier for the background, you'd
2397 % better do it by defining \cs{eqframe} in terms of
2398 % \cs{colorbox} or \cs{fcolorbox}.
2400 \define@key{breqn}{background}{\def\eq@background{#1}%
2401 \freeze@glue\eqlinespacing \freeze@glue\eqlineskip
2404 % \begin{literalcode}
2405 % \begin{dmath}[color={purple}]
2408 \define@key{breqn}{color}{\def\eq@foreground{#1}}
2410 % \begin{literalcode}
2411 % \begin{dmath}[center]
2412 % \begin{dmath}[nocenter]
2414 % The \opt{center} option means add leftskip stretch to make the
2415 % individual lines be centered; this is the default for
2418 \define@key{breqn}{center}[]{\let\eq@centerlines\@True}
2419 \define@key{breqn}{nocenter}[]{\let\eq@centerlines\@False}
2420 \let\eq@centerlines\@False
2422 % \begin{literalcode}
2423 % \begin{dgroup}[noalign]
2425 % Equation groups normally have alignment of the primary relation
2426 % symbols across the whole group. The \opt{noalign} option
2427 % switches that behavior.
2429 \define@key{breqn}{noalign}[]{\let\grp@aligned\@False}
2430 \let\grp@aligned\@True % default
2432 % \begin{literalcode}
2433 % \begin{dgroup}[breakdepth={2}]
2435 % Break depth of 2 means that breaks are allowed at mathbin symbols
2436 % inside two pairs of delimiters, but not three.
2438 \define@key{breqn}{breakdepth}{\eqbreakdepth#1\relax}
2440 % \begin{literalcode}
2441 % \begin{darray}[cols={lcrlcr}]
2443 % The \opt{cols} option only makes sense for the
2444 % \env{darray} environment but we liberally allow all the options to
2445 % be used with all the environments and just ignore any unsensible ones
2446 % that happen to come along.
2448 \define@key{breqn}{cols}{\global\let\@preamble\@empty
2449 \darray@mkpream#1\@percentchar
2456 % CLM works tolerably
2457 % \def\eqindent{C}\def\eqnumside{L}\def\eqnumplace{M}
2458 % CLT works tolerably
2459 % \def\eqindent{C}\def\eqnumside{L}\def\eqnumplace{T}
2461 % \def\eqindent{I}\def\eqnumside{L}\def\eqnumplace{M}\mathindent40\p@
2463 % \def\eqindent{I}\def\eqnumside{L}\def\eqnumplace{T}\mathindent40\p@
2464 % Indended w/left number
2465 % work ok if mathindent is larger than number width,
2466 % but then equations must fit into smaller space.
2467 % Is shiftnumber allowed to put eqn at left, instead of indent?
2469 % \def\eqindent{C}\def\eqnumside{R}\def\eqnumplace{M}
2471 % \def\eqindent{C}\def\eqnumside{R}\def\eqnumplace{B}
2473 % \def\eqindent{I}\def\eqnumside{R}\def\eqnumplace{M}\mathindent10\p@
2475 % \def\eqindent{I}\def\eqnumside{R}\def\eqnumplace{B}\mathindent10\p@
2478 % The main environments.
2480 %BRM: The following incorporates several changes:
2481 % 1) modifications supplied by MJD to fix the eaten \cs{paragraph} problem.
2482 % 2) Added \cs{display@setup} here, rather than globally.
2484 % \begin{macro}{\dmath}
2485 % \begin{macro}{\enddmath}
2486 % For the \env{dmath} environment we don't want the standard
2487 % optional arg processing because of the way it skips over whitespace,
2488 % including newline, while looking for the \verb"[" char; which is not good
2489 % for math material. So we call \cs{@optarg} instead.
2491 \newenvironment{dmath}{%
2492 \let\eq@hasNumber\@True \@optarg\@dmath{}}{}
2494 %<trace> \breqn@debugmsg{=== DMATH ==================================================}%
2495 \everydisplay\expandafter{\the\everydisplay \display@setup}%
2496 \if@noskipsec \leavevmode \fi
2497 \if@inlabel \leavevmode \global\@inlabelfalse \fi
2498 \if\eq@group\else\eq@prelim\fi
2499 \setkeys{breqn}{#1}%
2502 % The equation number might have been overridden in \verb|#1|.
2506 % Start up the displayed equation by reading the contents into a
2507 % box register. Enclose this phase in an extra group so that
2508 % modified \cs{hsize} and other params will be auto-restored
2516 % Before it finishes off the box holding the equation body,
2517 % \cs{enddmath} needs to look ahead for punctuation (and
2520 \def\enddmath#1{\check@punct@or@qed}
2522 \gdef\EQ@setwdL{}% Occasionally undefined ???
2527 % Measure (a copy of) the equation body to find the minimum width
2528 % required to get acceptable line breaks, how many lines will be required
2529 % at that width, and whether the equation number needs to be shifted to
2530 % avoid overlapping. This information will then be used by
2531 % \cs{eq@finish} to do the typesetting of the real equation body.
2535 % Piece together the equation from its constituents, recognizing
2536 % current constraints. If we are in an equation group, this might
2537 % just save the material on a stack for later processing.
2539 \if\eq@group \grp@push \else \eq@finish\fi
2545 % \begin{macro}{\dmath*}
2546 % \begin{macro}{\enddmath*}
2547 % Ah yes, now the lovely \env{dmath*} environment.
2549 \newenvironment{dmath*}{%
2550 \let\eq@hasNumber\@False \@optarg\@dmath{}%
2552 \@namedef{end@dmath*}{\end@dmath}
2553 \@namedef{enddmath*}#1{\check@punct@or@qed}
2559 % \begin{macro}{\eq@prelim}
2560 % If \cs{everypar} has a non-null value, it's probably
2561 % some code from \cs{@afterheading} that sets \cs{clubpenalty}
2562 % and\slash or removes the parindent box. Both of those actions
2563 % are irrelevant and interfering for our purposes and need to be deflected
2564 % for the time being.
2565 % If an equation appears at the very beginning of a list item
2566 % (possibly from a trivlist such as \env{proof}), we need to
2567 % trigger the item label.
2570 \if@inlabel \indent \par \fi
2571 \if@nobreak \global\@nobreakfalse \predisplaypenalty\@M \fi
2572 \everypar\@emptytoks
2574 % If for some reason \env{dmath} is called between paragraphs,
2575 % \cn{noindent} is better than \cn{leavevmode}, which would produce
2576 % an indent box and an empty line to hold it. If we are in a list
2577 % environment, \cn{par} is defined as \verb"{\@@par}" to preserve
2582 \par %% \eq@saveparinfo %% needs work
2583 \let\intertext\breqn@intertext
2587 % \begin{macro}{\breqn@parshape@warning}
2588 % Warning message extracted to a separate function to streamline the
2591 \def\breqn@parshape@warning{%
2592 \PackageWarning{breqn}{%
2593 Complex paragraph shape cannot be followed by this equation}%
2599 % \begin{macro}{\eq@prevshape}
2600 % Storage; see \cs{eq@saveparinfo}.
2602 \let\eq@prevshape\@empty
2607 % \begin{macro}{\eq@saveparinfo}
2608 % Save the number of lines and parshape info for the text preceding
2611 \def\eq@saveparinfo{%
2612 \count@\prevgraf \advance\count@-\thr@@ % for the null display
2613 \edef\eq@prevshape{\prevgraf\the\count@\space}%
2615 % case 0: no action required
2616 \or \edef\eq@prevshape{\eq@prevshape
2617 \parshape\@ne\displayindent\displaywidth\relax
2620 % Maybe best to set \cs{eq@prevshape} the same in the else case
2621 % also. Better than nothing.
2624 \breqn@parshape@warning
2631 % \begin{macro}{\eq@setnumber}
2632 % If the current equation number is not explicitly given, then
2633 % use an auto-generated number, unless the no-number switch has been
2634 % thrown (\env{dmath*}).
2635 % \cs{theequation} is the number form to be used for all equations,
2636 % \cs{eq@number} is the actual value for the current equation
2637 % (might be an exception to the usual sequence).
2642 \ifx\eq@number\@empty
2643 \stepcounter{equation}\let\eq@number\theequation
2647 % This sets up numbox, etc, even if unnumbered?????
2649 \ifx\eq@number\@empty
2652 % Put the number in a box so we can use its measurements in our
2653 % number-placement calculations. The extra braces around
2654 % \cs{eqnumform} make it possible for \cs{eqnumfont} to have
2655 % either an \cs{itshape} (recommended) or a \cs{textit}
2658 %<trace> \breqn@debugmsg{Number \eq@number}%
2659 \set@label{equation}\eq@number
2660 \global\sbox\EQ@numbox{%
2661 \next@label \global\let\next@label\@empty
2662 \eqnumcolor\eqnumsize\eqnumfont{\eqnumform{\eq@number}}%
2664 \global\eq@wdNum\wd\EQ@numbox\global\advance\eq@wdNum\eqnumsep
2665 % \let\eq@hasNumber\@True % locally true
2672 % \begin{macro}{\eq@finish}
2673 % The information available at this point from preliminary
2674 % measuring includes the number of lines required, the width of the
2675 % equation number, the total height of the equation body, and (most
2676 % important) the parshape spec that was used in determining height and
2679 % Invoke the equation formatter for the requested centering/indentation
2680 % having worked out the best parshape.
2681 % BRM: This portion is extensively refactored to get common operations
2682 % together (so corrections get consistently applied).
2684 % MH: I've destroyed Bruce's nice refactoring a bit to get the
2685 % abovedisplayskips correct for both groups of equations and single
2686 % \env{dmath} environments. I will have to redo that later.
2688 \newcount\eq@final@linecount
2689 \let\eq@GRP@first@dmath\@True
2692 %<trace> \breqn@debugmsg{Formatting equation}%
2693 %<trace> \debug@showmeasurements
2695 \freeze@glue\eqlinespacing \freeze@glue\eqlineskip
2697 % \eq@topspace{\vskip\parskip}% Set top spacing
2698 \csname eq@\eqindent @setsides\endcsname % Compute \leftskip,\rightskip
2699 \adjust@parshape\eq@parshape% Final adjustment of parshape for left|right skips
2701 % If we are in an a group of equations we don't want to calculate the
2702 % top space for the first one as that will be delayed until later when
2703 % the space for the group is calculated. However, we do need to store
2704 % the leftskip used here as that will be used later on for calculating
2708 \if\eq@GRP@first@dmath
2709 \global\let\eq@GRP@first@dmath\@False
2710 \xdef\dmath@first@leftskip{\leftskip=\the\leftskip\relax}%
2711 %<trace> \breqn@debugmsg{Stored\space\dmath@first@leftskip}
2713 \eq@topspace{\vskip\parskip}% Set top spacing
2716 \eq@topspace{\vskip\parskip}% Set top spacing
2718 %<trace> \debug@showformat
2720 % We now know the final line count of the display. If it is a
2721 % single-line display, we want to know as that greatly simplifies the
2722 % equation tag placement (until such a time where this algorithm has
2723 % been straightened out).
2725 \afterassignment\remove@to@nnil
2726 \eq@final@linecount=\expandafter\@gobble\eq@parshape\@nnil
2728 % Now, invoke the appropriate typesetter according to number placement
2732 \csname eq@typeset@\eqnumside Shifted\endcsname
2735 % If there is only one line and the tag doesn't have to be shifted, we
2736 % call a special procedure to put the tag correctly.
2738 \ifnum\eq@final@linecount=\@ne
2739 \csname eq@typeset@\eqnumside @single\endcsname
2741 \csname eq@typeset@\eqnumside\eqnumplace\endcsname
2745 \eq@typeset@Unnumbered
2754 % These are temporary until the tag position algorithm gets
2755 % rewritten. At least the tag is positioned correctly for single-line
2756 % displays. The horizontal frame position is not correct but the
2757 % problem lies elsewhere.
2759 \def\eq@typeset@L@single{%
2761 \eq@params\eq@parshape
2762 \nointerlineskip\noindent
2764 \rlap{\kern-\leftskip\box\EQ@numbox}%
2767 \rlap{\raise\eq@firstht\hbox to\z@{\eq@addframe\hss}}%
2769 \eq@dump@box\unhbox\EQ@box \@@par
2771 \def\eq@typeset@R@single{%
2773 \eq@params\eq@parshape
2774 \nointerlineskip\noindent
2778 \rlap{\raise\eq@firstht\hbox to\z@{\eq@addframe\hss}}%
2780 \rlap{\kern-\leftskip\kern\linewidth\kern-\wd\EQ@numbox\copy\EQ@numbox}%
2781 \eq@dump@box\unhbox\EQ@box
2788 % \section{Special processing for end-of-equation}
2790 % At the end of a displayed equation environment we need to peek ahead
2791 % for two things: following punction such as period or command that
2792 % should be pulled in for inclusion at the end of the equation; and
2793 % possibly also an \verb"\end{proof}" with an implied \dquoted{qed}
2794 % symbol that is traditionally included at the end of the display rather
2795 % than typeset on a separate line.
2796 % We could require that the users type \cs{qed} explicitly at the
2797 % end of the display when they want to have the display take notice of it.
2798 % But the reason for doing that would only be to save work for the
2799 % programmer; the most natural document markup would allow an inline
2800 % equation and a displayed equation at the end of a proof to differ only
2801 % in the environment name:
2802 % \begin{literalcode}
2803 % ... \begin{math} ... \end{math}.
2807 % \begin{literalcode}
2815 % The technical difficulties involved in supporting this markup within
2816 % \latex2e are, admittedly, nontrivial.
2817 % Nonetheless, let's see how far we can go.
2820 % The variations that we will support are only the most
2821 % straightforward ones:
2822 % \begin{literalcode}
2827 % \begin{literalcode}
2833 % If there is anything more complicated than a space after the
2834 % period we will not attempt to scan any further for a possible
2835 % \verb"\end{proof}".
2836 % This includes material such as:
2837 % \begin{literalcode}
2838 % \begin{figure}...\end{figure}%
2840 % \renewcommand{\foo}{...}
2843 % or even a blank line\mdash because in \latex a blank line is
2844 % equivalent to \cs{par} and the meaning of \cs{par} is
2845 % \dquoted{end-paragraph}; in my opinion if explicit end-of-paragraph
2846 % markup is given before the end of an element, it has to be respected,
2847 % and the preceding paragraph has to be fully finished off before
2848 % proceeding further, even inside an element like \dquoted{proof} whose
2849 % end-element formatting requires integration with the end of the
2851 % And \tex nically speaking, a \cs{par} token that comes from a
2852 % blank line and one that comes from the sequence of characters
2853 % \verb"\" \verb"p" \verb"a" \verb"r" are equally explicit.
2854 % I hope to add support for \cs{footnote} in the future, as it
2855 % seems to be a legitimate markup possibility in that context from a
2856 % purely logical point of view, but there are additional technical
2857 % complications if one wants to handle it in full generality
2864 % \begin{macro}{\peek@branch}
2866 % This is a generalized \dquoted{look at next token and choose some action
2867 % based on it} function.
2869 \def\peek@branch#1#2{%
2870 \let\peek@b#1\let\peek@space#2\futurelet\@let@token\peek@a
2872 \def\peek@skipping@spaces#1{\peek@branch#1\peek@skip@space}
2874 \ifx\@let@token\@sptoken \expandafter\peek@space
2875 \else \expandafter\peek@b\fi
2877 \lowercase{\def\peek@skip@space} {\futurelet\@let@token\peek@a}%
2883 % \begin{macro}{\check@punct}
2884 % \changes{v0.96a}{2007/12/17}{Insert \cs{finish@end} if no special
2886 % For this one we need to recognize and grab for inclusion any of the
2887 % following tokens: \verb",;.!?", both catcode 12 (standard \latex
2888 % value) and catcode 13 (as might hold when the Babel package is
2890 % We do not support a space preceding the punctuation since that would
2891 % be considered simply invalid markup if a display-math environment were
2892 % demoted to in-line math; and we want to keep their markup as parallel as
2894 % If punctuation does not follow, then the \cs{check@qed} branch
2895 % is not applicable.
2897 \def\check@punct{\futurelet\@let@token\check@punct@a}
2898 \def\check@punct@a{%
2900 \ifx\@let@token\@sptoken\@nx\finish@end
2901 \else\ifx\@let@token ,\@nx\check@qed
2902 \else\ifx\@let@token .\@nx\check@qed
2903 \else\check@punct@b % check the less common possibilities
2910 \ifx\@let@token ;\@nx\check@qed
2911 \else\ifx\@let@token ?\@nx\check@qed
2912 \else\ifx\@let@token !\@nx\check@qed
2914 \toks@c{\fi\fi\fi}% matching with \toks@a
2915 \catcode`\.=\active \catcode`\,=\active \catcode`\;=\active
2916 \catcode`\?=\active \catcode`\!=\active
2918 \else\ifx\@let@token ,\@nx\check@qed
2919 \else\ifx\@let@token .\@nx\check@qed
2920 \else\ifx\@let@token ;\@nx\check@qed
2921 \else\ifx\@let@token ?\@nx\check@qed
2922 \else\ifx\@let@token !\@nx\check@qed
2923 \else\@nx\finish@end
2926 \xdef\check@punct@b{%
2927 \the\toks@a\the\toks@b\the\toks@c
2933 \let\found@punct\@empty
2935 \gdef\found@punct{#1}%
2936 \peek@skipping@spaces\check@qed@a
2939 \ifx\end\@let@token \@xp\check@qed@b
2940 \else \@xp\finish@end
2944 % For each environment ENV that takes an implied qed at the end, the
2945 % control sequence ENVqed must be defined; and it must include suitable
2946 % code to yield the desired results in a displayed equation.
2948 \def\check@qed@b#1#2{%
2949 \@ifundefined{#2qed}{}{%
2950 \toks@\@xp{\found@punct\csname#2qed\endcsname}%
2951 \xdef\found@punct{\the\toks@}%
2961 % \begin{macro}{\latex@end}
2962 % \begin{macro}{\finish@end}
2963 % The lookahead for punctuation following a display requires
2964 % mucking about with the normal operation of \cn{end}. Although
2965 % this is not exactly something to be done lightly, on the other hand this
2966 % whole package is so over-the-top anyway, what's a little more
2967 % going to hurt? And rationalizing this aspect of
2968 % equation markup is a worthy cause. Here is the usual
2969 % definition of \cs{end}.
2970 % \begin{literalcode}
2972 % \csname end#1\endcsname \@checkend{#1}%
2973 % \expandafter\endgroup\if@endpe\@doendpe\fi
2974 % \if@ignore \global\@ignorefalse \ignorespaces \fi
2977 % We can improve the chances of this code surviving through future
2978 % minor changes in the fundamental definition of \cs{end} by taking a
2979 % little care in saving the original meaning.
2981 \def\@tempa#1\endcsname#2\@nil{\def\latex@end##1{#2}}
2982 \expandafter\@tempa\end{#1}\@nil
2983 \def\end#1{\csname end#1\endcsname \latex@end{#1}}%
2985 % Why don't we call \cs{CheckCommand} here? Because that
2986 % doesn't help end users much; it works better to use it during package
2987 % testing by the maintainer.
2990 % If a particular environment needs to call a different end action, the
2991 % end command of the environment should be defined to gobble two args and
2992 % then call a function like \cs{check@punct@or@qed}.
2994 \def\check@punct@or@qed#1{%
2995 \xdef\found@punct{\@empty}% BRM: punctuation was being remembered past this eqn.
2996 \def\finish@end{\csname end@#1\endcsname\latex@end{#1}}%
3005 % \begin{macro}{\eqpunct}
3006 % User-settable function for handling
3007 % the punctuation at the end of an equation. You could, for example,
3008 % define it to just discard the punctuation.
3010 \newcommand\eqpunct[1]{\thinspace#1}
3016 % \begin{macro}{\set@label}
3017 % \cs{set@label} just sets \cs{@currentlabel} but it
3018 % takes the counter as an argument, in the hope that \latex will some
3019 % day provide an improved labeling system that includes type info on the
3022 \providecommand\set@label[2]{\protected@edef\@currentlabel{#2}}
3028 % \begin{macro}{\eq@topspace}
3029 % \begin{macro}{\eq@botspace}
3030 % The action of \cs{eq@topspace} is complicated by the
3031 % need to test whether the \quoted{short} versions of the display skips
3032 % should be used. This can be done only after the final parshape
3033 % and indent have been determined, so the calls of this function are
3034 % buried relatively deeply in the code by comparison to the calls of
3035 % \cs{eq@botspace}. This also allows us to optimize
3036 % slightly by setting the above-skip with \cs{parskip} instead of
3037 % \cs{vskip}. \verb|#1| is either \cs{noindent} or
3038 % \verb"\vskip\parskip".
3040 % BRM: Hmm; we need to do *@setspace BEFORE this for small skips to work!
3042 \def\eq@topspace#1{%
3044 \global\let\EQ@shortskips\@False
3046 % If we are in \env{dgroup} or \env{dgroup*} and not before the top
3047 % one, we just insert \cs{intereqskip}. Otherwise we must check for
3050 \if\@And{\eq@group}{\@Not\eq@GRP@first@dmath}%
3051 %<trace>\breqn@debugmsg{Between lines}%
3052 \parskip\intereqskip \penalty\intereqpenalty
3053 %<trace>\breqn@debugmsg{parskip=\the\parskip}%
3057 \parskip\abovedisplayshortskip
3058 \aftergroup\belowdisplayskip\aftergroup\belowdisplayshortskip
3060 % BRM: Not exactly \TeX's approach, but seems right\ldots
3062 \ifdim\predisplaysize>\z@\nointerlineskip\fi
3064 \parskip\abovedisplayskip
3069 \addtolength\parskip{\eq@framesep+\eq@framewd}%
3072 \breqn@debugmsg{Topspace: \theb@@le\EQ@shortskips, \parskip=\the\parskip,
3073 \predisplaysize=\the\predisplaysize}%
3079 % \begin{macro}{\eq@check@shortskip}
3080 % \changes{v0.96a}{2007/12/17}{Insert \cs{finish@end} if no special
3082 % \changes{v0.97a}{2007/12/22}{Use design parameter and fix
3083 % shortskips properly.}
3085 \def\eq@check@shortskip {%
3086 \global\let\EQ@shortskips\@False
3087 \setlength\dim@a{\abovedisplayskip+\ht\EQ@numbox}%
3089 % Here we work around the hardwired standard TeX value and use the
3090 % designer parameter instead.
3092 \ifdim\leftskip<\predisplaysize
3095 % If the display was preceded by a blank line, \cs{predisplaysize} is
3096 % $-\cs{maxdimen}$ and so we should insert a fairly large skip to
3097 % separate paragraphs, i.e., no short skip. Perhaps this should be a
3098 % third parameter \cs{abovedisplayparskip}.
3100 \ifdim -\maxdimen=\predisplaysize
3103 \global\let\EQ@shortskips\@True
3108 \ifdim\dim@a<\eq@firstht
3109 \global\let\EQ@shortskips\@True
3112 \setlength\dim@b{\eq@vspan/2}%
3114 \global\let\EQ@shortskips\@True
3125 % At the end of an equation, need to put in a pagebreak penalty
3126 % and some vertical space. Also set some flags to remove parindent
3127 % and extra word space if the current paragraph text continues without an
3128 % intervening \cs{par}.
3131 \penalty\postdisplaypenalty
3133 % Earlier calculations will have set \cs{belowdisplayskip} locally
3134 % to \cs{belowdisplayshortskip} if applicable. So we can just use
3139 \addtolength\belowdisplayskip{\eq@framesep+\eq@framewd}%
3141 \vskip\belowdisplayskip
3142 \@endpetrue % kill parindent if current paragraph continues
3143 \global\@ignoretrue % ignore following spaces
3151 % \begin{macro}{\eq@resume@parshape}
3152 % This should calculate the total height of the equation,
3153 % including space above and below, and set prevgraf to the number it would
3154 % be if that height were taken up by normally-spaced normal-height
3155 % lines. We also need to restore parshape if it had a non-null
3156 % value before the equation. Not implemented yet.
3158 \def\eq@resume@parshape{}
3165 % \section{Preprocessing the equation body}
3166 % \begin{macro}{\eq@startup}
3167 % Here is the function that initially collects the equation
3168 % material in a box.
3173 \global\let\EQ@hasLHS\@False
3174 \setbox\z@\vbox\bgroup
3175 \noindent \@@math \displaystyle
3180 % This setup defines the environment for the first typesetting
3181 % pass, note the \cs{hsize} value for example.
3184 \everymath\everydisplay
3185 %\let\@newline\eq@newline % future possibility?
3187 \let\insert\eq@insert \let\mark\eq@mark \let\vadjust\eq@vadjust
3188 \hsize\maxdimen \pretolerance\@M
3190 % Here it is better not to use \cs{@flushglue} (0pt
3191 % plus1fil) for \cs{rightskip}, or else a negative penalty
3192 % (such as $-99$ for \cs{prerelpenalty}) will tempt
3193 % \tex to use more line breaks than necessary in the first typesetting
3194 % pass. Ideal values for \cs{rightskip} and
3195 % \cs{linepenalty} are unclear to me, but they are rather sensitively
3196 % interdependent. Choice of 10000 pt for rightskip is derived by
3197 % saying, let's use a value smaller than 1 fil and smaller than
3198 % \cs{hsize}, but more than half of \cs{hsize} so that if a line
3199 % is nearly empty, the glue stretch factor will always be less than 2.0
3200 % and so the badness will be less than 100 and so \tex will not issue
3204 \rightskip\z@\@plus\@M\p@ \leftskip\z@skip \parfillskip\z@skip
3205 \clubpenalty\@ne \widowpenalty\z@ \interlinepenalty\z@
3207 % After a relation symbol is discovered, binop symbols should start
3208 % including a special offset space.
3209 % But until then \cs{EQ@prebin@space} is a no-op.
3211 \global\let\EQ@prebin@space\relax
3213 % Set binoppenalty and relpenalty high to prohibit line breaks
3214 % after mathbins and mathrels. As a matter of fact, the penalties are
3215 % then omitted by \tex , since bare glue without a penalty is
3216 % \emph{not} a valid breakpoint if it occurs within
3217 % mathon\ndash mathoff items.
3219 \binoppenalty\@M \relpenalty\@M
3227 % The contents of an equation after the initial typesetting pass,
3228 % as shown by \cs{showlists}. This is the material on which the
3229 % \cs{eq@repack} function operates. The equation was
3230 % \begin{literalcode}
3231 % a=b +\left(\frac{c\sp 2}{2} -d\right) +(e -f) +g
3233 % . The contents are shown in four parts in this figure and the next
3234 % three. The first part contains two line boxes, one for the mathon
3235 % node and one for the LHS.
3236 % \begin{literalcode}
3237 % \hbox(0.0+0.0)x16383.99998, glue set 1.6384
3240 % .\glue(\rightskip) 0.0 plus 10000.0
3242 % \glue(\baselineskip) 7.69446
3243 % \hbox(4.30554+0.0)x16383.99998, glue set 1.63759
3244 % .\OML/cmm/m/it/10 a
3245 % .\glue 2.77771 minus 1.11108
3247 % .\glue(\rightskip) 0.0 plus 10000.0
3249 % \glue(\lineskip) 1.0
3252 % \caption{Preliminary equation contents, part 1}
3254 % \begin{figure}\centering
3255 % This is the first part of the RHS, up to the
3256 % \cs{right}, where a line break has been forced so that we can break
3257 % open the left-right box.
3258 % \begin{literalcode}
3261 % \glue(\lineskip) 1.0
3262 % \hbox(14.9051+9.50012)x16383.99998, glue set 1.63107
3264 % .\glue(\thickmuskip) 2.77771 minus 1.11108
3265 % .\OT1/cmr/m/n/10 =
3266 % .\glue(\thickmuskip) 2.77771 minus 1.11108
3267 % .\OML/cmm/m/it/10 b
3273 % .\glue(\medmuskip) 2.22217 minus 1.66663
3274 % .\OT1/cmr/m/n/10 +
3275 % .\glue(\medmuskip) 2.22217 minus 1.66663
3276 % .\hbox(14.9051+9.50012)x43.36298
3277 % ..\hbox(0.39998+23.60025)x7.36115, shifted -14.10013
3278 % ...\OMX/cmex/m/n/5 \hat \hat R
3279 % ..\hbox(14.9051+6.85951)x11.21368
3280 % ...\hbox(14.9051+6.85951)x11.21368
3281 % ... [fraction contents, elided]
3287 % ..\glue(\medmuskip) 2.22217 minus 1.66663
3288 % ..\OMS/cmsy/m/n/10 \hat \hat @
3289 % ..\glue(\medmuskip) 2.22217 minus 1.66663
3290 % ..\OML/cmm/m/it/10 d
3291 % ..\hbox(0.39998+23.60025)x7.36115, shifted -14.10013
3292 % ...\OMX/cmex/m/n/5 \hat \hat S
3294 % .\glue(\rightskip) 0.0 plus 10000.0
3296 % \glue(\lineskip) 1.0
3299 % \caption{Preliminary equation contents, part 2}
3304 % This is the remainder of the RHS after the post-\cs{right}
3306 % \begin{literalcode}
3309 % \glue(\lineskip) 1.0
3310 % \hbox(7.5+2.5)x16383.99998, glue set 1.63239
3316 % .\glue(\medmuskip) 2.22217 minus 1.66663
3317 % .\OT1/cmr/m/n/10 +
3318 % .\glue(\medmuskip) 2.22217 minus 1.66663
3319 % .\OT1/cmr/m/n/10 (
3320 % .\OML/cmm/m/it/10 e
3326 % .\glue(\medmuskip) 2.22217 minus 1.66663
3327 % .\OMS/cmsy/m/n/10 \hat \hat @
3328 % .\glue(\medmuskip) 2.22217 minus 1.66663
3329 % .\OML/cmm/m/it/10 f
3331 % .\OT1/cmr/m/n/10 )
3337 % .\glue(\medmuskip) 2.22217 minus 1.66663
3338 % .\OT1/cmr/m/n/10 +
3339 % .\glue(\medmuskip) 2.22217 minus 1.66663
3340 % .\OML/cmm/m/it/10 g
3343 % .\glue(\rightskip) 0.0 plus 10000.0
3344 % \glue(\baselineskip) 9.5
3347 % \caption{Preliminary equation contents, part 3}
3352 % This is the mathoff fragment.
3353 % \begin{literalcode}
3355 % \glue(\baselineskip) 9.5
3356 % \hbox(0.0+0.0)x16383.99998, glue set 1.6384
3359 % .\glue(\parfillskip) 0.0
3360 % .\glue(\rightskip) 0.0 plus 10000.0
3362 % \caption{Preliminary equation contents, part 4}
3365 % \begin{macro}{\eq@capture}
3366 % \begin{macro}{\eq@punct}
3367 % If an equation ends with a \cs{right} delim, the last thing
3368 % on the math list will be a force-break penalty. Then don't
3369 % redundantly add another forcing penalty. (question: when does a
3370 % penalty after a linebreak not disappear? Answer: when you have
3371 % two forced break penalties in a row). Ending punctuation, if
3372 % any, goes into the last box with the mathoff kern. If the math list
3373 % ends with a slanted letter, then there will be an italic correction
3374 % added after it by \tex . Should we remove it? I guess
3378 % \subsection{Capturing the equation}
3380 % BRM: There's a problem here (or with \cs{ss@scan}). If the LHS has
3381 % \cs{left} \cs{right} pairs, \ss@scan gets involved. It seems to produce
3382 % a separate box marked w/\cs{penalty} 3. But it appears that \cs{eq@repack}
3383 % is only expecting a single box for the LHS; when it measures that
3384 % box it's missing the (typically larger) bracketted section,
3385 % so the LHS is measured => 0pt (or very small).
3386 % I'm not entirely clear what Michael had in mind for this case;
3387 % whether it's an oversight, or whether I've introduced some other bug.
3388 % At any rate, my solution is to measure the RHS (accumulated in \cs{EQ@box}),
3389 % at the time of the relation, and subtract that from the total size.
3391 \newdimen\eq@wdR\eq@wdR\z@%BRM
3393 \ifnum\lastpenalty>-\@M \penalty-\@Mi \fi
3395 % We want to keep the mathoff kern from vanishing at the line break,
3396 % so that we can reuse it later.
3398 \keep@glue\@@endmath
3403 % First snip the last box, which contains the mathoff node, and put it
3404 % into \cs{EQ@box}. Then when we call \cs{eq@repack} it
3405 % will recurse properly.
3408 \global\setbox\EQ@box\hbox{\unhbox\tw@\unskip\unskip\unpenalty}%
3410 \global\setbox\EQ@copy\copy\EQ@box
3411 %% \global\setbox\EQ@vimcopy\copy\EQ@vimbox
3413 %\batchmode\showboxbreadth\maxdimen\showboxdepth99\showlists\errorstopmode
3414 \eq@wdR\z@%BRM: eq@wdL patch
3415 \eq@repack % recursive
3417 % Finally, add the mathon item to \cs{EQ@box} and \cs{EQ@copy}.
3420 \global\setbox\EQ@box\hbox{\unhcopy\tw@\unskip\unpenalty \unhbox\EQ@box}%
3421 \global\setbox\EQ@copy\hbox{\unhbox\tw@\unskip\unpenalty \unhbox\EQ@copy}%
3422 %\batchmode\showbox\EQ@copy \showthe\eq@wdL\errorstopmode
3423 \ifdim\eq@wdR>\z@% BRM: eq@wdL patch
3424 \setlength\dim@a{\wd\EQ@box-\eq@wdR
3425 % Apparently missing a \thickmuskip = 5mu = 5/18em=0.27777777777.. ?
3426 + 0.2777777777777em}% FUDGE??!?!?!
3427 \ifdim\dim@a>\eq@wdL
3429 \breqn@debugmsg{Correcting LHS from \the\eq@wdL\space to
3430 \the\dim@a = \the\wd\EQ@box - \the\eq@wdR}%
3433 \xdef\EQ@setwdL{\eq@wdL\the\eq@wdL\relax}%
3437 \breqn@debugmsg{Capture: total length=\the\wd\EQ@box \MessageBreak
3438 ==== has LHS=\theb@@le\EQ@hasLHS, \eq@wdL=\the\eq@wdL, \eq@wdR=\the\eq@wdR,
3440 ==== \eq@wdCond=\the\eq@wdCond}%
3442 \egroup % end vbox started earlier
3444 %\debugwr{EQ@box}\debug@box\EQ@box
3445 %\debugwr{EQ@copy}\debug@box\EQ@copy
3449 % Now we have two copies of the equation, one in \cs{EQ@box},
3450 % and one in \cs{EQ@copy} with inconvenient stuff like inserts and
3453 % \cs{eq@addpunct} is for tacking on text punctuation at the end
3454 % of a display, if any was captured by the \quoted{gp} lookahead.
3457 \ifx\found@punct\@empty
3458 \else \eqpunct{\found@punct}%
3460 % BRM: Added; the punctuation kept getting carried to following environs
3461 \xdef\found@punct{\@empty}%
3465 % Needed for the \env{dseries} environment, among other things.
3467 \global\let\EQ@afterspace\@empty
3473 % \begin{macro}{\eq@repack}
3474 % The \cs{eq@repack} function looks at the information at hand
3475 % and proceeds accordingly.
3477 % TeX Note: this scans BACKWARDS from the end of the math.
3480 % A previous penalty of 3 on the vertical list means that we need
3481 % to break open a left-right box.
3484 % case 0: normal case
3486 \eq@repacka\EQ@copy \eq@repacka\EQ@box
3488 \or % case 1: finished recursing
3490 % Grab the mathon object since we need it to inhibit line breaking at
3491 % bare glue nodes later.
3495 \eq@repacka\EQ@copy \eq@repacka\EQ@box
3497 \or % case 2: save box width = LHS width
3499 % Don't need to set \cs{EQ@hasLHS} here because it was set earlier
3504 \setbox\z@\copy\tw@ \setbox\z@\hbox{\unhbox\z@\unskip\unpenalty}%
3505 \addtolength\eq@wdL{\wd\z@}
3506 \setlength\eq@wdR{\wd\EQ@box}% BRM: eq@wdL patch
3507 \xdef\EQ@setwdL{\eq@wdL\the\eq@wdL\relax}%
3509 % At this point, box 2 typically ends with
3510 % \begin{literalcode}
3512 % .\glue 2.77771 plus 2.77771
3514 % .\glue(\rightskip) 0.0 plus 10000.0
3516 % and we want to ensure that the thickmuskip glue gets removed.
3517 % And we now arrange for \cs{EQ@copy} and \cs{EQ@box} to
3518 % keep the LHS in a separate subbox; this is so that we can introduce a
3519 % different penalty before the first relation symbol if necessary,
3520 % depending on the layout decisions that are made later.
3522 \global\setbox\EQ@copy\hbox{%
3523 \hbox{\unhcopy\tw@\unskip\unpenalty\unskip}%
3526 \global\setbox\EQ@box\hbox{%
3527 \hbox{\unhbox\tw@\unskip\unpenalty\unskip}%
3531 \or % case 3: unpack left-right box
3537 \eq@repack % RECURSE
3540 % Error message extracted to streamline calling function.
3542 \def\breqn@repack@err{%
3543 \PackageError{breqn}{eq@repack penalty neq 0,1,2,3}\relax
3549 % \begin{macro}{\eq@repacka}
3550 % We need to transfer each line into two separate boxes, one
3551 % containing everything and one that omits stuff like \cs{insert}s
3552 % that would interfere with measuring.
3555 \global\setbox#1\hbox{\unhcopy\tw@ \unskip
3556 \count@-\lastpenalty
3557 \ifnum\count@<\@M \else \advance\count@-\@M \fi
3560 % If creating the measure copy, ignore all cases above case 3 by
3561 % folding them into case 1.
3563 \ifx\EQ@copy#1\ifnum\count@>\thr@@ \count@\@ne\fi\fi
3565 % case 0, normal line break
3566 \penalty-\@M % put back the linebreak penalty
3567 \or % case 1, do nothing (end of equation)
3569 \or % case 2, no-op (obsolete case)
3570 \or % case 3, transfer vspace and/or penalty
3571 \ifx#1\EQ@box \eq@revspace \else \eq@revspaceb \fi
3572 \or % case 4, put back an insert
3574 \or % case 5, put back a mark
3576 \or % case 6, put back a vadjust
3578 \else % some other break penalty
3587 % \begin{macro}{\eq@nulldisplay}
3588 % Throw in a null display in order to get predisplaysize \etc .
3589 % My original approach here was to start the null display, then measure
3590 % the equation, and set a phantom of the equation's first line before
3591 % ending the null display. That would allow finding out if \tex used
3592 % the short displayskips instead of the normal ones. But because of
3593 % some complications with grouping and the desirability of omitting
3594 % unnecessary invisible material on the vertical list, it seems better to
3595 % just collect information about the display (getting \cs{prevdepth}
3596 % requires \cs{halign}) and manually perform our own version of
3597 % \TeX's shortskip calculations. This approach also gives greater
3598 % control, \eg , the threshold amount of horizontal space between
3599 % predisplaysize and the equation's left edge that determines when the
3600 % short skips kick in becomes a designer-settable parameter rather than
3601 % hardwired into \TeX .
3603 \def\eq@nulldisplay{%
3604 \begingroup \frozen@everydisplay\@emptytoks
3606 \predisplaypenalty\@M \postdisplaypenalty\@M
3607 \abovedisplayskip\z@skip \abovedisplayshortskip\z@skip
3608 \belowdisplayskip\z@skip \belowdisplayshortskip\z@skip
3609 \xdef\EQ@displayinfo{%
3610 \prevgraf\the\prevgraf \predisplaysize\the\predisplaysize
3611 \displaywidth\the\displaywidth \displayindent\the\displayindent
3612 \listwidth\the\linewidth
3614 % Not sure how best to test whether leftmargin should be
3615 % added. Let's do this for now [mjd,1997/10/08].
3617 \ifdim\displayindent>\z@
3618 \advance\listwidth\the\leftmargin
3619 \advance\listwidth\the\rightmargin
3623 % An \cs{halign} containing only one \cs{cr} (for the
3624 % preamble) puts no box on the vertical list, which means that no
3625 % \cs{baselineskip} will be added (so we didn't need to set it to
3626 % zero) and the previous value of prevdepth carries through. Those
3627 % properties do not hold for an empty simple equation without
3640 % \begin{macro}{\eq@newline}
3641 % \begin{macro}{\eq@newlinea}
3642 % \begin{macro}{\eq@newlineb}
3643 % Here we use \cs{@ifnext} so that in a sequence like
3644 % \begin{literalcode}
3648 % \latex does not attempt to interpret the \verb"[a,b]" as a
3649 % vertical space amount. We would have used \cs{eq@break} in the
3650 % definition of \cs{eq@newlineb} except that it puts in a
3651 % \cs{keep@glue} object which is not such a good idea if a mathbin
3652 % symbol follows \mdash the indent of the mathbin will be wrong because
3653 % the leading negative glue will not disappear as it should at the line
3657 \@ifstar{\eq@newlinea\@M}{\eq@newlinea\eqinterlinepenalty}}
3658 \def\eq@newlinea#1{%
3659 \@ifnext[{\eq@newlineb{#1}}{\eq@newlineb{#1}[\maxdimen]}}
3660 \def\eq@newlineb#1[#2]{\penalty-\@M}
3667 % \begin{macro}{\eq@revspace}
3668 % \begin{macro}{\eq@revspaceb}
3669 % When \cs{eq@revspace} (re-vspace) is called, we are the
3670 % end of an equation line; we need to remove the existing penalty of
3671 % $-10002$ in order to put a vadjust object in front of it, then put
3672 % back the penalty so that the line break will still take place in the
3676 \global\setbox\EQ@vimbox\vbox{\unvbox\EQ@vimbox
3678 \global\setbox\@ne\lastbox}%
3679 \@@vadjust{\unvbox\@ne}%
3683 % The b version is used for the \cs{EQ@copy} box.
3686 \global\setbox\EQ@vimcopy\vbox{\unvbox\EQ@vimcopy
3688 \global\setbox\@ne\lastbox}%
3689 \@@vadjust{\unvbox\@ne}%
3697 % \begin{macro}{\eq@break}
3698 % The function \cs{eq@break} does a preliminary linebreak with
3701 \def\eq@break#1{\penalty-1000#1 \keep@glue}
3708 % \section{Choosing optimal line breaks}
3709 % The question of what line width to use when breaking an
3710 % equation into several lines is best examined in the light of an extreme
3711 % example. Suppose we have a two-column layout and a displayed
3712 % equation falls inside a second-level list with nonzero leftmargin and
3713 % rightmargin. Then we want to try in succession a number of
3714 % different possibilities. In each case if the next possibility is
3715 % no wider than the previous one, skip ahead to the one after.
3717 % \item First try linewidth(2), the linewidth for the current
3721 % \item If we cannot find adequate linebreaks at that width, next try
3722 % listwidth(2), the sum of leftmargin, linewidth, and rightmargin for
3726 % \item If we cannot find linebreaks at that width, next try linewidth
3727 % (1) (skipping this step if it is no larger then
3731 % \item If we cannot find linebreaks at that width, next try
3735 % \item If we cannot find linebreaks at that width, next try column
3739 % \item If we cannot find linebreaks at that width, next try text
3743 % \item If we cannot find linebreaks at that width, next try equation
3744 % width, if it exceeds text width (\ie , if the style allows equations
3745 % to extend into the margins).
3754 % \caption{first-approximation parshape for equations}\label{f:parshape-1}
3757 % At any given line width, we run through a series of parshape
3758 % trials and, essentially, use the first one that gives decent line
3760 % But the process is a bit more complicated in fact.
3761 % In order to do a really good job of setting up the parshapes, we
3762 % need to know how many lines the equation will require.
3763 % And of course the number of lines needed depends on the parshape!
3764 % So as our very first trial we run a simple first-approximation
3765 % parshape (Figure~\vref{f:parshape-1}) whose
3766 % main purpose is to get an estimate on the number of lines that will be
3767 % needed; it chooses a uniform indent for all lines after the first one
3768 % and does not take any account of the equation number.
3769 % A substantial majority of equations only require one line anyway,
3770 % and for them this first trial will succeed.
3771 % In the one-line case if there is an equation number and it doesn't
3772 % fit on the same line as the equation body, we don't go on to other
3773 % trials because breaking up the equation body will not gain us
3774 % anything\mdash we know that we'll have to use two lines in any case
3775 % \mdash so we might as well keep the equation body together on one line
3776 % and shift the number to a separate line.
3778 % If we learn from the first trial that the equation body
3779 % requires more than one line, the next parshape trial involves adjusting
3780 % the previous parshape to leave room for the equation number, if
3781 % present. If no number is present, again no further trials are
3784 % Some remarks about parshape handling. The \tex
3785 % primitive doesn't store the line specs anywhere, \verb"\the\parshape"
3786 % only returns the number of line specs. This makes it well nigh
3787 % impossible for different packages that use \cs{parshape} to work
3788 % together. Not that it would be terribly easy for the package
3789 % authors to make inter-package collaboration work, if it were
3790 % possible. If we optimistically conjecture that
3791 % someone some day may take on such a task, then the thing to do,
3792 % obviously, is provide a parshape interface that includes a record of all
3793 % the line specs. For that we designate a macro \cs{@parshape}
3794 % which includes not only the line specs, but also the line count and even
3795 % the leading \cs{parshape} token.
3796 % This allows it to be directly executed without an auxiliary if-empty
3797 % test. It should include a trailing \cs{relax} when it has a
3800 \let\@parshape\@empty
3804 % The function \cs{eq@measure} runs line-breaking trials
3805 % on the copy of the equation body that is stored in the box register
3806 % \cs{EQ@copy}, trying various possible layouts in order of
3807 % preference until we get successful line breaks, where \quoted{successful}
3808 % means there were no overfull lines. The result of the trials is,
3809 % first, a parshape spec that can be used for typesetting the real
3810 % equation body in \cs{EQ@box}, and second, some information that
3811 % depends on the line breaks such as the depth of the last line, the
3812 % height of the first line, and positioning information for the equation
3813 % number. The two main variables in the equation layout are the line
3814 % width and the placement of the equation number, if one is present.
3817 % \begin{macro}{\eq@measure}
3818 % Run linebreak trials on the equation contents and measure the
3823 % If an override value is given for indentstep in the env options, use
3826 \ifdim\eq@indentstep=\maxdimen \eq@indentstep\eqindentstep \fi
3828 % If \cs{eq@linewidth} is nonzero at this point, it means that
3829 % the user specified a particular target width for this equation.
3830 % In that case we override the normal list of trial widths.
3832 \ifdim\eq@linewidth=\z@ \else \edef\eq@linewidths{{\the\eq@linewidth}}\fi
3833 \begingroup \eq@params
3836 % Even if \cs{hfuzz} is greater than zero a box whose contents
3837 % exceed the target width by less then hfuzz still has a reported badness
3838 % value of 1000000 (infinitely bad). Because we use inf-bad
3839 % to test whether a particular trial succeeds or fails, we want to make
3840 % such boxes return a smaller badness. To this end we include an
3841 % \cs{hfuzz} allowance in \cs{rightskip}. In fact,
3842 % \cs{eq@params} ensures that \cs{hfuzz} for equations is at
3845 \rightskip\z@\@plus\columnwidth\@minus\hfuzz
3847 \global\EQ@continue{\eq@trial}%
3848 \eq@trial % uses \eq@linewidths
3849 \eq@failout % will be a no-op if the trial succeeded
3852 % \quoted{local} parameter settings are passed outside the endgroup through
3861 \def\debug@showmeasurements{%
3862 \breqn@debugmsg{=> \number\eq@lines\space lines}%
3864 \def\@elt##1X##2{\MessageBreak==== \space\space##1/##2}%
3866 \breqn@debugmsg{=> trial info:\eq@measurements}%
3867 \breqn@debugmsg{=> bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness}%
3868 \let\@elt\relax \let\@endelt\relax
3871 \def\debug@showmeasurements{%
3873 \def\@elt##1X##2{\MessageBreak==== ##1/##2}%
3875 \breqn@debugmsg{===> Measurements: \number\eq@lines\space lines
3878 ==== bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness
3880 ==== \leftskip=\the\leftskip, \rightskip=\the\rightskip}%
3886 % Layout Trials Driver
3887 % Basically, trying different sequences of parshapes.
3890 % \begin{macro}{\EQ@trial}
3893 \let\EQ@trial\@empty
3898 % \begin{macro}{\EQ@continue}
3899 % This is a token register used to carry trial info past a
3900 % group boundary with only one global assignment.
3902 \newtoks\EQ@continue
3907 % \begin{macro}{\EQ@widths}
3908 % This is used for storing the actual line-width info of the equation
3909 % contents after breaking.
3911 \let\EQ@widths\@empty
3914 % \begin{macro}{\EQ@fallback}
3916 \let\EQ@fallback\@empty
3919 % \begin{macro}{\eq@linewidths}
3920 % This is the list of target widths for line breaking.
3922 %========================================
3923 % BRM: Odd; I don't think I've seen this use anything but \cs{displaywidth}...
3925 \def\eq@linewidths{\displaywidth\linewidth\columnwidth}
3930 % \begin{macro}{\eq@trial}
3932 % The \cs{eq@trial} function tries each candidate
3933 % line width in \cs{eq@linewidths} until an equation layout is found
3934 % that yields satisfactory line breaks.
3937 \ifx\@empty\eq@linewidths
3938 \global\EQ@continue{}%
3940 \iffalse{\fi \@xp\eq@trial@a \eq@linewidths}%
3948 % \begin{macro}{\eq@trial@a}
3949 % The \cs{eq@trial@a} function reads the leading line
3950 % width from \cs{eq@linewidths}; if the new line width is greater
3951 % than the previous one, start running trials with it; otherwise do
3953 % Finally, run a peculiar \cs{edef} that leaves
3954 % \cs{eq@linewidths} redefined to be the tail of the list.
3955 % If we succeed in finding satisfactory line breaks
3956 % for the equation, we will reset \cs{EQ@continue} in such a
3957 % way that it will terminate the current trials.
3958 % An obvious branch here would be to check whether the width of
3959 % \cs{EQ@copy} is less than \cs{eq@linewidth} and go immediately
3960 % to the one-line case if so.
3961 % However, if the equation contains more than one RHS, by
3962 % default each additional RHS starts on a new line\mdash \ie , we want
3963 % the ladder layout anyway.
3964 % So we choose the initial trial on an assumption of multiple lines
3965 % and leave the one-line case to fall out naturally at a later point.
3969 \if T\eq@frame \eq@frame@adjust\dim@c \fi
3970 \ifdim\dim@c>\eq@linewidth
3972 %<trace> \breqn@debugmsg{Choose Shape for width(#1)=\the\eq@linewidth}%
3973 \let\eq@trial@b\eq@trial@d
3974 \csname eq@try@layout@\eq@layout\endcsname
3976 %<trace> \breqn@debugmsg{Next width (#1) is shorter; skip it}%
3978 \edef\eq@linewidths{\iffalse}\fi
3980 \def\eq@frame@adjust#1{%
3981 %\addtolength#1{-2\eq@framewd-2\eq@framesep}%
3982 \dim@a\eq@framewd \advance\dim@a\eq@framesep
3987 %========================================
3988 % Note curious control structure.
3989 % Try to understand interaction of \cs{EQ@fallback}, \cs{EQ@continue},
3992 \def\eq@trial@succeed{%
3993 \aftergroup\@gobbletwo % cancel the \EQ@fallback code; see \eq@trial@c (?)
3994 \global\EQ@continue{\eq@trial@done}%
3997 % \begin{macro}{\eq@trial@done}
4000 \def\eq@trial@done{%
4001 %<trace> \breqn@debugmsg{End trial: Success!}%
4002 \let\eq@failout\relax
4007 % \begin{macro}{\eq@trial@init}
4008 % This is called from \cs{eq@trial@b} to initialize or
4009 % re-initialize certain variables as needed when running one or more
4010 % trials at a given line width.
4011 % By default assume success, skip the fallback code.
4013 \def\eq@trial@init{\global\let\EQ@fallback\eq@nextlayout}
4016 % \begin{macro}{\eq@nextlayout}
4018 % In the fallback case cancel the current group to avoid unnecessary
4019 % group nesting (with associated save-stack cost, \etc ).
4021 \def\eq@nextlayout#1{%
4023 %<trace> \breqn@debugmsg{Nope ... that ain't gonna work.}%
4029 % \begin{macro}{\eq@failout}
4034 %<trace>\breqn@debugmsg{End trial: failout}%
4035 \global\let\EQ@trial\EQ@last@trial
4040 % \begin{macro}{\eq@trial@save}
4042 % Save the parameters of the current trial.
4044 \def\eq@trial@save#1{%
4046 % \begingroup \def\@elt##1X##2{\MessageBreak==== \space\space##1/##2}\let\@endelt\@empty\breqn@debugmsg{=> trial info:\eq@measurements}%
4047 % \breqn@debugmsg{=> bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness\MessageBreak}%
4048 % \let\@elt\relax \let\@endelt\relax
4052 \eq@linewidth\the\eq@linewidth
4053 % save info about the fit
4054 \eq@lines\the\eq@lines \eq@badness\the\eq@badness \def\@nx\eq@badline{\eq@badline}%
4056 \eq@wdT\the\eq@wdT \eq@wdMin\the\eq@wdMin
4057 \eq@vspan\the\eq@vspan \eq@dp\the\eq@dp \eq@firstht\the\eq@firstht
4058 % save info about the LHS
4059 \eq@wdL\the\eq@wdL \def\@nx\EQ@hasLHS{\EQ@hasLHS}%
4060 % save info about the numbering
4061 \def\@nx\eq@hasNumber{\eq@hasNumber}%
4062 % save info about the chosen layout
4063 \def\@nx\eq@layout{\eq@layout}%
4064 \def\@nx\eq@parshape{\@parshape}%
4065 \def\@nx\eq@measurements{\eq@measurements}%
4066 \def\@nx\adjust@rel@penalty{\adjust@rel@penalty}%
4067 \def\@nx\eq@shiftnumber{\eq@shiftnumber}%
4068 \def\@nx\eq@isIntertext{\@False}%
4074 % \begin{macro}{\eq@trial@b}
4076 % By default this just runs \cs{eq@trial@c}; \cf
4079 \def\eq@trial@b{\eq@trial@c}
4085 % \begin{macro}{\eq@trial@c}
4087 % Run the equation contents through the current parshape.
4089 \def\eq@trial@c#1#2{%
4090 %<trace> \breqn@debugmsg{Trying layout "#1" with\MessageBreak==== parshape\space\@xp\@gobble\@parshape}%
4096 \eq@trial@p % run the given parshape
4097 \if\@Not{\eq@badline}%
4098 \eq@trial@save\EQ@trial
4100 % If there is a number, try the same parshape again with adjustments
4101 % to make room for the number.
4103 % This is an awkward place for this:
4104 % It only allows trying to fit the number w/the SAME layout shape!
4106 \if\eq@hasNumber\eq@retry@with@number\fi
4107 \if L\eq@layout \eq@check@density
4109 \if\@Not{\eq@badline}%
4114 \eq@trial@save\EQ@last@trial
4123 % \begin{macro}{\eq@trial@d}
4125 \def\eq@trial@d#1#2{\eq@trial@c{#1}{}}
4129 % \begin{macro}{\eq@check@density}
4132 \def\eq@check@density{%
4133 %<trace> \breqn@debugmsg{Checking density for layout L}%
4134 \if\@Or{\@Not\EQ@hasLHS}{\eq@shortLHS}%
4135 %<trace> \breqn@debugmsg{Density check: No LHS, or is short; OK}%
4137 \else\if\eq@dense@enough
4145 % \begin{macro}{\eq@shortLHS}
4147 % Test to see if we need to apply the \cs{eq@dense@enough} test.
4149 \def\eq@shortLHS{\ifdim\eq@wdL>.44\eq@wdT 1\else 0\fi 0}
4153 %\verb|\def\eq@shortLHS{\@False}|
4154 %========================================
4155 % \begin{macro}{\eq@trial@p}
4156 % Run a trial with the current \cs{@parshape} and measure it.
4160 \eq@dump@box\unhcopy\EQ@copy
4161 {\@@par}% leave \parshape readable
4164 \let\eq@badline\@False
4165 \if i\eq@layout \ifnum\eq@lines>\@ne \let\eq@badline\@True \fi\fi
4166 \eq@curline\eq@lines % loop counter for eq@measure@lines
4167 \let\eq@measurements\@empty
4168 \eq@ml@record@indents
4171 %<trace> \debug@showmeasurements
4178 % \begin{macro}{\adjust@rel@penalty}
4180 % Normally this is a no-op.
4182 \let\adjust@rel@penalty\@empty
4186 % \begin{macro}{\eq@fix@lastline}
4187 % Remove parfillskip from the last line box.
4189 \def\eq@fix@lastline{%
4190 \setbox\tw@\lastbox \dim@b\wd\tw@
4193 % Remove \cs{parfillskip} but retain \cs{rightskip}.
4194 % Need to keep the original line width for later shrink testing.
4196 \nointerlineskip\hbox to\dim@b{\unhbox\tw@
4197 \skip@c\lastskip \unskip\unskip\hskip\skip@c
4203 % \begin{macro}{\eq@recalc}
4205 % Calculate \cs{eq@wdT} et cetera.
4208 \eq@wdT\z@ \eq@wdMin\maxdimen \eq@vspan\z@skip \eq@badness\z@
4209 \let\@elt\eq@recalc@a \eq@measurements \let\@elt\relax
4216 % \begin{macro}{\eq@recalc@a}
4219 \def\eq@recalc@a#1x#2+#3\@endelt{%
4221 \let\@elt\eq@recalc@b
4222 \@elt#1x#2+#3\@endelt
4229 % \begin{macro}{\eq@recalc@b}
4232 \def\eq@recalc@b#1X#2,#3x#4+#5@#6\@endelt{%
4233 \setlength\dim@a{#2+#3}%
4234 \ifdim\dim@a>\eq@wdT \eq@wdT\dim@a \fi
4235 \ifdim\dim@a<\eq@wdMin \eq@wdMin\dim@a \fi
4237 \addtolength\eq@vspan{#1+#4+\eq@dp}%
4239 % Record the max badness of all the lines in \cs{eq@badness}.
4241 \ifnum#6>\eq@badness \eq@badness#6\relax\fi
4246 % \begin{macro}{\eq@layout}
4248 % A value of \verb"?" for \cs{eq@layout} means that we should
4249 % deduce which layout to use by looking at the size of the components.
4250 % Any other value means we have a user-specified override on the
4254 % Layout Definitions.
4255 % Based on initial equation measurements, we can choose a sequence of
4256 % candidate parshapes that the equation might fit into.
4257 % We accept the first shape that `works', else fall to next one.
4258 % [The sequence is hardcoded in the \cs{eq@try@layout@}<shape>
4259 % Would it be useful be more flexible? (eg. try layouts LDA, in order...)]
4266 % \begin{macro}{\eq@try@layout@?}
4268 % This is a branching function used to choose a suitable layout if
4269 % the user didn't specify one in particular.
4272 % Try Single line layout first, else try Multiline layouts
4274 \@namedef{eq@try@layout@?}{%
4275 \let\eq@trial@b\eq@trial@c
4276 \edef\@parshape{\parshape 1 0pt \the\eq@linewidth\relax}%
4277 % \eq@trial@b{i}{\eq@try@layout@multi}%
4278 \setlength\dim@a{\wd\EQ@copy-2em}% Fudge; can't shrink more than this?
4279 % if we're in a numbered group, try hard to fit within the numbers
4281 \if\eq@shiftnumber\else\if\eq@group
4282 \if\eq@hasNumber\addtolength\dim@b{-\wd\EQ@numbox-\eqnumsep}%
4283 \else\if\grp@hasNumber\addtolength\dim@b{-\wd\GRP@numbox-\eqnumsep}%
4285 \ifdim\dim@a<\dim@b% Do we even have a chance of fitting to one line?
4286 %<trace> \breqn@debugmsg{Choose Shape: (\the\wd\EQ@copy) may fit in \the\dim@b}%
4288 % BRM: assuming it might fit, don't push too hard
4290 \setlength\dim@b{\columnwidth-\dim@a+\eq@wdCond}%
4291 \rightskip\z@\@plus\dim@b\@minus\hfuzz
4292 \eq@trial@b{i}{\eq@try@layout@multi}%
4295 \breqn@debugmsg{Choose Shape: Too long (\the\wd\EQ@copy) for one line
4296 (free width=\the\dim@b)}%
4298 \eq@try@layout@multi
4302 % Layout Multiline layout:
4303 % If no LHS, try Stepped(S) layout
4304 % Else try Stepped(S), Ladder(L), Drop-ladder(D) or Stepladder(l), depending on LHS length.
4306 \def\eq@try@layout@multi{%
4308 \ifdim\eq@wdL>\eq@linewidth
4309 %<trace> \breqn@debugmsg{Choose Shape: LHS \the\eq@wdL > linewidth}%
4311 % Find the total width of the RHS.
4312 % If it is relatively short, a step layout is the thing to try.
4314 \setlength\dim@a{\wd\EQ@copy-\eq@wdL}%
4315 \ifdim\dim@a<.25\eq@linewidth \eq@try@layout@S
4316 \else \eq@try@layout@l
4318 % BRM: Originally .7: Extreme for L since rhs has to wrap within the remaining 30+%!
4319 \else\ifdim\eq@wdL>.50\eq@linewidth
4321 \breqn@debugmsg{Choose Shape: LHS (\the\eq@wdL) > .50 linewidth (linewidth=\the\eq@linewidth)}%
4325 %<trace> \breqn@debugmsg{Choose Shape: LHS (\the\eq@wdL) not extraordinarily wide}%
4329 %<trace> \breqn@debugmsg{Choose Shape: No LHS here}%
4331 % Try one-line layout first, then step layout.
4333 \eq@try@layout@S % (already checked case i)
4339 % \begin{macro}{\eq@try@layout@D}
4341 % Change the penalty before the first mathrel symbol to encourage a
4344 % Layout D=Drop-Ladder Layout, for wide LHS.
4345 % \begin{literalcode}
4350 % If fails, try Almost-Columnar layout
4352 \def\eq@try@layout@D{%
4353 \setlength\dim@a{\eq@linewidth -\eq@indentstep}%
4354 \edef\@parshape{\parshape 2
4355 0pt \the\eq@wdL\space \the\eq@indentstep\space \the\dim@a\relax
4357 \def\adjust@rel@penalty{\penalty-99 }%
4358 \eq@trial@b{D}{\eq@try@layout@A}%
4362 % \begin{macro}{\eq@try@layout@L}
4363 % Try a straight ladder layout.
4364 % Preliminary filtering ensures that \cs{eq@wdL} is less than 70%
4365 % of the current line width.
4366 % \begin{literalcode}
4367 % Layout L=Ladder layout
4372 % If fails, try Drop-ladder layout.
4373 % NOTE: This is great for some cases (multi relations?), but
4374 % tends to break really badly when it fails....
4376 \def\eq@try@layout@L{%
4377 \setlength\dim@b{\eq@linewidth-\eq@wdL}%
4378 \edef\@parshape{\parshape 2 0pt \the\eq@linewidth\space
4379 \the\eq@wdL\space \the\dim@b\relax
4381 \eq@trial@b{L}{\eq@try@layout@D}%
4386 % \begin{macro}{\eq@try@layout@S}
4388 % In the \dquoted{stepped} layout there is no LHS, or LHS
4389 % is greater than the line width and RHS is small.
4390 % Then we want to split up the equation into lines of roughly equal
4391 % width and stagger them downwards to the right, leaving a small amount of
4392 % whitespace on both sides.
4393 % But also, if there is an equation number, we want to try first a
4394 % layout that leaves room for the number.
4395 % Otherwise it would nearly always be the case that the number would
4396 % get thrown on a separate line.
4398 % Layout S=Stepped layout, typically no LHS or very long, variations on
4399 % \begin{literalcode}
4404 % If fails, try Almost-Columnar layout
4406 \def\eq@try@layout@S{%
4407 \setlength\dim@b{\eq@linewidth-2\eqmargin}% \advance\dim@b-1em%
4409 % About how many lines will we need if dim@b is the line width?
4411 \int@a\wd\EQ@copy \divide\int@a\dim@b
4413 % Adjust the target width by number of lines times indentstep.
4414 % We don't need to decrement \cs{int@a} because \tex
4415 % division is integer division with truncation.
4417 \addtolength\dim@b{-\int@a\eq@indentstep}%
4419 % Adjust for equation number.
4420 % But try not to leave too little room for the equation body.
4424 % \advance\dim@b-\eqnumsep \advance\dim@b-\wd\EQ@numbox
4425 \addtolength\dim@b{-\eq@wdNum}%
4429 % Now some hand-waving to set up the parshape.
4433 \edef\@parshape{\parshape 2 0pt \the\dim@b\space
4434 \the\eqmargin\space\the\dim@b\relax}%
4435 \eq@trial@b{S}{\eq@try@layout@A}%
4440 % \begin{macro}{\eq@try@layout@l}
4442 % This is the \dquoted{step-ladder} layout: similar to the drop-ladder
4443 % layout but the LHS is too wide and needs to be broken up.
4445 % Layout l = Stepladder
4446 % Similar to Drop-Ladder, but LHS is long and needs to be broken up.
4447 % If fails, try Almost-Columnar layout
4449 \def\eq@try@layout@l{%
4450 \setlength\dim@a{\eq@linewidth -\eq@indentstep}%
4451 \int@a\eq@wdL \divide\int@a\dim@a
4453 \edef\@parshape{\parshape \number\int@a\space
4454 0pt \the\eq@linewidth
4457 \setlength\dim@b{2\eq@indentstep}%
4458 \setlength\dim@c{\eq@linewidth -\dim@b}%
4459 \edef\@parshape{\@parshape
4460 \replicate{\int@a}{\space\the\eq@indentstep\space\the\dim@a}%
4461 \space\the\dim@b\space\the\dim@c\relax
4463 \eq@trial@b{l}{\eq@try@layout@A}%
4469 % \begin{macro}{\eq@try@layout@A}
4471 % In the \dquoted{almost-columnar} layout, which is the layout of last
4472 % resort, we let all lines run to the full width and leave the adjusting
4473 % of the indents to later.
4475 % Layout A = Almost-Columnar layout.
4476 % Pretty much straight full width, more of a last-resort.
4477 % If fails, give up.
4479 \def\eq@try@layout@A{%
4480 \edef\@parshape{\parshape 1 0pt \the\eq@linewidth\relax}%
4481 \if\EQ@hasLHS \def\adjust@rel@penalty{\penalty-99 }\fi
4487 % \begin{macro}{\eq@shiftnumber}
4488 % MH: Should be moved to a section where all keys are set to defaults.
4490 \let\eq@shiftnumber\@False
4495 % \begin{macro}{\eq@retry@with@number@a}
4496 % Number placement adjustments
4498 \def\eq@retry@with@number{%
4500 %<trace> \breqn@debugmsg{Place number: Shifted number requested}%
4503 % Condition and right numbers? We're just going to have to shift.
4505 \ifdim\eq@wdCond>\z@\if R\eqnumside
4506 %<trace> \breqn@debugmsg{Place number: Condition w/Right number => Shift number}%
4507 \let\eq@shiftnumber\@True
4510 % Compute free space.
4512 % \dim@b\eqnumsep\advance\dim@b\wd\EQ@numbox
4515 \ifdim\@totalleftmargin>\dim@b\dim@b\@totalleftmargin\fi
4517 \addtolength\dim@b{\@totalleftmargin}%
4519 \setlength\dim@a{\eq@linewidth-\dim@b}%\advance\dim@a1em\relax% Allowance for shrink?
4521 % Set up test against 1-line case only if not in a group
4523 \int@a\@ne\if\eq@group\int@a\maxint\fi
4525 % Now check for cases.
4527 \if\eq@shiftnumber % Already know we need to shift
4528 \else\ifdim\eq@wdT<\dim@a % Fits!
4530 % left \& right skips will be done later, and parshape adjusted if
4533 %<trace> \breqn@debugmsg{Place number: eqn and number fit together}%
4534 % \else\ifnum\eq@lines=\int@a % Shift, if single line, unless inside a dgroup.
4536 % NOTE: this is too strong for dgroup!
4539 % \breqn@debugmsg{Place number: single line too long with number => Shift number \the\int@a}%
4541 % \let\eq@shiftnumber\@True
4544 % % Retry: use leftskip for space for number(for now; whether
4545 % % right/left) \& adjust parshape
4547 % \leftskip\wd\EQ@numbox\advance\leftskip\eqnumsep
4548 \setlength\leftskip{\eq@wdNum}%
4549 \setlength\rightskip{\z@\@plus\dim@a}%
4550 \adjust@parshape\@parshape
4552 \breqn@debugmsg{Place number: Try with \leftskip=\the\leftskip, \rightskip=\the\rightskip,
4553 \MessageBreak==== parshape\space\@xp\@gobble\@parshape}%
4556 \edef\eq@prev@lines{\the\eq@lines}%
4557 \edef\eq@prev@badness{\the\eq@badness}% BRM
4559 \int@a\eq@prev@badness\relax\advance\int@a 50\relax%?
4560 \int@b\eq@prev@lines \if\eq@group\advance\int@b\@ne\fi% Allow 1 extra line in group
4561 \ifnum\eq@lines>\int@b % \eq@prev@lines
4562 %<trace> \breqn@debugmsg{Adjustment causes more breaks => Shift number}%
4563 \let\eq@shiftnumber\@True
4565 %<trace> \breqn@debugmsg{Adjustment causes bad lines (\the\eq@badness) => Shift}%
4566 \let\eq@shiftnumber\@True
4567 \else\ifnum\eq@badness>\int@a % BRM: New case
4569 \breqn@debugmsg{Adjustment is badder than previous
4570 (\the\eq@badness >> \eq@prev@badness) => Shift}%
4572 \let\eq@shiftnumber\@True
4574 %<trace> \breqn@debugmsg{Adjustment succeeded}%
4578 % If we got shifted, restore parshape, etc,
4581 \EQ@trial% Restore parshape & other params,
4582 \leftskip\z@\let\eq@shiftnumber\@True % But set shift & leftskip
4583 \edef\@parshape{\eq@parshape}% And copy saved parshape back to `working copy' !?!?
4585 \eq@trial@save\EQ@trial % Either way, save the trial state.
4590 % \begin{macro}{\adjust@parshape}
4592 % Varies depending on the layout.
4594 % Adjust a parshape variable for a given set of left\textbar right skips.
4595 % Note that the fixed part of the left\textbar right skips effectively
4596 % comes out of the parshape widths (NOT in addition to it).
4597 % We also must trim the widths so that the sum of skips, indents
4598 % and widths add up to no more than the \cs{eq@linewidth}.
4600 \def\adjust@parshape#1{%
4601 \@xp\adjust@parshape@a#1\relax
4609 % \begin{macro}{\adjust@parshape@a}
4610 % \begin{macro}{\adjust@parshape@b}
4613 \def\adjust@parshape@a#1 #2\relax{%
4614 \setlength\dim@a{\leftskip+\rightskip}%
4616 \adjust@parshape@b#2 @ @ \relax
4618 \def\adjust@parshape@b#1 #2 {%
4619 \ifx @#1\edef\temp@a{\temp@a\relax}%
4624 \addtolength\dim@c{\dim@a+\dim@b}%
4625 \ifdim\dim@c>\eq@linewidth\setlength\dim@c{\eq@linewidth}\fi
4626 \addtolength\dim@c{-\dim@b}%
4627 \edef\temp@a{\temp@a\space\the\dim@b\space\the\dim@c}%
4634 % \begin{macro}{\eq@ml@record@indents}
4636 % Plunk the parshape's indent values into an array for easy access
4637 % when constructing \cs{eq@measurements}.
4639 \def\eq@ml@record@indents{%
4643 \@xp\edef\csname eq@i\number\int@a\endcsname{\the\dim@a}%
4644 \ifnum\int@a<\int@b \afterassignment\@tempb \fi
4647 \def\@tempb{\afterassignment\@tempa \dim@a}%
4648 \def\@tempc##1##2 {\int@b##2\afterassignment\@tempa\dim@a}%
4649 \@xp\@tempc\@parshape
4656 % \begin{macro}{\@endelt}
4658 % This is a scan marker.
4659 % It should get a non-expandable definition.
4660 % It could be \cs{relax}, but let's try a chardef instead.
4662 \chardef\@endelt=`\?
4668 % \begin{macro}{\eq@measurements}
4670 % This is similar to a parshape spec but for each line we record more
4671 % info: space above, indent, width x height + dp, and badness.
4673 \def\eq@measurements{%
4674 \@elt 4.5pt/5.0pt,66.0ptx6.8pt+2.4pt@27\@endelt
4682 % \begin{macro}{\eq@measure@lines}
4683 % Loop through the list of boxes to measure things like total
4684 % height (including interline stretch), \etc . We check the
4685 % actual width of the current line against the natural width \mdash
4686 % after removing rightskip \mdash in case the former is
4687 % \emph{less} than the latter because of shrinkage. In that
4688 % case we do not want to use the natural width for RHS-max-width because
4689 % it might unnecessarily exceed the right margin.
4691 \def\eq@measure@lines{%
4692 \let\eq@ml@continue\eq@measure@lines
4693 \setbox\tw@\lastbox \dim@b\wd\tw@ % find target width of line
4694 \setbox\z@\hbox to\dim@b{\unhbox\tw@}% check for overfull
4696 \ifnum\eq@badness<\inf@bad \else \let\eq@badline\@True \fi
4697 \eq@ml@a \eq@ml@continue
4704 % \begin{macro}{\eq@ml@a}
4708 \setbox\tw@\hbox{\unhbox\z@ \unskip}% find natural width
4710 \ifnum\eq@badness<\inf@bad\else\breqn@debugmsg{!?! Overfull: \the\wd\tw@ >\the\dim@b}\fi
4713 % Is actual width less than natural width?
4715 \ifdim\dim@b<\wd\tw@ \setlength\dim@a{\dim@b}% shrunken line
4716 \else \setlength\dim@a{\wd\tw@}% OK to use natural width
4718 \addtolength\dim@a{-\leftskip}% BRM: Deduct the skip if we're retrying w/number
4720 % If there's no aboveskip, assume we've reached the top of the
4723 \skip@a\lastskip \unskip \unpenalty
4725 \let\eq@ml@continue\relax % end the recursion
4727 % Sum repeated vskips if present
4729 \ifdim \lastskip=\z@
4730 \else \addtolength\skip@a{\lastskip}\unskip\unpenalty \@xp\@tempa
4734 \edef\eq@measurements{\@elt
4735 \the\skip@a\space X% extra space to facilitate extracting only the
4738 \ifnum\eq@curline<\parshape \number\eq@curline
4739 \else\number\parshape
4741 \endcsname,\the\dim@a x\the\ht\tw@+\the\dp\tw@ @\the\eq@badness\@endelt
4744 \advance\eq@curline\m@ne
4745 \ifnum\eq@curline=\z@ \let\eq@ml@continue\relax\fi
4752 % \begin{macro}{\eq@ml@vspace}
4754 % Handle an embedded vspace.
4757 \global\advance\eq@vspan\lastskip \unskip\unpenalty
4758 \ifdim\lastskip=\z@ \else \@xp\eq@ml@vspace \fi
4765 % \begin{macro}{\eq@dense@enough}
4768 \def\eq@dense@enough{%
4769 \ifnum\eq@lines<\thr@@
4770 %<trace> \breqn@debugmsg{Density check: less than 3 lines; OK}%
4773 \ifdim\eq@wdL >.7\eq@wdT
4774 %<trace> \breqn@debugmsg{Density check: LHS too long; NOT OK}%
4776 \else \@xp\@xp\@xp\eq@dense@enough@a
4785 % \begin{macro}{\true@false@true}
4787 \def\true@false@true{\fi\fi\iftrue\iffalse\iftrue}
4792 % \begin{macro}{\false@false@false}
4794 \def\false@false@false{\fi\fi\iffalse\iffalse\iffalse}
4799 % \begin{macro}{\false@true@false}
4801 \def\false@true@false{\fi\fi\iffalse\iftrue\iffalse}
4806 % \begin{macro}{\eq@density@factor}
4808 % This number specifies, for the ladder layout, how much of the
4809 % equation's bounding box should contain visible material rather than
4811 % If the amount of visible material drops below this value, then we
4812 % switch to the drop-ladder layout.
4813 % The optimality of this factor is highly dependent on the equation
4814 % contents; .475 was chosen as the default just because it worked well
4815 % with the sample equation, designed to be as average as possible, that I
4818 \def\eq@density@factor{.475}
4823 % \begin{macro}{\eq@dense@enough@a}
4825 % Calculate whether there is more
4826 % visible material than whitespace within the equation's bounding box.
4827 % Sum up the actual line widths and compare to the total
4828 % \dquoted{area} of the bounding box.
4829 % But if we have an extremely large number of lines, fall back to an
4830 % approximate calculation that is more conservative about the danger of
4831 % exceeding \cs{maxdimen}.
4833 \def\eq@dense@enough@a{%
4835 \ifnum\eq@lines>\sixt@@n
4838 \dim@b\z@ \let\@elt\eq@delt \eq@measurements
4839 \dim@c\eq@density@factor\eq@wdT \multiply\dim@c\eq@lines
4840 %<trace> \breqn@debugmsg{Density check: black \the\dim@b/\eq@density@factor total \the\dim@c}%
4841 \ifdim\dim@b>\dim@c \true@false@true \else \false@false@false \fi
4848 % \begin{macro}{\eq@delt}
4849 % Args are space-above, indent, width, height, depth, badness.
4851 \def\eq@delt#1X#2,#3x#4+#5@#6\@endelt{\addtolength\dim@b{#3}}%
4856 % \begin{macro}{\eq@dense@enough@b}
4858 % This is an approximate calculation used to keep from going over
4859 % \cs{maxdimen} if the number of lines in our trial break is large
4860 % enough to make that a threat.
4861 % If l, t, n represent left-side-width, total-width, and number of
4862 % lines, the formula is
4863 % \begin{literalcode}
4866 % or equivalently, since rational arithmetic is awkward in \tex :
4868 % \begin{literalcode}
4873 \def\eq@dense@enough@b{%
4874 \int@b\eq@wdT \divide\int@b\p@
4875 \dim@b\eq@wdL \divide\dim@b\int@b
4876 \dim@c\eq@lines\p@ \multiply\dim@c\f@ur
4877 \int@b\eq@lines \multiply\int@b 9 \advance\int@b -10%
4879 %<trace> \breqn@debugmsg{Density check: l/t \the\dim@b\space< \the\dim@c\space 4n/(9n-10)?}%
4880 \ifdim\dim@b<\dim@c \true@true@true \else \false@true@false \fi
4886 % \begin{macro}{\eq@parshape}
4889 \let\eq@parshape\@empty
4895 % \begin{macro}{\eq@params}
4896 % The interline spacing and penalties in \cs{eq@params}
4897 % are used during both preliminary line breaking and final typesetting.
4900 \baselineskip\eqlinespacing
4901 \lineskip\eqlineskip \lineskiplimit\eqlineskiplimit
4903 % Forbid absolutely a pagebreak that separates the first line or last
4904 % line of a multiline equation from the rest of it. Or in other
4905 % words: no equation of three lines or less will be broken at the bottom
4906 % of a page; instead it will be moved whole to the top of the next
4907 % page. If you really really need a page break that splits the
4908 % first or last line from the rest of the equation, you can always fall
4909 % back to\cs{pagebreak}, I suppose.
4912 \clubpenalty\@M \widowpenalty\@M \interlinepenalty\eqinterlinepenalty
4913 \linepenalty199 \exhyphenpenalty5000 % was 9999: make breaks at, eg. \* a bit easier.
4915 % For equations, hfuzz should be at least 1pt.
4916 % But we have to fake it a little because we are running the equation
4917 % through \tex 's paragrapher.
4918 % In our trials we use minus 1pt in the rightskip rather than hfuzz;
4919 % and we must do the same during final breaking of the equation, otherwise
4920 % in borderline cases \tex will use two lines instead of one when our
4921 % trial indicated that one line would be enough.
4923 \ifdim\hfuzz<\p@ \hfuzz\p@ \fi
4925 % \ifdim\hfuzz<2pt\relax \hfuzz2pt \fi
4929 % Make sure we skip \tex 's preliminary line-breaking pass to save
4932 \tolerance9999 \pretolerance\m@ne
4940 % \section{Equation layout options}
4941 % Using the notation C centered, I indented (applied to
4942 % the equation body), T top, B bottom, M
4943 % middle, L left, R right (applied to the equation number),
4944 % the commonly used equation types are C, CRM, CRB, CLM, CLT,
4945 % I, IRM, IRB, ILM, ILT. In other words, CLM stands for Centered equation
4946 % body with Left-hand Middle-placed equation number, and IRB stands for
4947 % Indented equation with Right-hand Bottom-placed equation number.
4949 % Here are some general thoughts on how to place an equation
4950 % tag. Currently it does not work as desired: the L option positions
4951 % the tag app. 10 lines below the math expression, the RM doesn't
4952 % position the tag on the baseline for single-line math
4953 % expressions. Therefore I am going to first write what I think is
4954 % supposed to happen and then implement it.
4956 % Below is a small list where especially the two three specifications
4957 % should be quite obvious, I just don't want to forget anything and it
4958 % is important to the implementation.
4959 % \begin{description}
4960 % \item[Definition 1] If a display consists of exactly one line, the
4961 % tag should always be placed on the same baseline as the math
4964 % The remaining comments refer to multi-line displays.
4965 % \begin{description}
4966 % \item[Definition 2] If a tag is to be positioned at the top (T), it
4967 % should be placed such that the baseline of the tag aligns with the
4968 % baseline of the top line of the display.
4970 % \item[Definition 3] If a tag is to be positioned at the bottom (B),
4971 % it should be placed such that the baseline of the tag aligns with
4972 % the baseline of the bottom line of the display.
4974 % \item[Definition 4] If a tag is to be positioned vertically centered
4975 % (M), it should be placed such that the baseline of the tag is
4976 % positioned exactly halfway between the baseline of the top line of
4977 % the display and the baseline of the bottom line of the display.
4980 % Definitions 1--3 are almost axiomatic in their
4981 % simplicity. Definition~4 is different because I saw at least two
4982 % possibilities for which area to span:
4984 % \item Calculate distance from top of top line to the bottom of the
4985 % bottom line, position the vertical center of the tag exactly
4986 % halfway between those two extremes.
4988 % \item Calculate the distance from the baseline of the top line to
4989 % the baseline of the bottom line, position the baseline of the tag
4990 % exactly halfway between these two extremes.
4992 % Additional combinations of these methods are possible but make
4993 % little sense in my opinion. I have two reasons for choosing the
4994 % latter of these possibilities: Firstly, two expressions looking
4995 % completely identical with the exception of a superscript in the
4996 % first line or a subscript in the last line will have the tag
4997 % positioned identically. Secondly, then M means halfway between T and
4998 % B positions which makes good sense and then also automatically
4999 % fulfills Definition~1.
5001 % From an implementation perspective, these definitions should also
5002 % make it possible to fix a deficiency in the current implementation,
5003 % namely that the tag does not influence the height of a display, even
5004 % if the display is a single line. This means that two single-line
5005 % expressions in a \env{dgroup} can be closer together than
5006 % \cs{intereqskip} if the math expressions are (vertically) smaller
5012 % \section{Centered Right-Number Equations}
5014 % \begin{macro}{\eq@dump@box}
5016 % \arg1 might be \cs{unhbox} or \cs{unhcopy}; \arg2 is
5019 \def\eq@dump@box#1#2{%
5021 \noindent #1#2\setbox\f@ur\lastbox \setbox\tw@\lastbox
5023 % If the LHS contains shrinkable glue, in an L layout the alignment
5024 % could be thrown off if the first line is shrunk noticeably.
5025 % For the time being, disable shrinking on the left-hand side.
5026 % The proper solution requires more work \begin{dn}
5031 \if L\eq@layout \box\tw@ \else\unhbox\tw@\fi
5032 \adjust@rel@penalty \unhbox\f@ur
5040 % Various typesetting bits, invoked from \cs{eq@finish}
5041 % BRM: This has been extensively refactored from the original breqn,
5042 % initially to get left\textbar right skips and parshape used consistently,
5043 % ultimately to get most things handled the same way, in the same order.
5047 % Given that left and right skips have been set,
5048 % typeset the frame, number and equation with the
5049 % given number side and placement
5054 \def\eq@typeset@Unnumbered{%
5056 \eq@typeset@equation
5058 \def\eq@typeset@LM{%
5059 \setlength\dim@a{(\eq@vspan+\ht\EQ@numbox-\dp\EQ@numbox)/2}%
5060 \eq@typeset@leftnumber
5062 \eq@typeset@equation
5065 % Typeset equation and left-top number (and shifted)
5067 \def\eq@typeset@LT{%
5069 \eq@typeset@leftnumber
5071 \eq@typeset@equation
5074 % Typeset equation and left shifted number
5076 \def\eq@typeset@LShifted{%
5078 \copy\EQ@numbox \penalty\@M
5081 \setlength\dim@a{\eq@framesep+\eq@framewd}%
5085 \eq@typeset@equation
5088 % Typeset equation and right middle number
5090 \def\eq@typeset@RM{%
5091 \setlength\dim@a{(\eq@vspan+\ht\EQ@numbox-\dp\EQ@numbox)/2}%
5092 \eq@typeset@rightnumber
5094 \eq@typeset@equation
5097 % Typeset equation and right bottom number
5099 \def\eq@typeset@RB{%
5100 % NOTE: is \eq@dp useful here
5101 \setlength\dim@a{\eq@vspan-\ht\EQ@numbox-\dp\EQ@numbox}%
5102 \eq@typeset@rightnumber
5104 \eq@typeset@equation
5107 % Typeset equation and right shifted number
5109 \def\eq@typeset@RShifted{%
5112 \eq@typeset@equation
5116 \addtolength\dim@a{\eq@framesep+\eq@framewd}%
5119 \hbox to\hsize{\hfil\copy\EQ@numbox}\@@par%
5123 % Debugging aid to show all relevant formatting info for a given eqn.
5126 \def\debug@showformat{%
5127 \breqn@debugmsg{Formatting Layout:\eq@layout\space Center/indent: \eqindent\space
5128 Number placement \eqnumside\eqnumplace:
5129 \MessageBreak==== \eq@linewidth=\the\eq@linewidth, \@totalleftmargin=\the\@totalleftmargin,
5130 \MessageBreak==== Centered Lines=\theb@@le\eq@centerlines, Shift Number=\theb@@le\eq@shiftnumber,
5131 \MessageBreak==== \eq@wdT=\the\eq@wdT, \eq@wdMin=\the\eq@wdMin,
5132 \MessageBreak==== LHS=\theb@@le\EQ@hasLHS: \eq@wdL=\the\eq@wdL,
5133 \MessageBreak==== \eq@firstht=\the\eq@firstht, \eq@vspan=\the\eq@vspan
5134 \MessageBreak==== \eq@wdNum=\the\eq@wdNum
5135 \MessageBreak==== \eq@wdCond=\the\eq@wdCond, \conditionsep=\the\conditionsep,
5136 \MessageBreak==== \leftskip=\the\leftskip, \rightskip=\the\rightskip,
5137 \MessageBreak==== \abovedisplayskip=\the\abovedisplayskip,
5138 \MessageBreak==== \belowdisplayskip=\the\belowdisplayskip
5139 \MessageBreak==== parshape=\eq@parshape}%
5144 % Set left \& right skips for centered equations,
5145 % making allowances for numbers (if any, right, left) and constraint.
5147 % Amazingly, I've managed to collect all the positioning logic for
5148 % centered equations in one place, so it's more manageable.
5149 % Unfortunately, by the time it does all it needs to do,
5150 % it has evolved I'm (re)using so many temp variables, it's becoming
5154 \def\eq@C@setsides{%
5155 % \dim@c = space for number, if any, and not shifted.
5157 \if\eq@hasNumber\if\eq@shiftnumber\else
5160 % \dim@e = space for condition(on right), if any and formula is only a single line.(to center nicely)
5161 % but only count it as being right-aligned if we're not framing, since the frame must enclose it.
5164 \ifnum\eq@lines=\@ne\ifdim\eq@wdCond>\z@
5165 \setlength\dim@e{\eq@wdCond+\conditionsep}%
5167 % \dim@b = minimum needed on left max(totalleftmargin, left number space)
5169 \if L\eqnumside\ifdim\dim@b<\dim@c
5172 \ifdim\dim@b<\@totalleftmargin
5175 \addtolength\dim@b{-\@totalleftmargin}%
5177 % \dim@d = minimum needed on right max(condition, right number space)
5179 \if R\eqnumside\ifdim\dim@d<\dim@c
5182 % \dim@a = left margin; initially half available space
5183 % \dim@c = right margin; ditto
5184 \setlength\dim@a{(\eq@linewidth-\eq@wdT+\dim@e+\@totalleftmargin)/2}%
5186 % If too far to the left
5188 \addtolength\dim@c{\dim@a-\dim@b}%
5189 \ifdim\dim@c<\z@\dim@c=\z@\fi
5191 % Or if too far to the right
5192 \else\ifdim\dim@c<\dim@d
5193 \addtolength\dim@a{\dim@c-\dim@d}%
5194 \ifdim\dim@a<\z@\dim@a=\z@\fi
5197 % Now, \dim@d,\dim@e is the left & right glue to center each line for centerlines
5198 \setlength\dim@e{\eq@wdT-\eq@wdMin}\dim@d=\z@
5200 % NOTE: Need some work here centering when there's a condition
5202 % \advance\dim@e-\eq@wdT\multiply\dim@e-1\relax
5203 % \if\eq@wdMin<\dim@e\dim@e\eq@wdMin\fi
5204 % \multiply\dim@e-1\relax\advance\dim@e\eq@wdT
5207 \divide\dim@e2\relax
5210 \setlength\leftskip{\dim@a\@plus\dim@d}%
5211 \addtolength\dim@e{\dim@c}%
5212 \setlength\rightskip{\z@\@plus\dim@e}%\@minus5\p@
5213 % Special case: if framing, reduce the stretchiness of the formula (eg. condition)
5214 % Or if we have a right number, FORCE space for it
5219 \if\@And{\eq@hasNumber}{\@Not{\eq@shiftnumber}}%
5227 % If either of those cases requires hard rightskip, move that part from glue.
5229 \addtolength\dim@e{-\dim@c}%
5230 \rightskip\dim@b\@plus\dim@e%\@minus5\p@
5232 % And peculiar further special case: in indented environs, width isn't where it would seem
5233 \ifdim\eq@wdCond>\z@
5234 \addtolength\rightskip{-\@totalleftmargin}%
5240 % Set the left and right side spacing for indented equations
5241 % Some things handled by eq@C@setsides that probably apply here????
5244 % \item \cs{@totalleftmargin}: SHOULD we move farther right?
5246 % Leftskip is normally just the requested indentation
5248 \def\eq@I@setsides{%
5249 \leftskip\mathindent
5251 % But move left, if shifted number presumably because of clashed w/ number?
5254 \setlength\dim@a{\eq@linewidth-\eq@wdT-\mathindent}%
5256 \leftskip=\z@ % Or something minimal?
5260 % Push gently from right.
5263 \setlength\dim@b{\eq@linewidth-\leftskip-\eq@wdMin}%
5265 % Special case: if framing be much more rigid(?)
5269 \setlength\dim@a{\eq@linewidth-\leftskip-\eq@wdT}
5270 \addtolength\dim@b{-\dim@a}%
5272 % Or force the space for right number, if needed
5274 \if\@And{\eq@hasNumber}{\@Not{\eq@shiftnumber}}%
5278 \addtolength\dim@b{-\dim@c}%
5283 \setlength\rightskip{\dim@a\@plus\dim@b \@minus\hfuzz }%\hfuzz\z@
5287 % \paragraph{Typesetting pieces: frame, equation and number (if any)}
5288 % \cs{dim@a} should contain the downward displacement of number's baseline
5290 \def\eq@typeset@leftnumber{%
5291 \setlength\skip@c{\dim@a-\ht\EQ@numbox}%
5292 \vglue\skip@c% NON discardable
5293 \copy\EQ@numbox \penalty\@M
5296 \def\eq@typeset@rightnumber{%
5297 \setlength\skip@c{\dim@a-\ht\EQ@numbox}%
5298 \vglue\skip@c% NON discardable
5299 \hbox to \hsize{\hfil\copy\EQ@numbox}\penalty\@M
5302 \def\eq@typeset@equation{%
5304 \eq@params\eq@parshape
5305 \nointerlineskip\noindent
5307 \eq@dump@box\unhbox\EQ@box\@@par
5311 % \section{Framing an equation}
5312 % \begin{macro}{\eqframe}
5313 % The \cs{eqframe} function is called in vertical mode
5314 % with the reference point at the top left corner of the equation, including
5315 % any allowance for \cs{fboxsep}. Its arguments are the width
5316 % and height of the equation body, plus fboxsep.
5317 % \changes{v0.95}{2007/12/03}{Made \cs{eqframe} obey the key settings
5318 % for frame and framesep.}
5320 \newcommand\eqframe[2]{%
5322 \fboxrule=\eq@framewd\relax\fboxsep=\eq@framesep\relax
5323 \framebox{\z@rule\@height#2\kern#1}%
5328 % The frame is not typeset at the correct horizontal position. Will
5333 \setlength\dim@a{\eq@framesep+\eq@framewd}%
5335 \vbox to\z@{\kern-\dim@a
5336 \hbox{\eqframe{\eq@wdT}{\eq@vspan}}%
5342 \def\eq@typeset@frame{%
5344 % Tricky: put before \noindent, so it's not affected by glue in \leftskip
5345 \nobreak\nointerlineskip
5346 \vbox to\eq@firstht{\moveright\leftskip\hbox to\z@{\eq@addframe\hss}\vss}%
5355 % \section{Delimiter handling}
5356 % The special handling of delimiters is rather complex, but
5357 % everything is driven by two motives: to mark line breaks inside
5358 % delimiters as less desirable than line breaks elsewhere, and to make it
5359 % possible to break open left-right boxes so that line breaks between
5360 % \cs{left} and \cs{right} delimiters are not absolutely
5361 % prohibited. To control the extent to which line breaks will be
5362 % allowed inside delimiters, set \cs{eqbreakdepth} to the maximum
5363 % nesting depth. Depth 0 means never break inside delimiters.
5365 % Note: \cs{eqbreakdepth} is not implemented as a \latex
5366 % counter because changes done by \cs{setcounter} \etc are always
5369 % It would be natural to use grouping in the implementation
5370 % \mdash at an open delimiter, start a group and increase mathbin
5371 % penalties; at a close delimiter, close the group. But this gives us
5372 % trouble in situations like the \env{array} environment, where a
5373 % close delimiter might fall in a different cell of the \cs{halign}
5374 % than the open delimiter.
5375 % Ok then, here's what we want the various possibilities to
5376 % expand to. Note that \cs{right} and \cs{biggr} are
5377 % being unnaturally applied to a naturally open-type delimiter.
5378 % \begin{literalcode}
5379 % ( -> \delimiter"4... \after@open
5381 % \@@left \delimiter"4... \after@open
5383 % \@@right \delimiter"4... \after@close
5385 % \mathopen{\@@left \delimiter... \vrule...\@@right.}
5388 % \mathclose{\@@left \delimiter... \vrule...\@@right.}
5391 % \mathord{\@@left \delimiter... \vrule...\@@right.}
5393 % \mathrel{\@@left \delimiter... \vrule...\@@right.}
5397 % First save the primitive meanings of \cs{left} and
5400 \@saveprimitive\left\@@left
5401 \@saveprimitive\right\@@right
5405 % The variable \cs{lr@level} is used by the first mathrel in
5406 % an equation to tell whether it is at top level: yes? break and measure
5407 % the LHS, no? keep going.
5413 % It would be nice to have better error checking here if the
5414 % argument is not a delimiter symbol at all.
5417 \@ifnext .{\eq@nullleft}{\begingroup \let\delimiter\eq@left@a}%
5420 \@ifnext .{\eq@nullright}{\begingroup \let\delimiter\eq@right@a}%
5423 % The arguments are: \arg1 delim symbol, \arg2 .
5425 \def\eq@left@a#1 #2{\endgroup\@@left\delimiter#1 \after@open}
5426 \def\eq@right@a#1 #2{\endgroup
5427 \@@right\delimiter#1 \after@close \ss@scan{#1}%
5430 % The null versions.
5432 \def\eq@nullleft#1{\@@left#1\after@open}
5433 \def\eq@nullright#1{\@@right#1\after@close}
5437 % Here is the normal operation of \cs{biggl}, for example.
5438 % \begin{literalcode}
5439 % \biggl ->\mathopen \bigg
5442 % \bigg #1->{\hbox {$\left #1\vbox to14.5\p@ {}\right .\n@space $}}
5445 % For paren matching: )
5446 % Like \cs{left}, \cs{biggl} coerces its delimiter to be of
5447 % mathopen type even if its natural inclination is towards closing.
5449 % The function \cs{delim@reset} makes delimiter characters
5450 % work just about the same as they would in normal \latex .
5453 \let\after@open\relax \let\after@close\relax
5454 \let\left\@@left \let\right\@@right
5457 % If the \pkg{amsmath} or \pkg{exscale} package is loaded, it
5458 % will have defined \cs{bBigg@}; if not, the macros \cs{big} and
5459 % variants will have hard-coded point sizes as inherited through the ages
5460 % from \fn{plain.tex}. In this case we can kluge a little by
5461 % setting \cs{big@size} to \cs{p@}, so that our definition of
5462 % \cs{bBigg@} will work equally well with the different multipliers.
5464 \@ifundefined{bBigg@}{% not defined
5466 \def\big{\bBigg@{8.5}}\def\Big{\bBigg@{11.5}}%
5467 \def\bigg{\bBigg@{14.5}}\def\Bigg{\bBigg@{17.5}}%
5468 \def\biggg{\bBigg@{20.5}}\def\Biggg{\bBigg@{23.5}}%
5473 \vrule\@height#1\big@size\@width-\nulldelimiterspace
5480 \def\bigl#1{\mathopen\big{#1}\after@open}
5481 \def\Bigl#1{\mathopen\Big{#1}\after@open}
5482 \def\biggl#1{\mathopen\bigg{#1}\after@open}
5483 \def\Biggl#1{\mathopen\Bigg{#1}\after@open}
5484 \def\bigggl#1{\mathopen\biggg{#1}\after@open}
5485 \def\Bigggl#1{\mathopen\Biggg{#1}\after@open}
5487 \def\bigr#1{\mathclose\big{#1}\after@close}
5488 \def\Bigr#1{\mathclose\Big{#1}\after@close}
5489 \def\biggr#1{\mathclose\bigg{#1}\after@close}
5490 \def\Biggr#1{\mathclose\Bigg{#1}\after@close}
5491 \def\bigggr#1{\mathclose\biggg{#1}\after@close}
5492 \def\Bigggr#1{\mathclose\Biggg{#1}\after@close}
5494 %% No change needed, I think. [mjd,1998/12/04]
5495 %%\def\bigm{\mathrel\big}
5496 %%\def\Bigm{\mathrel\Big}
5497 %%\def\biggm{\mathrel\bigg}
5498 %%\def\Biggm{\mathrel\Bigg}
5499 %%\def\bigggm{\mathrel\biggg}
5500 %%\def\Bigggm{\mathrel\Biggg}
5504 % \begin{macro}{\m@@DeL} \begin{macro}{\d@@DeL}
5505 % \begin{macro}{\m@@DeR} \begin{macro}{\d@@DeR}
5506 % \begin{macro}{\m@@DeB} \begin{macro}{\d@@DeB}
5507 % Original definition of \cs{m@DeL} from
5508 % \pkg{flexisym} is as follows. \cs{m@DeR} and
5509 % \cs{m@DeB} are the same except for the math class number.
5510 % \begin{literalcode}
5511 % \def\m@DeL#1#2#3{%
5512 % \delimiter"4\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 }
5515 % Save the existing meanings of \cs{m@De[LRB]}.
5517 \let\m@@DeL\m@DeL \let\m@@DeR\m@DeR \let\m@@DeB\m@DeB
5519 \delimiter"4\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 \after@open
5522 \delimiter"5\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 \after@close
5525 \delimiter"0\@xp\delim@a\csname sd@#1#2#3\endcsname #1#2#3 \after@bidir
5528 %%BRM: These weren't defined, but apparently should be.
5529 % Are these the right values???
5531 \let\m@@DeA\m@DeA\let\d@@DeA\m@DeA%
5541 % \begin{macro}{\after@open}
5542 % \begin{macro}{\after@close}
5543 % \begin{macro}{\after@bidir}
5544 % \begin{macro}{\zero@bop}
5545 % \begin{macro}{\bop@incr}
5546 % \cs{after@open} and \cs{after@close} are carefully
5547 % written to avoid the use of grouping and to run as fast as possible.
5548 % \cs{zero@bop} is the value used for \cs{prebinoppenalty} at
5549 % delimiter level 0, while \cs{bop@incr} is added for each level of
5550 % nesting. The standard values provide that breaks will be prohibited
5551 % within delimiters below nesting level 2.
5553 \let\after@bidir\@empty
5554 \mathchardef\zero@bop=888 \relax
5555 \mathchardef\bop@incr=4444 \relax
5557 \global\advance\lr@level\@ne
5558 \prebinoppenalty\bop@incr \multiply\prebinoppenalty\lr@level
5559 \advance\prebinoppenalty\zero@bop
5560 \ifnum\eqbreakdepth<\lr@level
5563 % Inside delimiters, add some fillglue before binops so that a broken off
5564 % portion will get thrown flush right. Also shift it slightly
5565 % further to the right to ensure that it clears the opening delimiter.
5568 \eq@binoffset=\eqbinoffset
5569 \advance\eq@binoffset\lr@level\eqdelimoffset plus1fill\relax
5570 \def\dt@fill@cancel{\hskip\z@ minus1fill\relax}%
5572 \penalty\@M % BRM: discourage break after an open fence?
5575 \global\advance\lr@level\m@ne
5576 \prebinoppenalty\bop@incr \multiply\prebinoppenalty\lr@level
5577 \advance\prebinoppenalty\zero@bop
5578 \ifnum\eqbreakdepth<\lr@level
5579 \else \let\m@Bin\d@@Bin
5582 % When we get back to level 0, no delimiters, remove the stretch
5583 % component of \cs{eqbinoffset}.
5585 \ifnum\lr@level<\@ne \eq@binoffset=\eqbinoffset\relax \fi
5596 % \begin{macro}{\subsup@flag}
5597 % \begin{macro}{\ss@scan}
5598 % \cs{ss@scan} is called after a \cs{right} delimiter and
5599 % looks ahead for sub and superscript tokens.
5600 % If sub and/or superscripts are present, we adjust the line-ending
5601 % penalty to distinguish the various cases (sub, sup, or both).
5602 % This facilitates the later work of excising the sub/sup box and
5603 % reattaching it with proper shifting.
5605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5606 % Sub/Superscript measurement
5607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5608 % BRM: There's possibly a problem here.
5609 % When \cs{ss@scan} gets invoked after a \cs{left}...\cs{right} pair in the LHS
5610 % during \cs{eq@measure}, it produces an extra box (marked with \cs{penalty} 3);
5611 % Apparently \cs{eq@repack} expects only one for the LHS.
5612 % The end result is \cs{eq@wdL} => 0.0pt !!! (or at least very small)
5614 \let\subsup@flag=\count@
5615 \def\ss@delim@a#1#2#3#4{\xdef\right@delim@code{\number"#2#3#4}}
5617 % The argument of \cs{ss@scan} is an expanded form of a
5618 % right-delimiter macro.
5619 % We want to use the last three digits in the expansion
5620 % to define \cs{right@delim@code}.
5621 % The assignment to a temp register is just a way to scan away the
5622 % leading digits that we don't care about.
5626 % This part of the code.
5629 \let\delim@a\ss@delim@a \@tempcnta#1\relax
5631 \subsup@flag\@M \afterassignment\ss@scan@a \let\@let@token=}
5633 \ifx\@let@token\sb \advance\subsup@flag\@ne\else
5634 \ifx\@let@token\sp \advance\subsup@flag\tw@\else
5636 \expandafter\@firstoftwo % gobble \ss@scan@b
5638 \ss@scan@b\@let@token
5643 \def\ss@scan@b#1#2{#1{%
5647 \let\m@Bin\m@@Bin \let\m@Rel\m@@Rel
5648 #2}\afterassignment\ss@scan@a \let\@let@token=}%
5650 % We need to keep following glue from disappearing
5651 % \mdash \eg , a thickmuskip or medmuskip from a following mathrel or
5655 \@@vadjust{\penalty\thr@@}%
5656 \penalty\right@delim@code \penalty-\subsup@flag \keep@glue
5663 % \begin{macro}{\eq@lrunpack}
5664 % For \cs{eq@lrunpack} we need to break open a left-right box and
5665 % reset it just in case it contains any more special breaks. After
5666 % it is unpacked the recursion of \cs{eq@repack} will continue,
5667 % acting on the newly created lines.
5669 \def\eq@lrunpack{\setbox\z@\lastbox
5671 % We remove the preceding glue item and deactivate
5672 % baselineskip for the next line, otherwise we would end up with
5673 % three items of glue (counting parskip) at this point instead of
5674 % the single one expected by our recursive repacking
5677 \unskip \nointerlineskip
5679 % Then we open box 0, take the left-right box at the right end of
5680 % it, and break that open. If the line-ending penalty is greater than
5681 % 10000, it means a sub and/or superscript is present on the right
5682 % delimiter and the box containing them must be taken off first.
5684 \noindent\unhbox\z@ \unskip
5685 \subsup@flag-\lastpenalty \unpenalty
5686 \xdef\right@delim@code{\number\lastpenalty}%
5688 \ifnum\subsup@flag>\@M
5689 \advance\subsup@flag-\@M
5691 \else \setbox\tw@\box\voidb@x
5694 \ifvoid\tw@ \unhbox\z@
5695 \else \lrss@reattach % uses \subsup@flag, box\z@, box\tw@
5698 % The reason for adding a null last line here is that the last
5699 % line will contain parfillskip in addition to rightskip, and a final
5700 % penalty of $10000$ instead of $-1000N$
5701 % ($1\leq N\leq 9$), which would interfere with the usual
5702 % processing. Setting a null last line and discarding it dodges
5703 % this complication. The penalty value $-10001$ is a no-op case
5704 % in the case statement of \cs{eq@repacka}.
5706 \penalty-\@Mi\z@rule\@@par
5707 \setbox\z@\lastbox \unskip\unpenalty
5708 %%{\showboxbreadth\maxdimen\showboxdepth99\showlists}%
5714 % \begin{macro}{\lrss@reattach}
5716 % Well, for a small self-contained computation, carefully
5717 % hand-allocated dimens should be safe enough. But let the
5718 % maintainer beware! This code cannot be arbitrarily transplanted
5719 % or shaken up without regard to grouping and interaction with other
5720 % hand-allocated dimens.
5722 \dimendef\sub@depth=8 \dimendef\sup@base=6
5723 \dimendef\prelim@sub@depth=4 \dimendef\prelim@sup@base=2
5724 \def\sym@xheight{\fontdimen5\textfont\tw@}
5725 \def\sup@base@one{\fontdimen13\textfont\tw@}
5726 \def\sub@base@one{\fontdimen16\textfont\tw@}
5727 \def\sub@base@two{\fontdimen17\textfont\tw@}
5729 % Note that only \cs{sup@drop} and \cs{sub@drop} come from
5730 % the next smaller math style.
5732 \def\sup@drop{\fontdimen18\scriptfont\tw@}
5733 \def\sub@drop{\fontdimen19\scriptfont\tw@}
5735 % Provide a mnemonic name for the math axis fontdimen, if it's not
5738 \providecommand{\mathaxis}{\fontdimen22\textfont\tw@}
5741 % Assumes box 2 contains the sub/sup and box 0 contains the left-right
5742 % box. This is just a repeat of the algorithm in \fn{tex.web},
5743 % with some modest simplifications from knowing that this is only going to
5744 % be called at top level in a displayed equation, thus always mathstyle =
5745 % uncramped displaystyle.
5747 \def\lrss@reattach{%
5749 % "The TeXbook" Appendix G step 18:
5750 \setlength\prelim@sup@base{\ht\z@-\sup@drop}%
5751 \setlength\prelim@sub@depth{\dp\z@ +\sub@drop}%
5753 \ifcase\subsup@flag % case 0: this can't happen
5754 \or \lr@subscript % case 1: subscript only
5755 \or \lr@superscript % case 2: superscript only
5756 \else \lr@subsup % case 3: sub and superscript both
5763 \sub@depth\sub@base@one
5764 \ifdim\prelim@sub@depth>\sub@depth \sub@depth\prelim@sub@depth\fi
5765 \setlength\dim@a{\ht\tw@ -.8\sym@xheight}%
5766 \ifdim\dim@a>\sub@depth \sub@depth=\dim@a \fi
5767 \twang@adjust\sub@depth
5768 \lower\sub@depth\box\tw@
5773 \def\lr@superscript{%
5774 \sup@base\sup@base@one
5775 \ifdim\prelim@sup@base>\sup@base \sup@base\prelim@sup@base\fi
5776 \setlength\dim@a{\dp\tw@ -.25\sym@xheight}%
5777 \ifdim\dim@a>\sup@base \sup@base\dim@a \fi
5778 \twang@adjust\sup@base
5779 \raise\sup@base\box\tw@
5785 \sub@depth\sub@base@two
5786 \ifdim\prelim@sub@depth>\sub@depth \sub@depth\prelim@sub@depth \fi
5787 \twang@adjust\sub@depth
5788 \lower\sub@depth\box\tw@
5792 % For delimiters that curve top and bottom, the twang factor allows
5793 % horizontal shifting of the sub and superscripts so they don't
5794 % fall too far away (or too close for that matter). This is
5795 % accomplished by arranging for (\eg ) \verb"\right\rangle" to leave
5796 % a penalty $N$ in the math list before the subsup penalty that triggers
5797 % \cs{lrss@reattach}, where $N$ is the mathcode of
5798 % \cs{rangle} (ignoring \dquoted{small} variant).
5800 \def\twang@adjust#1{%
5802 \@ifundefined{twang@\right@delim@code}{}{%
5803 \setlength\dim@d{#1-\mathaxis}%
5804 % put an upper limit on the adjustment
5805 \ifdim\dim@d>1em \dim@d 1em \fi
5806 \kern\csname twang@\right@delim@code\endcsname\dim@d
5811 % The method used to apply a \dquoted{twang} adjustment is just an
5812 % approximate solution to a complicated problem.
5813 % We make the following assumptions that hold true, approximately,
5814 % for the most common kinds of delimiters:
5817 % The right delimiter is symmetrical top to bottom.
5820 % \item There is an upper limit on the size of the adjustment.
5823 % \item When we have a superscript, the amount of left-skew that we
5824 % want to apply is linearly proportional to the distance of the bottom
5825 % left corner of the superscript from the math axis, with the ratio
5826 % depending on the shape of the delimiter symbol.
5831 % By symmetry, Assumption 3 is true also for subscripts (upper left
5833 % Assumption 2 is more obviously true for parens and braces, where the
5834 % largest super-extended versions consist of truly vertical parts with
5835 % slight bending on the ends, than it is for a \cs{rangle}.
5836 % But suppose for the sake of expediency that it is
5837 % approximately true for rangle symbols also.
5840 % Here are some passable twang factors for the most common types of
5841 % delimiters in \fn{cmex10}, as determined by rough measurements from
5842 % magnified printouts.
5843 % \begin{literalcode}
5844 % vert bar, double vert: 0
5845 % square bracket: -.1
5850 % Let's provide a non-private command for changing the twang factor of
5853 \newcommand{\DeclareTwang}[2]{%
5854 \ifcat.\@nx#1\begingroup
5855 \lccode`\~=`#1\lowercase{\endgroup \DeclareTwang{~}}{#2}%
5857 \@xp\decl@twang#1?\@nil{#2}%
5861 % Note that this is dependent on a fixed interpretation of the
5862 % mathgroup number \arg4 .
5864 \def\decl@twang#1#2#3#4#5#6#7\@nil#8{%
5865 \@namedef{twang@\number"#4#5#6}{#8}%
5867 \DeclareTwang{\rangle}{-.4}
5868 \DeclareTwang{)}{-.33}
5869 \DeclareTwang{\rbrace}{-.25}
5876 % \section{Series of expressions}
5877 % The \env{dseries} environment is for a display
5878 % containing a series of expressions of the form \quoted{A, B} or \quoted{A and
5879 % B} or \quoted{A, B, and C} and so on. Typically the expressions
5880 % are separated by a double quad of space. If the expressions in a
5881 % series don't all fit in a single line, they are continued onto extra
5882 % lines in a ragged-center format.
5884 \newenvironment{dseries}{\let\eq@hasNumber\@True \@optarg\@dseries{}}{}%
5885 \def\enddseries#1{\check@punct@or@qed}%
5888 % And the unnumbered version of same.
5890 \newenvironment{dseries*}{\let\eq@hasNumber\@False \@optarg\@dseries{}}{}%
5891 \@namedef{enddseries*}#1{\check@punct@or@qed}%
5892 \@namedef{end@dseries*}{\end@dseries}%
5895 % Turn off the special breaking behavior of mathrels \etc for math
5896 % formulas embedded in a \env{dseries} environment.
5898 %BRM: DS Expermient: Use alternative display setup.
5900 % \def\display@setup{\displaystyle}%
5901 \let\display@setup\dseries@display@setup
5902 % Question: should this be the default for dseries???
5903 % \let\eq@centerlines\@True
5904 \global\eq@wdCond\z@
5906 % BRM: use special layout for dseries
5909 \@dmath[layout={M},#1]%
5910 \mathsurround\z@\@@math \penalty\@Mi
5911 \let\endmath\ends@math
5914 % BRM: Tricky to cleanup space OR add space ONLY BETWEEN math!
5916 \ifdim\lastskip<.3em \unskip
5917 \else\ifnum\lastpenalty<\@M \dquad\fi\fi
5920 %BRM: Tricky; if a subformula breaks, we'd like to start the next on new line!
5922 \def\postmath{\unpenalty\eq@addpunct \penalty\intermath@penalty \dquad \@ignoretrue}%
5927 \@@endmath \mathsurround\z@ \end@dmath
5930 % BRM: Try this layout for dseries: Essentially layout i, but w/o
5931 % limit to 1 line. And no fallback!
5933 \def\eq@try@layout@M{%
5934 \edef\@parshape{\parshape 1 0pt \the\eq@linewidth\relax}%
5938 % BRM: Tricky to get right value here.
5939 % Prefer breaks between formula if we've got to break at all.
5941 %\def\intermath@penalty{-201}%
5942 \def\intermath@penalty{-221}%
5944 % BRM: A bit tighter than it was ( 1em minus.25em )
5946 %\newcommand\dquad{\hskip0.4em}
5947 \newcommand\dquad{\hskip0.6em minus.3em}
5948 \newcommand\premath{}\newcommand\postmath{}
5951 % Change the \env{math} environment to add
5952 % \cs{premath} and \cs{postmath}. They are no-ops except
5953 % inside a \env{dseries} environment.
5955 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5956 % Redefinition of math environment to take advantage of dseries env.
5958 \renewenvironment{math}{%
5959 \leavevmode \premath
5960 \ifmmode\@badmath\else\@@math\fi
5962 \ifmmode\@@endmath\else\@badmath\fi
5964 \def\ends@math#1{\check@punct@or@qed}
5966 \ifmmode\@@endmath\else\@badmath\fi
5974 % \section{Equation groups}
5975 % For many equation groups the strategy is easy: just center each
5976 % equation individually following the normal rules for a single
5977 % equation. In some groups, each equation gets its own number; in
5978 % others, a single number applies to the whole group (and may need to be
5979 % vertically centered on the height of the group). In still other
5980 % groups, the equations share a parent number but get individual equation
5981 % numbers consisting of parent number plus a letter.
5983 % If the main relation symbols in a group of equations are to be
5984 % aligned, then the final alignment computations cannot be done until the
5985 % end of the group \mdash \ie , the horizontal positioning of the first
5986 % $n - 1$ equations cannot be done immediately. Yet because of
5987 % the automatic line breaking, we cannot calculate an initial value of
5988 % RHS-max over the whole group unless we do a trial run on each equation
5989 % first to find an RHS-max for that equation. Once we know RHS-group-max
5990 % and LHS-group-max we must redo the trial set of each equation because
5991 % they may affect the line breaks. If the second trial for an
5992 % equation fails (one of its lines exceeds the available width), but
5993 % the first one succeeded, fall back to the first trial, \ie let that
5994 % equation fall out of alignment with the rest of the group.
5997 % All right then, here is the general idea of the whole algorithm for
5999 % To start with, ignore the possibility of equation numbers so that
6000 % our equation group has the form:
6001 % \begin{literalcode}
6002 % LHS[1] RHS[1,1] RHS[1,2] ... RHS[1,n[1]]
6003 % LHS[2] RHS[2,1] RHS[2,2] ... RHS[2,n[2]]
6005 % LHS[3] RHS[3,1] RHS[3,2] ... RHS[3,n[3]]
6007 % The number of RHS's might not be the same for all of the
6009 % First, accumulate all of the equation contents in a queue, checking
6010 % along the way to find the maximum width of all the LHS's and the maximum
6011 % width of all the RHS's.
6012 % Call these widths maxwd\_L and maxwd\_R.
6013 % Clearly if maxwd\_L + maxwd\_R is less than or equal to the available
6014 % equation width then aligning all of the equations is going to be simple.
6017 % Otherwise we are going to have to break at least one of the RHS's
6018 % and/or at least one of the LHS's.
6019 % The first thing to try is using maxwd\_L for the LHS's and breaking
6020 % all the RHS's as needed to fit in the remaining space.
6021 % However, this might be a really dumb strategy if one or more of the
6022 % LHS's is extraordinarily wide.
6023 % So before trying that we check whether maxwd\_L exceeds some
6024 % threshold width beyond which it would be unsensible not to break the LHS.
6025 % Such as, max(one-third of the available width; six ems), or
6026 % something like that.
6027 % Or how about this?
6028 % Compare the average LHS width and RHS width and divide up the available
6029 % width in the same ratio for line breaking purposes.
6032 % BRM: Fairly broad changes; it mostly didn't work before (for me).
6034 % \begin{description}
6035 % \item[\cs{begin}\csarg{dgroup} produces a `numbered' group]
6036 % The number is the next equation number.
6037 % There are 2 cases:
6039 % \item If ANY contained equations are numbered (|\begin{dmath}|),
6040 % then they will be subnumbered: eg 1.1a
6041 % and the group number is not otherwise displayed.
6042 % \item If ALL contained equations are unnumbered (|\begin{dmath*}|)
6043 % then the group, as a whole, gets a number displayed,
6044 % using the same number placement as for equations.
6046 % \item[\cs{begin}\csarg{dgroup*} produces an unnumbered group.]
6047 % Contained equations are numbered, or not, as normal.
6048 % But note that in the mixed case, it's too late to
6049 % force the unnumbered eqns to \cs{retry@with@number}
6050 % We'll just do a simple check of dimensions, after the fact,
6051 % and force a shiftnumber if we're stuck.
6053 % NOTE: Does this work for dseries, as well? (alignment?)
6055 % NOTE: Does \cs{label} attach to the expected thing?
6057 % \item[For number placement] We use shiftnumber placement on ALL equations
6058 % if ANY equations need it, or if an unnumbered equation is too
6059 % wide to be aligned, given that the group or other eqns are numbered.
6060 % [does this latter case interract with the chosen alignment?]
6062 % \item[For Alignment]
6063 % As currently coded, it tries to align on relations, by default.
6064 % If LHS's are not all present, or too long, it switches to left-justify.
6065 % Maybe there are other cases that should switch?
6066 % Should there be a case for centered?
6068 % NOTE: Should there be some options to choose alignment?
6071 % \begin{macro}{\eq@group}
6072 % \begin{macro}{\GRP@top}
6075 \let\eq@group\@False
6076 \let\grp@shiftnumber\@False
6077 \let\grp@hasNumber\@False
6078 \let\grp@eqs@numbered\@False
6079 \let\grp@aligned\@True
6086 % Definition of the \env{dgroup} environment.
6088 \newenvironment{dgroup}{%
6089 \let\grp@hasNumber\@True\@optarg\@dgroup{}%
6097 \newenvironment{dgroup*}{%
6098 \let\grp@hasNumber\@False\@optarg\@dgroup{}%
6103 %<trace> \breqn@debugmsg{=== DGROUP ==================================================}%
6104 \let\eq@group\@True \global\let\eq@GRP@first@dmath\@True
6105 \global\GRP@queue\@emptytoks \global\setbox\GRP@box\box\voidb@x
6106 \global\let\GRP@label\@empty
6107 \global\grp@wdL\z@\global\grp@wdR\z@\global\grp@wdT\z@
6108 \global\grp@linewidth\z@\global\grp@wdNum\z@
6109 \global\let\grp@eqs@numbered\@False
6110 \global\let\grp@aligned\@True
6111 \global\let\grp@shiftnumber\@False
6113 \setkeys{breqn}{#1}%
6114 \if\grp@hasNumber \grp@setnumber \fi
6117 \EQ@displayinfo \grp@finish
6118 \if\grp@hasNumber\grp@resetnumber\fi
6121 % If the \pkg{amsmath} package is not loaded the parentequation
6122 % counter will not be defined.
6124 \@ifundefined{c@parentequation}{\newcounter{parentequation}}{}
6128 \global\let\GRP@label\@empty
6129 \def\add@grp@label{%
6130 \ifx\@empty\GRP@label
6131 \else \GRP@label \global\let\GRP@label\@empty
6135 % Before sending down the `equation' counter to the subordinate level,
6136 % set the current number in \cs{EQ@numbox}. The
6137 % \cs{eq@setnumber} function does everything we need here. If
6138 % the child equations are unnumbered, \cs{EQ@numbox} will retain the
6139 % group number at the end of the group.
6141 \def\grp@setnumber{%
6142 \global\let\GRP@label\next@label \global\let\next@label\@empty
6143 % Trick \eq@setnumber to doing our work for us.
6144 \let\eq@hasNumber\@True
6147 % Define \cn{theparentequation} equivalent to current
6148 % \cn{theequation}. \cn{edef} is necessary to expand the
6149 % current value of the equation counter. This might in rare cases
6150 % cause something to blow up, in which case the user needs to add
6153 \global\sbox\GRP@numbox{\unhbox\EQ@numbox}%
6155 \let\eq@hasNumber\@False
6156 \let\eq@number\@empty
6159 \protected@edef\theparentequation{\theequation}%
6160 \setcounter{parentequation}{\value{equation}}%
6162 % And set the equation counter to 0, so that the normal incrementing
6163 % processes will produce the desired results if the child equations are
6166 \setcounter{equation}{0}%
6167 \def\theequation{\theparentequation\alph{equation}}%
6168 %<trace> \breqn@debugmsg{Group Number \theequation}%
6171 % At the end of a group, need to reset the equation counter.
6173 \def\grp@resetnumber{%
6174 \setcounter{equation}{\value{parentequation}}%
6177 \newbox\GRP@wholebox
6179 % Save data for this equation in the group
6181 % \item push the trial data onto end of \cs{GRP@queue}.
6182 % \item push an hbox onto the front of \cs{GRP@box} containing:
6183 % \cs{EQ@box}, \cs{EQ@copy}, \cs{penalty} 1 and \cs{EQ@numbox}.
6185 % \begin{macro}{\grp@push}
6187 % For putting the equation on a queue.
6190 \global\GRP@queue\@xp\@xp\@xp{\@xp\the\@xp\GRP@queue
6191 \@xp\@elt\@xp{\EQ@trial}%
6193 \global\setbox\GRP@box\vbox{%
6194 \hbox{\box\EQ@box\box\EQ@copy\penalty\@ne\copy\EQ@numbox}%
6198 \if\eq@isIntertext\else
6199 \ifdim\eq@wdL>\grp@wdL \global\grp@wdL\eq@wdL \fi
6200 \ifdim\eq@wdT>\grp@wdT \global\grp@wdT\eq@wdT \fi
6201 \setlength\dim@a{\eq@wdT-\eq@wdL}%
6202 \ifdim\dim@a>\grp@wdR \global\grp@wdR\dim@a \fi
6203 \ifdim\eq@linewidth>\grp@linewidth \global\grp@linewidth\eq@linewidth\fi
6205 \global\let\grp@eqs@numbered\@True
6206 \ifdim\eq@wdNum>\grp@wdNum\global\grp@wdNum\eq@wdNum\fi
6208 \if\EQ@hasLHS\else\global\let\grp@aligned\@False\fi
6209 \if D\eq@layout \global\let\grp@aligned\@False\fi % Layout D (usually) puts rel on 2nd line.
6210 \if\eq@shiftnumber\global\let\grp@shiftnumber\@True\fi % One eq shifted forces all.
6215 % \begin{macro}{\grp@finish}
6217 % Set accumulated equations from a \env{dgroup} environment.
6219 % BRM: Questionable patch!!
6220 % When processing the \cs{GRP@queue}, put it into a \cs{vbox}, then \cs{unvbox} it.
6221 % This since there's a bizarre problem when the \cs{output} routine
6222 % gets invoked at an inopportune moment: All the not-yet-processed
6223 % \cs{GRP@queue} ends up in the \cs{@freelist} and bad name clashes happen.
6224 % Of course, it could be due to some other problem entirely!!!
6227 % \debug@box\GRP@box
6228 % \breqn@debugmsg{\GRP@queue: \the\GRP@queue}%
6230 % == Now that we know the collective measurements, make final decision
6231 % about alignment \& shifting. Check if alignment is still possible
6233 \setlength\dim@a{\grp@wdL+\grp@wdR-4em}% Allowance for shrink?
6235 \ifdim\dim@a>\grp@linewidth
6236 \global\let\grp@aligned\@False
6240 % If we're adding an unshifted group number that equations didn't know
6241 % about, re-check shifting
6243 \addtolength\dim@a{\grp@wdNum }% Effective length
6246 \if\@And{\grp@hasNumber}{\@Not\grp@eqs@numbered}
6247 \ifdim\dim@a>\grp@linewidth
6248 \global\let\grp@shiftnumber\@True
6253 % If we can still align, total width is sum of maximum LHS \& RHS
6256 \global\grp@wdT\grp@wdL
6257 \global\advance\grp@wdT\grp@wdR
6260 \breqn@debugmsg{======= DGROUP Formatting
6261 \MessageBreak==== \grp@wdL=\the\grp@wdL, \grp@wdR=\the\grp@wdR
6262 \MessageBreak==== Shift Number=\theb@@le\grp@shiftnumber, Eqns. numbered=\theb@@le\grp@eqs@numbered
6263 \MessageBreak==== Aligned=\theb@@le\grp@aligned
6264 \MessageBreak==== \grp@wdNum=\the\grp@wdNum}%
6267 % BRM: Originally this stuff was dumped directly, without capturing it
6270 \setbox\GRP@wholebox\vbox{%
6275 % If we're placing a group number (not individual eqn numbers)
6276 % NOTE: For now, just code up LM number
6277 % NOTE: Come back and handle other cases.
6278 % NOTE: Vertical spacing is off, perhaps because of inter eqn. glue
6280 % A bit of a hack to get the top spacing correct. Fix this logic
6281 % properly some day. Also, we do the calculation in a group for
6284 \global\let\eq@GRP@first@dmath\@True
6286 \dmath@first@leftskip
6287 \eq@topspace{\vskip\parskip}%
6289 \if\@And{\grp@hasNumber}{\@Not{\grp@eqs@numbered}}%
6290 % \eq@topspace{\vskip\parskip}%
6292 \copy\GRP@numbox \penalty\@M
6296 (\ht\GRP@wholebox+\dp\GRP@wholebox+\ht\GRP@numbox-\dp\GRP@numbox)/2}%
6297 \setlength\skip@c{\dim@a-\ht\GRP@numbox}%
6298 \vglue\skip@c% NON discardable
6299 \copy\GRP@numbox \penalty\@M
6301 \breqn@debugmsg{GROUP NUMBER: preskip:\the\skip@c, postkern:\the\dim@a, height:\the\ht\GRP@wholebox,
6302 \MessageBreak==== box height:\the\ht\GRP@numbox, box depth:\the\dp\GRP@numbox}%
6305 \kern-\abovedisplayskip % To cancel the topspace above the first eqn.
6309 %\debug@box\GRP@wholebox
6311 \unvbox\GRP@wholebox
6314 % We'd need to handle shifted, right number here, too!!!
6316 \eq@botspace % not needed unless bottom number?
6321 % \begin{macro}{\eqgrp@elt}
6323 % Mission is to typeset the next equation from the group queue.
6325 % The arg is an \cs{EQ@trial}
6328 \global\setbox\GRP@box\vbox{%
6331 \setbox\tw@\hbox{\unhbox\z@
6332 \ifnum\lastpenalty=\@ne
6334 \global\setbox\EQ@numbox\lastbox
6337 \global\setbox\EQ@copy\lastbox
6338 \global\setbox\EQ@box\lastbox
6341 \begingroup \let\eq@botspace\relax
6344 \vskip\belowdisplayskip
6354 % Override the \cs{eq@trial} data as needed for this equation in this group
6355 % NOTE: w/ numbering variations (see above), we may need to tell
6356 % \cs{eq@finish} to allocate space for a number, but not actually have one
6360 % For aligned (possibly becomes an option?)
6361 % For now ASSUMING we started out as CLM!!!
6365 % compute nominal left for centering the group
6367 \setlength\dim@a{(\grp@linewidth-\grp@wdT)/2}%
6369 % Make sure L+R not too wide; should already have unset alignment
6371 \ifdim\dim@a<\z@\dim@a=\z@\fi
6372 \dim@b\if L\eqnumside\grp@wdNum\else\z@\fi
6374 % make sure room for number on left, if needed.
6376 \if\grp@shiftnumber\else
6377 \ifdim\dim@b>\dim@a\dim@a\dim@b\fi
6380 \addtolength\dim@a{\grp@wdL-\eq@wdL}%
6384 \let\eq@shiftnumber\@True
6387 % Could set |\def\eqnumplace{T}| (or even (m) if indentation is enough).
6389 % NOTE: Work out how this should interact with the various formats!!!
6390 % NOTE: should recognize the case where the LHS's are a bit Wild,
6391 % and then do simple left align (not on relation)
6398 % \section{The \env{darray} environment}
6399 % There are two potential applications for darray. One
6400 % is like eqnarray where the natural structure of the material crosses the
6401 % table cell boundaries, and math operator spacing needs to be preserved
6402 % across cell boundaries. And there is also the feature of
6403 % attaching an equation number to each row. The other application
6404 % is like a regular array but with automatic displaystyle math in each
6405 % cell and better interline spacing to accommodate outsize cell
6406 % contents. In this case it is difficult to keep the vert ruling
6407 % capabilities of the standard \env{array} environment without
6408 % redoing the implementation along the lines of Arseneau's
6409 % \pkg{tabls} package. Because the vert ruling feature is at
6410 % cross purposes with the feature of allowing interline stretch and page
6411 % breaks within a multiline array of equations, the \env{darray}
6412 % environment is targeted primarily as an alternative to
6413 % \env{eqnarray}, and does not support vertical ruling.
6415 % Overall strategy for \env{darray} is to use
6416 % \cs{halign} for the body. In the case of a group, use a
6417 % single halign for the whole group!
6419 % What about intertext?
6422 % That's the most reliable way
6423 % to get accurate column widths. Don't spread the halign to the
6424 % column width, just use the natural width. Then, if we repack the
6425 % contents of the halign into \cs{EQ@box} and \cs{EQ@copy}, as
6426 % done for dmath, and twiddle a bit with the widths of the first and last
6427 % cell in each row, we can use the same algorithms for centering and
6428 % equation number placement as dmath! As well as handling footnotes
6429 % and vadjust objects the same way.
6431 % We can't just use \cs{arraycolsep} for \env{darray}, if
6432 % we want to be able to change it without screwing up interior arrays.
6433 % So let's make a new colsep variable. The initial value is
6434 % \quoted{2em, but let it shrink if necessary}.
6436 \newskip\darraycolsep \darraycolsep 20pt plus1fil minus12pt
6438 % Let's make a nice big default setup with eighteen columns, split up
6439 % into six sets of lcr like \env{eqnarray}.
6441 \newcount\cur@row \newcount\cur@col
6444 \setbox\z@\hbox{$\displaystyle####\m@th$}\@nx\col@box
6447 \setbox\z@\hbox{$\displaystyle\mathord{}####\mathord{}\m@th$}\@nx\col@box
6449 &\cur@col#3 \setbox\z@\hbox{$\displaystyle####\m@th$}\@nx\col@box
6450 \hfil\tabskip\darraycolsep
6452 \xdef\darray@preamble{%
6453 \@tempa 123&\@tempa 456&\@tempa 789%
6454 &\@tempa{10}{11}{12}&\@tempa{13}{14}{15}&\@tempa{16}{17}{18}%
6457 \@ifundefined{Mathstrut@}{\let\Mathstrut@\strut}{}
6458 \def\darray@cr{\Mathstrut@\cr}
6461 %\breqn@debugmsg{Col \number\cur@row,\number\cur@col: \the\wd\z@\space x \the\ht\z@+\the\dp\z@}%
6465 \newenvironment{darray}{\@optarg\@darray{}}{}
6467 %<trace> \breqn@debugmsg{=== DARRAY ==================================================}%
6468 \if\eq@group\else\eq@prelim\fi
6470 % Init the halign preamble to empty, then unless the \quoted{cols} key is
6471 % used to provide a non-null preamble just use the
6472 % default darray preamble which is a multiple lcr.
6474 \global\let\@preamble\@empty
6475 \setkeys{breqn}{#1}%
6476 \the\eqstyle \eq@setnumber
6477 \ifx\@preamble\@empty \global\let\@preamble\darray@preamble \fi
6479 % \let\check@mathfonts\relax % tempting, but too risky
6480 \@xp\let\csname\string\ \endcsname\darray@cr
6481 \setbox\z@\vbox\bgroup
6482 \everycr{\noalign{\global\advance\cur@row\@ne}}%
6483 \tabskip\z@skip \cur@col\z@
6485 \penalty\@ne % flag for \dar@repack
6486 \halign\@xp\bgroup\@preamble
6489 % Assimilate following punctuation.
6491 \def\enddarray#1{\check@punct@or@qed}
6493 \ifvmode\else \eq@addpunct \Mathstrut@\fi\crcr \egroup
6499 % The \cs{dar@capture} function steps back through the
6500 % list of row boxes and grinds them up in the best possible way.
6503 %% \showboxbreadth\maxdimen\showboxdepth99\showlists
6504 \eq@wdL\z@ \eq@wdRmax\z@
6509 % The \cs{dar@repack} function is a variation of
6515 %\batchmode{\showboxbreadth\maxdimen\showboxdepth99\showbox\tw@}\errorstopmode
6516 \global\setbox\EQ@box\hbox{%
6517 \hbox{\unhcopy\tw@\unskip}\penalty-\@M \unhbox\EQ@box}%
6518 \global\setbox\EQ@copy\hbox{%
6519 \hbox{\unhbox\tw@\unskip}\penalty-\@M \unhbox\EQ@copy}%
6521 \ifcase\lastpenalty \else\@xp\@gobble\fi
6529 % \section{Miscellaneous}
6530 % The \cs{condition} command. With
6531 % the star form, set the argument in math mode instead of text mode.
6532 % In a series of conditions, use less space between members of the
6533 % series than between the conditions and the main equation body.
6535 % BRM: Some modifications here, since I like for the condition
6536 % to go flush right. (thus, it also affects centering, margins, etc)
6538 \newskip\conditionsep \conditionsep=10pt minus5pt%
6539 \newcommand{\conditionpunct}{,}
6540 \let\cond@gobble\@firstofone
6541 \newcommand\condition{%
6542 \begingroup\@tempswatrue
6543 \@ifstar{\@tempswafalse \condition@a}\condition@a
6545 \newcommand\condition@a[2][\conditionpunct]{%
6546 \unpenalty\unskip\unpenalty\unskip % BRM Added
6548 \penalty -201\relax\hbox{}% Penalty to allow breaks here.
6550 \if@tempswa \@xp\hbox \else \@xp\condition@b\fi
6554 % BRM: Testing if I can measure conditions?
6556 \setbox\z@\if@tempswa\hbox{#2}\else\hbox{\textmath@setup #2}\fi
6557 \global\eq@wdCond\wd\z@
6558 \let\cond@gobble\@gobble
6561 % For a math condition.
6562 % This is called inside a group so we don't need extra grouping to
6563 % localize the effect of \cs{textmath@setup} which turns off the
6564 % line-breaking features of bin, rel, and delimiter symbols.
6566 \newcommand\condition@b[1]{%
6567 \cond@gobble{\hskip\conditionsep}%
6572 % The \env{dsuspend} environment. First the old one that didn't work.
6574 \newenvironment{XXXXdsuspend}{%
6575 \global\setbox\EQ@box\vbox\bgroup \@parboxrestore
6577 % If we are inside a list environment, \cs{displayindent} and
6578 % \cs{displaywidth} give us \cs{@totalleftmargin} and
6581 \parshape 1 \displayindent \displaywidth\relax
6582 \hsize=\columnwidth \noindent\ignorespaces
6586 % Let's try giving \cs{EQ@box} the correct height for the first
6587 % line and \cs{EQ@copy} the depth of the last line.
6589 \global\setbox\GRP@box\vbox{%
6590 \vbox{\copy\EQ@box\vtop{\unvbox\EQ@box}}%
6594 % Need to add a dummy element to \cs{GRP@queue}.
6596 \global\GRP@queue\@xp{\the\GRP@queue
6597 \@elt{\gdef\EQ@trial{}}%
6601 % And then the one that does work.
6603 \newenvironment{dsuspend}{%
6604 \global\setbox\EQ@box\vbox\bgroup \@parboxrestore
6605 \parshape 1 \displayindent \displaywidth\relax
6606 \hsize=\columnwidth \noindent\ignorespaces
6609 \global\setbox\GRP@box\vbox{%
6610 \hbox{\copy\EQ@box\vtop{\unvbox\EQ@box}}%
6613 \global\GRP@queue\@xp{\the\GRP@queue
6614 % \@elt{\gdef\EQ@trial{\let\eq@isIntertext\@True}}%
6615 \@elt{\let\eq@isIntertext\@True}%
6619 % Allow \cn{intertext} as a short form of the \env{dsuspend}
6620 % environment; it's more convenient to write, but it doesn't support
6621 % embedded verbatim because it reads the material as a macro argument.
6622 % To support simultaneous use of \pkg{amsmath} and
6623 % \pkg{breqn}, the user command \cs{intertext} is left alone
6624 % until we enter a \pkg{breqn} environment.
6626 \newcommand\breqn@intertext[1]{\dsuspend#1\enddsuspend}
6631 % \begin{macro}{\discretionarytimes}
6632 % Discretionary times sign. Standard \latex definition
6633 % serves only for inline math. Should the thin space be
6634 % included? Not sure.
6639 % Since \cs{eq@binoffset} is mu-glue, we can't use it directly
6640 % with \cs{kern} but have to measure it separately in a box.
6642 \setbox\z@\hbox{\mathsurround\z@$\mkern\eq@binoffset$}%
6644 \kern\the\wd\z@ \textchar\discretionarytimes
6648 \discretionary{\thinspace\textchar\discretionarytimes}{}{}%
6652 % This is only the symbol; it can be changed to some other symbol if
6655 \newcommand{\discretionarytimes}{\times}
6661 % \begin{macro}{\nref}
6663 % This is like \cs{ref} but doesn't apply font changes or other
6664 % guff if the reference is undefined.
6665 % And it is fully expandable for use as a label value.
6668 % Can break with Babel if author uses active characters in label key;
6669 % need to address that \begin{dn}
6676 \def\nref#1{\@xp\@nref\csname r@#1\endcsname}
6677 \def\@nref#1#2{\ifx\relax#1??\else \@xp\@firstoftwo#1\fi}
6678 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6688 % The usual endinput.
6698 % \item Alignment for equation groups.
6702 % Use dpc's code for package options in keyval form.
6705 % Encapsulate \dquoted{break math} into a subroutine taking suitable
6709 % Need a density check for layout S when linewidth is very small.
6712 % Make \verb":=" trigger a warning about using \cs{coloneq}
6715 % \item Ill-centered multiline equation (three-line case) in
6718 % \item Attaching a single group number.
6722 % Make sure to dump out box registers after done using them.
6724 % \item Do the implementation for \cs{eq@resume@parshape}.
6727 % \item Check on stackrel and buildrel and relbar and ???.
6730 % \item Test math symbols at the beginning of array cells.
6732 % \item Test \dbslash cmd in and out of delims.
6734 % \item Framing the equation body: the parshape and number placement
6735 % need adjusting when a frame is present.
6738 % \item Cascading line widths in list env.
6741 % \item Noalign option for dmath = multline arrangement?
6744 % \item Nocompact option, suggested 1998/05/19 by Andrew
6748 % \item \cs{delbreak} cmd to add discretionary space at a break
6749 % within delimiters.
6752 % \item Reduce above/below skip when the number is shifted.
6755 % \item Need a \cs{middelim} command for marking a delimiter symbol
6756 % as nondirectional if it has an innate directionality \verb"()[]" \etc .
6760 % \cs{xrightarrow} from amsmath won't participate in line
6761 % breaking unless something extra is done.
6762 % Make \cs{BreakingRel} and \cs{BreakingBin} functions?
6764 % \item Placement of number in an indented quotation or
6767 % \item If $LHSwd > 2em$, it might be a good idea to try with
6768 % eq@indentstep = 2em before shifting the number. Currently this
6769 % doesn't happen if the first trial pass (without the number)
6770 % succeeds with $indentstep = LHSwd > 2em$.
6773 % \item Read past \verb"\end{enumerate}" when checking
6774 % for \verb"\end{proof}"?
6777 % Look into using a \dquoted{qed-list} of environment names instead of
6778 % checking the existence of \cs{proofqed}.
6780 % \item Pick up the vadjust\slash footnote\slash mark handling.
6783 % \item Forcing\slash prohibiting page breaks after\slash before
6787 % \item Adding a spanner brace on the left and individual numbers on
6788 % the right (indy-numbered cases).
6791 % \item Provide \cs{shiftnumber}, \cs{holdnumber} to
6792 % override the decision.
6794 % \item Provide a mechanism for adjusting the vertical position of
6795 % the number. Here a version-specific selection macro would be
6797 % \begin{literalcode}
6799 % style={\foredition{1}{\raisenumber{13pt}}}
6805 % Add an alignleft option for an equation group to mean, break and
6806 % align to a ladder layout as usual within the equations, but for the
6807 % group alignment used the leftmost point (for equations that don't
6808 % have an LHS, this makes no difference).
6811 % Test with Arseneau's wrapfig for parshape\slash everypar
6815 % \item Fix up the macro/def elements.
6817 % \item Convert the literal examples in section \quoted{Equation types and
6818 % forms} to typeset form.
6821 % \item Compile comparison-examples: \eg , a standard equation
6822 % env with big left-right objects that don't shrink, versus how shrinking
6823 % can allow it to fit.
6826 % \item Frame the \dquoted{figures} since they are mostly
6833 % Possible enhancements:
6835 % \item Provide a \opt{pull} option meaning to pull the first
6836 % and last lines out to the margin, like the \env{multline}
6837 % environment of the \pkg{amsmath} package. Maybe this should
6838 % get an optional argument, actually, to specify the amount of space left
6841 % \item With the draft option, one would like to see the equation
6842 % labels in the left margin. Need to check with the
6843 % \pkg{showkeys} package.
6846 % \item Options for break preferences: if there's not enough room, do
6847 % we first shift the number, or first try to break up the equation
6848 % body?. In an aligned group, does sticking to the group alignment
6849 % take precedence over minimizing the number of line breaks needed for
6850 % individual equations?. And the general preferences probably need
6851 % to be overridable for individual instances.
6853 % \item Extend suppress-breaks-inside-delimiters support to inline
6854 % math (suggestion of Michael Doob).
6856 % \item Use belowdisplayshortskip above a dsuspend fragment if the
6857 % fragment is only one line and short enough compared to the equation line
6861 % \item Add \cs{eqfuzz} distinct from \cs{hfuzz}.
6862 % Make use of it in the measuring phase.
6865 % \item Provision for putting in a \quoted{continued} note.
6867 % \item Conserve box mem: modify frac, sub, sup, overline, underline,
6868 % sqrt, to turn off \cs{bin@break} and (less urgently)
6872 % \item More explicit support for Russian typesetting conventions (cf
6873 % Grinchuk article).
6876 % \item With package option \opt{refnumbers},
6877 % leave unnumbered all uncited equations, even if they are not done with
6878 % the star form (Bertolazzi's easyeqn idea).
6880 % \item In an equation group, use a vertical bracket with the
6881 % equation number to mark the lines contained in that equation.
6884 % \item For a two-line multline thingamabob, try to
6885 % make sure that the lines overlap in the middle by 2 em or whatever
6886 % (settable design variable).
6888 % \item Provide a separate vertical column for the principal mathrel
6889 % symbols and center them within the column if they aren't all the same
6890 % width. Maybe an option for \env{dmath}: relwidth=x, so that two
6891 % passes are not required to get the max width of all the mathrels.
6892 % Or, no, just require it to be an halign or provide a macro to be
6893 % applied to all the shorter rels:
6894 % \begin{literalcode}
6895 % lhs \widerel{19pt}{=} ...
6896 % \xrightarrow{foo} ...
6900 % \item try to use vadjust for keepglue