diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/mh/breqn.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/mh/breqn.dtx | 678 |
1 files changed, 468 insertions, 210 deletions
diff --git a/Master/texmf-dist/source/latex/mh/breqn.dtx b/Master/texmf-dist/source/latex/mh/breqn.dtx index 81d0fc39d7a..0f01201b370 100644 --- a/Master/texmf-dist/source/latex/mh/breqn.dtx +++ b/Master/texmf-dist/source/latex/mh/breqn.dtx @@ -67,7 +67,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: breqn 2007/12/10 v0.96 Breqn (MH)} +\Msg{* Package: breqn 2007/12/22 v0.97a Breqn (MH)} \Msg{************************************************************************} \keepsilent @@ -128,10 +128,12 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{breqn.drv}% - [2007/12/10 v0.96 breqn (MH)] + [2007/12/22 v0.97a breqn (MH)] \documentclass{ltxdoc} - -\usepackage{color,verbatim,xspace,varioref,listings} +\CodelineIndex +\EnableCrossrefs +\setcounter{IndexColumns}{2} +\usepackage{color,verbatim,xspace,varioref,listings,amsmath,trace} \definecolor{hilite}{rgb}{0.2,0.4,0.7} \def\theCodelineNo{\textcolor{hilite}{\sffamily\tiny\arabic{CodelineNo}}} @@ -228,7 +230,7 @@ and the derived files % \fi % % \title{The \pkg{breqn} package} -% \date{2007/12/10 v0.96} +% \date{2007/12/22 v0.97a} % \author{Morten H\o gholm \\\texttt{mh.ctan@gmail.com}} % % \maketitle @@ -417,7 +419,7 @@ and the derived files % \LaTeX\ interface for defining math symbols (\cs{DeclareMathSymbol}), % things should work OK most of the time. Any more complex math symbol % setup is quite likely to quarrel with the \pkg{flexisym} package. -% See Section~\ref{flexisym} for further information. +% See Section~\vref{flexisym} for further information. % % \subsection{Subscripts and superscripts} % @@ -502,13 +504,16 @@ and the derived files % \setkeys{breqn}{breakdepth={1}} % \end{verbatim} % -% See the discussion of environment options, Section~\ref{envopts}, for +% See the discussion of environment options, Section~\vref{envopts}, for % more information. % -% One package option that may be of interest to \TeX nicians is the -% \opt{debug} option; this activates some debugging statements embedded in -% the code of the alpha release which trace measuring activities related -% to line breaking. +% Debugging information is no longer available as a package +% option. Instead, the tracing information has been added in a fashion +% so that it can be enabled as a docstrip option: +% \begin{verbatim} +% \generate{\file{breqn.sty}{\from{breqn.dtx}{package,trace}}} +% \end{verbatim} +% % % \section{Environments and commands} % \subsection{Environments} @@ -1000,7 +1005,7 @@ and the derived files % % Declare package name and date. % \begin{macrocode} -\ProvidesPackage{breqn}[2007/12/10 v0.96] +\ProvidesPackage{breqn}[2007/12/22 v0.97a] % \end{macrocode} % % @@ -1009,17 +1014,14 @@ and the derived files % Most options are set with the \cs{options} command (which % calls \cs{setkeys}) because the standard package option % mechanism doesn't provide support for key-value syntax. -% Cf \fn{breqndoc.tex}. % -% It seems easier to turn off debugging than turn it on so the -% implementation of the \opt{debug} option is sort of backward. +% First we need to get the catcodes sorted out. % \begin{macrocode} \edef\breqnpopcats{% \catcode\number`\"=\number\catcode`\" \relax} \AtEndOfPackage{\breqnpopcats}% \catcode`\^=7 \catcode`\_=8 \catcode`\"=12 \relax -\DeclareOption{debug}{\errorcontextlines=2000\relax} \DeclareOption{mathstyleoff}{% \PassOptionsToPackage{mathstyleoff}{flexisym}% } @@ -1044,7 +1046,7 @@ and the derived files % I don't think so. % \begin{macrocode} \@ifpackageloaded{flexisym}{}{% - \RequirePackage[cmbase]{flexisym}[2007/12/10] + \RequirePackage{flexisym}[2007/12/19] \edef\breqnpopcats{\breqnpopcats \catcode\number`\^=\number\catcode`\^ \catcode\number`\_=\number\catcode`\_ @@ -1402,7 +1404,7 @@ and the derived files % 1999. % The extra application of \cs{number} is needed for maximal % robustness in case the repeat count N is given in some weird \tex form -% such as \verb""E9" or \verb"\count9". +% such as \verb|"E9| or \verb|\count9|. % \begin{macrocode} % usage: \message{H\replicate{5}{i h}ow de doo dee!} \begingroup \catcode`\&=11 @@ -1569,25 +1571,15 @@ and the derived files % % \section{Debugging} % Debugging help. -% -% \begin{macro}{\debug} % \begin{macrocode} -\let\debug=\begingroup +%<*trace> +\errorcontextlines=2000\relax % \end{macrocode} -% \end{macro} % -% \begin{macro}{\gubed} -% \begin{macrocode} -\let\gubed=\endgroup -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\debugmsg} +% \begin{macro}{\breqn@debugmsg} % Print a debugging message. % \begin{macrocode} -\def\debugmsg{\message{||= \iffalse}\fi - \@xp\@gobble\string -} +\long\def\breqn@debugmsg#1{\GenericInfo{||}{||=\space#1}} % \end{macrocode} % \end{macro} % @@ -1630,23 +1622,17 @@ and the derived files % \begin{macrocode} \def\debug@para{% \debugwr{\hsize\the\hsize, \parfillskip\the\parfillskip}% - \debugmsg{\leftskip\the\leftskip, \rightskip\the\rightskip}% - \debugmsg{\linepenalty\the\linepenalty, \adjdemerits\the\adjdemerits}% - \debugmsg{\pretolerance\the\pretolerance, \tolerance\the\tolerance, + \breqn@debugmsg{\leftskip\the\leftskip, \rightskip\the\rightskip}% + \breqn@debugmsg{\linepenalty\the\linepenalty, \adjdemerits\the\adjdemerits}% + \breqn@debugmsg{\pretolerance\the\pretolerance, \tolerance\the\tolerance, \parindent\the\parindent}% } % \end{macrocode} % \end{macro} % % -% Turn off debugging unless it was asked for. % \begin{macrocode} -\@ifpackagewith{breqn}{debug}{}{% - \let\debug\relax \let\gubed\relax - \let\debugmsg\@gobble \let\debug@lines\relax \let\debug@para\relax - \let\debugwr\@gobble - \let\debug@box\@gobble \let\debug@push\@gobbletwo -} +%</trace> % \end{macrocode} % % @@ -2348,6 +2334,20 @@ and the derived files \define@key{breqn}{style}{\eqstyle\@xp{\the\eqstyle #1}} % \end{macrocode} % \begin{literalcode} +% \begin{dmath}[shortskiplimit={1em}] +% \end{literalcode} +% If the line immediately preceeding a display has length $l$, the +% first line of the display is indented $i$, and a shortskip limit $s$ +% is set, then the spacing above the display is equal to +% \cs{abovedisplayshortskip} if $l+s < i $ and \cs{abovedisplayskip} +% otherwise. The default shortskip limit is 2\,em which is what \TeX\ +% hardcodes but this parameter overrides that. +% \begin{macrocode} +\define@key{breqn}{shortskiplimit}{\def\eq@shortskiplimit{#1}} +\def\eq@shortskiplimit{2em} +% \end{macrocode} +% +% \begin{literalcode} % \begin{dmath}[frame] % \end{literalcode} % The \opt{frame} option merely puts a framebox around the body @@ -2449,7 +2449,7 @@ and the derived files \darray@mkpream#1\@percentchar } % \end{macrocode} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % FORMAT STATUS% % \begin{verbatim} % \def\eq@frame{T}% @@ -2474,12 +2474,12 @@ and the derived files % IRB % \def\eqindent{I}\def\eqnumside{R}\def\eqnumplace{B}\mathindent10\p@ % \end{verbatim} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % The main environments. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%BRM: The following incorporates several changes: -%% 1) modifications supplied by MJD to fix the eaten \cs{paragraph} problem. -%% 2) Added \cs{display@setup} here, rather than globally. +% +%BRM: The following incorporates several changes: +% 1) modifications supplied by MJD to fix the eaten \cs{paragraph} problem. +% 2) Added \cs{display@setup} here, rather than globally. % % \begin{macro}{\dmath} % \begin{macro}{\enddmath} @@ -2491,7 +2491,7 @@ and the derived files \newenvironment{dmath}{% \let\eq@hasNumber\@True \@optarg\@dmath{}}{} \def\@dmath[#1]{% - \debugmsg{=== DMATH ==================================================}% +%<trace> \breqn@debugmsg{=== DMATH ==================================================}% \everydisplay\expandafter{\the\everydisplay \display@setup}% \if@noskipsec \leavevmode \fi \if@inlabel \leavevmode \global\@inlabelfalse \fi @@ -2655,7 +2655,7 @@ and the derived files % either an \cs{itshape} (recommended) or a \cs{textit} % value. % \begin{macrocode} - \debugmsg{Number \eq@number}% +%<trace> \breqn@debugmsg{Number \eq@number}% \set@label{equation}\eq@number \global\sbox\EQ@numbox{% \next@label \global\let\next@label\@empty @@ -2680,25 +2680,66 @@ and the derived files % having worked out the best parshape. % BRM: This portion is extensively refactored to get common operations % together (so corrections get consistently applied). +% +% MH: I've destroyed Bruce's nice refactoring a bit to get the +% abovedisplayskips correct for both groups of equations and single +% \env{dmath} environments. I will have to redo that later. % \begin{macrocode} +\newcount\eq@final@linecount +\let\eq@GRP@first@dmath\@True \def\eq@finish{% \begingroup - \debugmsg{Formatting equation}% - \debug@showmeasurements +%<trace> \breqn@debugmsg{Formatting equation}% +%<trace> \debug@showmeasurements \if F\eq@frame\else \freeze@glue\eqlinespacing \freeze@glue\eqlineskip \fi % \eq@topspace{\vskip\parskip}% Set top spacing \csname eq@\eqindent @setsides\endcsname % Compute \leftskip,\rightskip \adjust@parshape\eq@parshape% Final adjustment of parshape for left|right skips - \eq@topspace{\vskip\parskip}% Set top spacing - \debug@showformat - % Now, invoke the appropriate typesetter according to number placement +% \end{macrocode} +% If we are in an a group of equations we don't want to calculate the +% top space for the first one as that will be delayed until later when +% the space for the group is calculated. However, we do need to store +% the leftskip used here as that will be used later on for calculating +% the top space. +% \begin{macrocode} + \if\eq@group + \if\eq@GRP@first@dmath + \global\let\eq@GRP@first@dmath\@False + \xdef\dmath@first@leftskip{\leftskip=\the\leftskip\relax}% +%<trace> \breqn@debugmsg{Stored\space\dmath@first@leftskip} + \else + \eq@topspace{\vskip\parskip}% Set top spacing + \fi + \else + \eq@topspace{\vskip\parskip}% Set top spacing + \fi +%<trace> \debug@showformat +% \end{macrocode} +% We now know the final line count of the display. If it is a +% single-line display, we want to know as that greatly simplifies the +% equation tag placement (until such a time where this algorithm has +% been straightened out). +% \begin{macrocode} + \afterassignment\remove@to@nnil + \eq@final@linecount=\expandafter\@gobble\eq@parshape\@nnil +% \end{macrocode} +% Now, invoke the appropriate typesetter according to number placement +% \begin{macrocode} \if\eq@hasNumber \if\eq@shiftnumber \csname eq@typeset@\eqnumside Shifted\endcsname \else - \csname eq@typeset@\eqnumside\eqnumplace\endcsname +% \end{macrocode} +% If there is only one line and the tag doesn't have to be shifted, we +% call a special procedure to put the tag correctly. +% \begin{macrocode} + \ifnum\eq@final@linecount=\@ne + \csname eq@typeset@\eqnumside @single\endcsname + \else + \csname eq@typeset@\eqnumside\eqnumplace\endcsname + \fi \fi \else \eq@typeset@Unnumbered @@ -2706,11 +2747,42 @@ and the derived files \endgroup \eq@botspace } -% \end{macrocode} -% +% \end{macrocode} % \end{macro} % % +% These are temporary until the tag position algorithm gets +% rewritten. At least the tag is positioned correctly for single-line +% displays. The horizontal frame position is not correct but the +% problem lies elsewhere. +% \begin{macrocode} +\def\eq@typeset@L@single{% + \nobreak + \eq@params\eq@parshape + \nointerlineskip\noindent + \add@grp@label + \rlap{\kern-\leftskip\box\EQ@numbox}% + \if F\eq@frame + \else + \rlap{\raise\eq@firstht\hbox to\z@{\eq@addframe\hss}}% + \fi + \eq@dump@box\unhbox\EQ@box \@@par +} +\def\eq@typeset@R@single{% + \nobreak + \eq@params\eq@parshape + \nointerlineskip\noindent + \add@grp@label + \if F\eq@frame + \else + \rlap{\raise\eq@firstht\hbox to\z@{\eq@addframe\hss}}% + \fi + \rlap{\kern-\leftskip\kern\linewidth\kern-\wd\EQ@numbox\copy\EQ@numbox}% + \eq@dump@box\unhbox\EQ@box + \@@par +} +% \end{macrocode} +% % % % \section{Special processing for end-of-equation} @@ -2809,7 +2881,8 @@ and the derived files % % % \begin{macro}{\check@punct} -% +% \changes{v0.96a}{2007/12/17}{Insert \cs{finish@end} if no special +% case is found.} % For this one we need to recognize and grab for inclusion any of the % following tokens: \verb",;.!?", both catcode 12 (standard \latex % value) and catcode 13 (as might hold when the Babel package is @@ -2847,6 +2920,7 @@ and the derived files \else\ifx\@let@token ;\@nx\check@qed \else\ifx\@let@token ?\@nx\check@qed \else\ifx\@let@token !\@nx\check@qed + \else\@nx\finish@end \fi\fi\fi\fi\fi } \xdef\check@punct@b{% @@ -2968,8 +3042,15 @@ and the derived files \def\eq@topspace#1{% \begingroup \global\let\EQ@shortskips\@False - \if\@And{\eq@group}{\@Not\GRP@top}% - \parskip\intereqskip \penalty\intereqpenalty +% \end{macrocode} +% If we are in \env{dgroup} or \env{dgroup*} and not before the top +% one, we just insert \cs{intereqskip}. Otherwise we must check for +% shortskip. +% \begin{macrocode} + \if\@And{\eq@group}{\@Not\eq@GRP@first@dmath}% +%<trace>\breqn@debugmsg{Between lines}% + \parskip\intereqskip \penalty\intereqpenalty +%<trace>\breqn@debugmsg{parskip=\the\parskip}% \else \eq@check@shortskip \if\EQ@shortskips @@ -2987,29 +3068,59 @@ and the derived files \else \addtolength\parskip{\eq@framesep+\eq@framewd}% \fi -\debugmsg{Topspace: \theb@@le\EQ@shortskips, \parskip=\the\parskip, \predisplaysize=\the\predisplaysize}% +%<*trace> + \breqn@debugmsg{Topspace: \theb@@le\EQ@shortskips, \parskip=\the\parskip, + \predisplaysize=\the\predisplaysize}% +%</trace> #1% \endgroup } -\def\eq@check@shortskip{% +% \end{macrocode} +% \begin{macro}{\eq@check@shortskip} +% \changes{v0.96a}{2007/12/17}{Insert \cs{finish@end} if no special +% case is found.} +% \changes{v0.97a}{2007/12/22}{Use design parameter and fix +% shortskips properly.} +% \begin{macrocode} +\def\eq@check@shortskip {% \global\let\EQ@shortskips\@False \setlength\dim@a{\abovedisplayskip+\ht\EQ@numbox}% - \addtolength\leftskip{-2em}% standard TeX value +% \end{macrocode} +% Here we work around the hardwired standard TeX value and use the +% designer parameter instead. +% \begin{macrocode} \ifdim\leftskip<\predisplaysize - \else\if R\eqnumside \global\let\EQ@shortskips\@True - \else\if\eq@shiftnumber - \else\if T\eqnumplace - \ifdim\dim@a<\eq@firstht - \global\let\EQ@shortskips\@True - \fi \else - \setlength\dim@b{\eq@vspan/2}% - \ifdim\dim@a<\dim@b - \global\let\EQ@shortskips\@True +% \end{macrocode} +% If the display was preceeded by a blank line, \cs{predisplaysize} is +% $-\cs{maxdimen}$ and so we should insert a fairly large skip to +% separate paragraphs, i.e., no short skip. Perhaps this should be a +% third parameter \cs{abovedisplayparskip}. +% \begin{macrocode} + \ifdim -\maxdimen=\predisplaysize + \else + \if R\eqnumside + \global\let\EQ@shortskips\@True + \else + \if\eq@shiftnumber + \else + \if T\eqnumplace + \ifdim\dim@a<\eq@firstht + \global\let\EQ@shortskips\@True + \fi + \else + \setlength\dim@b{\eq@vspan/2}% + \ifdim\dim@a<\dim@b + \global\let\EQ@shortskips\@True + \fi + \fi + \fi + \fi \fi - \fi\fi\fi\fi + \fi } % \end{macrocode} +% \end{macro} % % At the end of an equation, need to put in a pagebreak penalty % and some vertical space. Also set some flags to remove parindent @@ -3263,9 +3374,9 @@ and the derived files % added after it by \tex . Should we remove it? I guess % so. % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Capturing the equation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% \subsection{Capturing the equation} +% % BRM: There's a problem here (or with \cs{ss@scan}). If the LHS has % \cs{left} \cs{right} pairs, \ss@scan gets involved. It seems to produce % a separate box marked w/\cs{penalty} 3. But it appears that \cs{eq@repack} @@ -3314,17 +3425,25 @@ and the derived files % Apparently missing a \thickmuskip = 5mu = 5/18em=0.27777777777.. ? + 0.2777777777777em}% FUDGE??!?!?! \ifdim\dim@a>\eq@wdL - \debugmsg{Correcting LHS from \the\eq@wdL\space to \the\dim@a = \the\wd\EQ@box - \the\eq@wdR}% +%<*trace> + \breqn@debugmsg{Correcting LHS from \the\eq@wdL\space to + \the\dim@a = \the\wd\EQ@box - \the\eq@wdR}% +%</trace> \eq@wdL\dim@a \xdef\EQ@setwdL{\eq@wdL\the\eq@wdL\relax}% \fi \fi - \debugmsg{Capture: total length=\the\wd\EQ@box - ^^J||===== has LHS=\theb@@le\EQ@hasLHS, \eq@wdL=\the\eq@wdL, \eq@wdR=\the\eq@wdR, - ^^J||===== \eq@wdCond=\the\eq@wdCond}% +%<*trace> + \breqn@debugmsg{Capture: total length=\the\wd\EQ@box \MessageBreak + ==== has LHS=\theb@@le\EQ@hasLHS, \eq@wdL=\the\eq@wdL, \eq@wdR=\the\eq@wdR, + \MessageBreak + ==== \eq@wdCond=\the\eq@wdCond}% +%</trace> \egroup % end vbox started earlier +%<*trace> %\debugwr{EQ@box}\debug@box\EQ@box %\debugwr{EQ@copy}\debug@box\EQ@copy +%</trace> } % \end{macrocode} % Now we have two copies of the equation, one in \cs{EQ@box}, @@ -3643,7 +3762,7 @@ and the derived files % need to know how many lines the equation will require. % And of course the number of lines needed depends on the parshape! % So as our very first trial we run a simple first-approximation -% parshape (Figure~\ref{f:parshape-1}) whose +% parshape (Figure~\vref{f:parshape-1}) whose % main purpose is to get an estimate on the number of lines that will be % needed; it chooses a uniform indent for all lines after the first one % and does not take any account of the equation number. @@ -3738,31 +3857,35 @@ and the derived files % \end{macrocode} % \end{macro} % \begin{macrocode} +%<*trace> \def\debug@showmeasurements{% - \debugmsg{=> \number\eq@lines\space lines}% - \debug - \def\@elt##1^^J##2{^^J||===== \space\space##1/##2}% + \breqn@debugmsg{=> \number\eq@lines\space lines}% + \begingroup + \def\@elt##1X##2{\MessageBreak==== \space\space##1/##2}% \let\@endelt\@empty - \debugmsg{=> trial info:\eq@measurements}% - \debugmsg{=> bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness}% + \breqn@debugmsg{=> trial info:\eq@measurements}% + \breqn@debugmsg{=> bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness}% \let\@elt\relax \let\@endelt\relax - \gubed + \endgroup } \def\debug@showmeasurements{% \begingroup - \def\@elt##1^^J##2{^^J||===== ##1/##2}% + \def\@elt##1X##2{\MessageBreak==== ##1/##2}% \let\@endelt\@empty - \debugmsg{===> Measurements: \number\eq@lines\space lines + \breqn@debugmsg{===> Measurements: \number\eq@lines\space lines \eq@measurements - ^^J||===== bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness - ^^J||===== \leftskip=\the\leftskip, \rightskip=\the\rightskip}% + \MessageBreak + ==== bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness + \MessageBreak + ==== \leftskip=\the\leftskip, \rightskip=\the\rightskip}% \endgroup } +%</trace> % \end{macrocode} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Layout Trials Driver % Basically, trying different sequences of parshapes. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % % \begin{macro}{\EQ@trial} % Init. @@ -3846,16 +3969,18 @@ and the derived files \if T\eq@frame \eq@frame@adjust\dim@c \fi \ifdim\dim@c>\eq@linewidth \eq@linewidth\dim@c - \debugmsg{Choose Shape for width(#1)=\the\eq@linewidth}% +%<trace> \breqn@debugmsg{Choose Shape for width(#1)=\the\eq@linewidth}% \let\eq@trial@b\eq@trial@d \csname eq@try@layout@\eq@layout\endcsname - \else - \debugmsg{Next width (#1) is shorter; skip it}% +%<trace> \else +%<trace> \breqn@debugmsg{Next width (#1) is shorter; skip it}% \fi \edef\eq@linewidths{\iffalse}\fi } \def\eq@frame@adjust#1{% - \addtolength#1{-2\eq@framewd-2\eq@framesep}% + %\addtolength#1{-2\eq@framewd-2\eq@framesep}% + \dim@a\eq@framewd \advance\dim@a\eq@framesep + \advance#1-2\dim@a } % \end{macrocode} % \end{macro} @@ -3873,7 +3998,7 @@ and the derived files % Success. % \begin{macrocode} \def\eq@trial@done{% - \debugmsg{End trial: Success!}% +%<trace> \breqn@debugmsg{End trial: Success!}% \let\eq@failout\relax } % \end{macrocode} @@ -3895,7 +4020,7 @@ and the derived files % \begin{macrocode} \def\eq@nextlayout#1{% \endgroup - \debugmsg{Nope ... that ain't gonna work.}% +%<trace> \breqn@debugmsg{Nope ... that ain't gonna work.}% \begingroup #1% } % \end{macrocode} @@ -3906,7 +4031,7 @@ and the derived files % . % \begin{macrocode} \def\eq@failout{% -\debugmsg{End trial: failout}% +%<trace>\breqn@debugmsg{End trial: failout}% \global\let\EQ@trial\EQ@last@trial } % \end{macrocode} @@ -3917,10 +4042,12 @@ and the derived files % Save the parameters of the current trial. % \begin{macrocode} \def\eq@trial@save#1{% -% \debug \def\@elt##1^^J##2{^^J||===== \space\space##1/##2}\let\@endelt\@empty\debugmsg{=> trial info:\eq@measurements}% -% \debugmsg{=> bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness^^J}% +%<*trace> +% \begingroup \def\@elt##1X##2{\MessageBreak==== \space\space##1/##2}\let\@endelt\@empty\breqn@debugmsg{=> trial info:\eq@measurements}% +% \breqn@debugmsg{=> bounding box: \the\eq@wdT x\the\eq@vspan, badness=\the\eq@badness\MessageBreak}% % \let\@elt\relax \let\@endelt\relax -% \gubed +% \endgroup +%</trace> \xdef#1{% \eq@linewidth\the\eq@linewidth % save info about the fit @@ -3960,7 +4087,7 @@ and the derived files % Run the equation contents through the current parshape. % \begin{macrocode} \def\eq@trial@c#1#2{% - \debugmsg{Trying layout "#1" with^^J||===== parshape\space\@xp\@gobble\@parshape}% +%<trace> \breqn@debugmsg{Trying layout "#1" with\MessageBreak==== parshape\space\@xp\@gobble\@parshape}% \begingroup \eq@trial@init \def\eq@layout{#1}% @@ -4003,9 +4130,9 @@ and the derived files % % \begin{macrocode} \def\eq@check@density{% - \debugmsg{Checking density for layout L}% +%<trace> \breqn@debugmsg{Checking density for layout L}% \if\@Or{\@Not\EQ@hasLHS}{\eq@shortLHS}% - \debugmsg{Density check: No LHS, or is short; OK}% +%<trace> \breqn@debugmsg{Density check: No LHS, or is short; OK}% \eq@trial@succeed \else\if\eq@dense@enough \eq@trial@succeed @@ -4041,7 +4168,7 @@ and the derived files \eq@ml@record@indents \eq@measure@lines \eq@recalc - \debug@showmeasurements +%<trace> \debug@showmeasurements } % \end{macrocode} % @@ -4102,12 +4229,12 @@ and the derived files % \begin{macro}{\eq@recalc@b} % % \begin{macrocode} -\def\eq@recalc@b#1^^J#2,#3x#4+#5@#6\@endelt{% +\def\eq@recalc@b#1X#2,#3x#4+#5@#6\@endelt{% \setlength\dim@a{#2+#3}% \ifdim\dim@a>\eq@wdT \eq@wdT\dim@a \fi \ifdim\dim@a<\eq@wdMin \eq@wdMin\dim@a \fi \eq@dp#5\relax - \addtolength\eq@vspan{#1+#4+#5}% + \addtolength\eq@vspan{#1+#4+\eq@dp}% % \end{macrocode} % Record the max badness of all the lines in \cs{eq@badness}. % \begin{macrocode} @@ -4123,14 +4250,13 @@ and the derived files % Any other value means we have a user-specified override on the % layout. % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Layout Definitions. % Based on initial equation measurements, we can choose a sequence of % candidate parshapes that the equation might fit into. % We accept the first shape that `works', else fall to next one. % [The sequence is hardcoded in the \cs{eq@try@layout@}<shape> % Would it be useful be more flexible? (eg. try layouts LDA, in order...)] -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macrocode} \def\eq@layout{?} % \end{macrocode} @@ -4157,15 +4283,18 @@ and the derived files \else\if\grp@hasNumber\addtolength\dim@b{-\wd\GRP@numbox-\eqnumsep}% \fi\fi\fi\fi \ifdim\dim@a<\dim@b% Do we even have a chance of fitting to one line? - \debugmsg{Choose Shape: (\the\wd\EQ@copy) may fit in \the\dim@b}% -%BRM% - % assuming it might fit, don't push too hard +%<trace> \breqn@debugmsg{Choose Shape: (\the\wd\EQ@copy) may fit in \the\dim@b}% +% \end{macrocode} +% BRM: assuming it might fit, don't push too hard +% \begin{macrocode} \setlength\dim@b{\columnwidth-\dim@a+\eq@wdCond}% \rightskip\z@\@plus\dim@b\@minus\hfuzz -% \eq@trial@b{i}{\eq@try@layout@multi}% \else - \debugmsg{Choose Shape: Too long (\the\wd\EQ@copy) for one line (free width=\the\dim@b)}% +%<*trace> + \breqn@debugmsg{Choose Shape: Too long (\the\wd\EQ@copy) for one line + (free width=\the\dim@b)}% +%</trace> \eq@try@layout@multi \fi } @@ -4177,7 +4306,7 @@ and the derived files \def\eq@try@layout@multi{% \if\EQ@hasLHS \ifdim\eq@wdL>\eq@linewidth - \debugmsg{Choose Shape: LHS \the\eq@wdL > linewidth}% +%<trace> \breqn@debugmsg{Choose Shape: LHS \the\eq@wdL > linewidth}% % \end{macrocode} % Find the total width of the RHS. % If it is relatively short, a step layout is the thing to try. @@ -4188,14 +4317,16 @@ and the derived files \fi % BRM: Originally .7: Extreme for L since rhs has to wrap within the remaining 30+%! \else\ifdim\eq@wdL>.50\eq@linewidth - \debugmsg{Choose Shape: LHS (\the\eq@wdL) > .50 linewidth (linewidth=\the\eq@linewidth)}% +%<*trace> + \breqn@debugmsg{Choose Shape: LHS (\the\eq@wdL) > .50 linewidth (linewidth=\the\eq@linewidth)}% +%</trace> \eq@try@layout@D \else - \debugmsg{Choose Shape: LHS (\the\eq@wdL) not extraordinarily wide}% +%<trace> \breqn@debugmsg{Choose Shape: LHS (\the\eq@wdL) not extraordinarily wide}% \eq@try@layout@L \fi\fi \else - \debugmsg{Choose Shape: No LHS here}% +%<trace> \breqn@debugmsg{Choose Shape: No LHS here}% % \end{macrocode} % Try one-line layout first, then step layout. % \begin{macrocode} @@ -4366,13 +4497,13 @@ and the derived files % \begin{macrocode} \def\eq@retry@with@number{% \if\eq@shiftnumber - \debugmsg{Place number: Shifted number requested}% +%<trace> \breqn@debugmsg{Place number: Shifted number requested}% \else % \end{macrocode} % Condition and right numbers? We're just going to have to shift. % \begin{macrocode} \ifdim\eq@wdCond>\z@\if R\eqnumside - \debugmsg{Place number: Condition w/Right number => Shift number}% +%<trace> \breqn@debugmsg{Place number: Condition w/Right number => Shift number}% \let\eq@shiftnumber\@True \fi\fi % \end{macrocode} @@ -4399,12 +4530,14 @@ and the derived files % left \& right skips will be done later, and parshape adjusted if % needed. % \begin{macrocode} - \debugmsg{Place number: eqn and number fit together}% +%<trace> \breqn@debugmsg{Place number: eqn and number fit together}% % \else\ifnum\eq@lines=\int@a % Shift, if single line, unless inside a dgroup. % \end{macrocode} % NOTE: this is too strong for dgroup! % \begin{macrocode} -% \debugmsg{Place number: single line too long with number => Shift number \the\int@a}% +%<*trace> +% \breqn@debugmsg{Place number: single line too long with number => Shift number \the\int@a}% +%</trace> % \let\eq@shiftnumber\@True \else % \end{macrocode} @@ -4415,8 +4548,10 @@ and the derived files \setlength\leftskip{\eq@wdNum}% \setlength\rightskip{\z@\@plus\dim@a}% \adjust@parshape\@parshape - \debugmsg{Place number: Try with \leftskip=\the\leftskip, \rightskip=\the\rightskip, - ^^J||===== parshape\space\@xp\@gobble\@parshape}% +%<*trace> + \breqn@debugmsg{Place number: Try with \leftskip=\the\leftskip, \rightskip=\the\rightskip, + \MessageBreak==== parshape\space\@xp\@gobble\@parshape}% +%</trace> \nointerlineskip \edef\eq@prev@lines{\the\eq@lines}% \edef\eq@prev@badness{\the\eq@badness}% BRM @@ -4424,16 +4559,19 @@ and the derived files \int@a\eq@prev@badness\relax\advance\int@a 50\relax%? \int@b\eq@prev@lines \if\eq@group\advance\int@b\@ne\fi% Allow 1 extra line in group \ifnum\eq@lines>\int@b % \eq@prev@lines - \debugmsg{Adjustment causes more breaks => Shift number}% +%<trace> \breqn@debugmsg{Adjustment causes more breaks => Shift number}% \let\eq@shiftnumber\@True \else\if\eq@badline - \debugmsg{Adjustment causes bad lines (\the\eq@badness) => Shift}% +%<trace> \breqn@debugmsg{Adjustment causes bad lines (\the\eq@badness) => Shift}% \let\eq@shiftnumber\@True \else\ifnum\eq@badness>\int@a % BRM: New case - \debugmsg{Adjustment is badder than previous (\the\eq@badness >> \eq@prev@badness) => Shift}% +%<*trace> + \breqn@debugmsg{Adjustment is badder than previous + (\the\eq@badness >> \eq@prev@badness) => Shift}% +%</trace> \let\eq@shiftnumber\@True \else - \debugmsg{Adjustment succeeded}% +%<trace> \breqn@debugmsg{Adjustment succeeded}% \fi\fi%\fi \fi\fi\fi % \end{macrocode} @@ -4568,7 +4706,9 @@ and the derived files % \begin{macrocode} \def\eq@ml@a{% \setbox\tw@\hbox{\unhbox\z@ \unskip}% find natural width - \debug\ifnum\eq@badness<\inf@bad\else\debugmsg{!?! Overfull: \the\wd\tw@ >\the\dim@b}\fi\gubed +%<*trace> + \ifnum\eq@badness<\inf@bad\else\breqn@debugmsg{!?! Overfull: \the\wd\tw@ >\the\dim@b}\fi +%</trace> % \end{macrocode} % Is actual width less than natural width? % \begin{macrocode} @@ -4592,7 +4732,7 @@ and the derived files }% \fi \edef\eq@measurements{\@elt - \the\skip@a\space^^J% extra space to facilitate extracting only the + \the\skip@a\space X% extra space to facilitate extracting only the % dimen part later \csname eq@i% \ifnum\eq@curline<\parshape \number\eq@curline @@ -4627,11 +4767,11 @@ and the derived files % \begin{macrocode} \def\eq@dense@enough{% \ifnum\eq@lines<\thr@@ - \debugmsg{Density check: less than 3 lines; OK}% +%<trace> \breqn@debugmsg{Density check: less than 3 lines; OK}% \@True \else \ifdim\eq@wdL >.7\eq@wdT - \debugmsg{Density check: LHS too long; NOT OK}% +%<trace> \breqn@debugmsg{Density check: LHS too long; NOT OK}% \@False \else \@xp\@xp\@xp\eq@dense@enough@a \fi @@ -4697,7 +4837,7 @@ and the derived files \else \dim@b\z@ \let\@elt\eq@delt \eq@measurements \dim@c\eq@density@factor\eq@wdT \multiply\dim@c\eq@lines - \debugmsg{Density check: black \the\dim@b/\eq@density@factor total \the\dim@c}% +%<trace> \breqn@debugmsg{Density check: black \the\dim@b/\eq@density@factor total \the\dim@c}% \ifdim\dim@b>\dim@c \true@false@true \else \false@false@false \fi \fi } @@ -4708,7 +4848,7 @@ and the derived files % \begin{macro}{\eq@delt} % Args are space-above, indent, width, height, depth, badness. % \begin{macrocode} -\def\eq@delt#1^^J#2,#3x#4+#5@#6\@endelt{\addtolength\dim@b{#3}}% +\def\eq@delt#1X#2,#3x#4+#5@#6\@endelt{\addtolength\dim@b{#3}}% % \end{macrocode} % \end{macro} % @@ -4736,7 +4876,7 @@ and the derived files \dim@c\eq@lines\p@ \multiply\dim@c\f@ur \int@b\eq@lines \multiply\int@b 9 \advance\int@b -10% \divide\dim@c\int@b - \debugmsg{Density check: l/t \the\dim@b\space< \the\dim@c\space 4n/(9n-10)?}% +%<trace> \breqn@debugmsg{Density check: l/t \the\dim@b\space< \the\dim@c\space 4n/(9n-10)?}% \ifdim\dim@b<\dim@c \true@true@true \else \false@true@false \fi } % \end{macrocode} @@ -4766,7 +4906,7 @@ and the derived files % of a page; instead it will be moved whole to the top of the next % page. If you really really need a page break that splits the % first or last line from the rest of the equation, you can always fall -% back to\cs{pagebreak}, I suppose9. +% back to\cs{pagebreak}, I suppose. % % \begin{macrocode} \clubpenalty\@M \widowpenalty\@M \interlinepenalty\eqinterlinepenalty @@ -4805,6 +4945,68 @@ and the derived files % I, IRM, IRB, ILM, ILT. In other words, CLM stands for Centered equation % body with Left-hand Middle-placed equation number, and IRB stands for % Indented equation with Right-hand Bottom-placed equation number. +% +% Here are some general thoughts on how to place an equation +% tag. Currently it does not work as desired: the L option positions +% the tag app. 10 lines below the math expression, the RM doesn't +% position the tag on the baseline for single-line math +% expressions. Therefore I am going to first write what I think is +% supposed to happen and then implement it. +% +% Below is a small list where especially the two three specifications +% should be quite obvious, I just don't want to forget anything and it +% is important to the implementation. +% \begin{description} +% \item[Definition 1] If a display consists of exactly one line, the +% tag should always be placed on the same baseline as the math +% expression. +% \end{description} +% The remaining comments refer to multi-line displays. +% \begin{description} +% \item[Definition 2] If a tag is to be positioned at the top (T), it +% should be placed such that the baseline of the tag aligns with the +% baseline of the top line of the display. +% +% \item[Definition 3] If a tag is to be positioned at the bottom (B), +% it should be placed such that the baseline of the tag aligns with +% the baseline of the bottom line of the display. +% +% \item[Definition 4] If a tag is to be positioned vertically centered +% (M), it should be placed such that the baseline of the tag is +% positioned exactly halfway between the baseline of the top line of +% the display and the baseline of the bottom line of the display. +% \end{description} +% +% Definitions 1--3 are almost axiomatic in their +% simplicity. Definition~4 is different because I saw at least two +% possibilities for which area to span: +% \begin{itemize} +% \item Calculate distance from top of top line to the bottom of the +% bottom line, position the vertical center of the tag exactly +% halfway between those two extremes. +% +% \item Calculate the distance from the baseline of the top line to +% the baseline of the bottom line, position the baseline of the tag +% exactly halfway between these two extremes. +% \end{itemize} +% Additional combinations of these methods are possible but make +% little sense in my opinion. I have two reasons for choosing the +% latter of these possibilities: Firstly, two expressions looking +% completely identical with the exception of a superscript in the +% first line or a subscript in the last line will have the tag +% positioned identically. Secondly, then M means halfway between T and +% B positions which makes good sense and then also automatically +% fulfills Definition~1. +% +% From an implementation perspective, these definitions should also +% make it possible to fix a deficiency in the current implementation, +% namely that the tag does not influence the height of a display, even +% if the display is a single line. This means that two single-line +% expressions in a \env{dgroup} can be closer together than +% \cs{intereqskip} if the math expressions are (vertically) smaller +% than the tag. +% +% % % % \section{Centered Right-Number Equations} @@ -4834,25 +5036,27 @@ and the derived files % \end{macro} % % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Various typesetting bits, invoked from \cs{eq@finish} % BRM: This has been extensively refactored from the original breqn, % initially to get left\textbar right skips and parshape used consistently, % ultimately to get most things handled the same way, in the same order. -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% % Given that left and right skips have been set, % typeset the frame, number and equation with the % given number side and placement -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% % \begin{macrocode} \def\eq@typeset@Unnumbered{% \eq@typeset@frame \eq@typeset@equation } \def\eq@typeset@LM{% - \addtolength\dim@a{(\eq@vspan+\ht\EQ@numbox-\dp\EQ@numbox)/2}% + \setlength\dim@a{(\eq@vspan+\ht\EQ@numbox-\dp\EQ@numbox)/2}% \eq@typeset@leftnumber \eq@typeset@frame \eq@typeset@equation @@ -4884,7 +5088,7 @@ and the derived files % Typeset equation and right middle number % \begin{macrocode} \def\eq@typeset@RM{% - \setlength\dim@a{(\eq@vspan+\ht\EQ@numbox-\dp\EQ@numbox)/2} + \setlength\dim@a{(\eq@vspan+\ht\EQ@numbox-\dp\EQ@numbox)/2}% \eq@typeset@rightnumber \eq@typeset@frame \eq@typeset@equation @@ -4915,25 +5119,28 @@ and the derived files \hbox to\hsize{\hfil\copy\EQ@numbox}\@@par% } % \end{macrocode} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Debugging aid to show all relevant formatting info for a given eqn. % \begin{macrocode} +%<*trace> \def\debug@showformat{% - \debugmsg{Formatting Layout:\eq@layout\space Center/indent: \eqindent\space Number placement \eqnumside\eqnumplace: - ^^J||===== \eq@linewidth=\the\eq@linewidth, \@totalleftmargin=\the\@totalleftmargin, - ^^J||===== Centered Lines=\theb@@le\eq@centerlines, Shift Number=\theb@@le\eq@shiftnumber, - ^^J||===== \eq@wdT=\the\eq@wdT, \eq@wdMin=\the\eq@wdMin, - ^^J||===== LHS=\theb@@le\EQ@hasLHS: \eq@wdL=\the\eq@wdL, - ^^J||===== \eq@firstht=\the\eq@firstht, \eq@vspan=\the\eq@vspan - ^^J||===== \eq@wdNum=\the\eq@wdNum - ^^J||===== \eq@wdCond=\the\eq@wdCond, \conditionsep=\the\conditionsep, - ^^J||===== \leftskip=\the\leftskip, \rightskip=\the\rightskip, - ^^J||===== \abovedisplayskip=\the\abovedisplayskip, - ^^J||===== \belowdisplayskip=\the\belowdisplayskip - ^^J||===== parshape=\eq@parshape}% -} + \breqn@debugmsg{Formatting Layout:\eq@layout\space Center/indent: \eqindent\space + Number placement \eqnumside\eqnumplace: + \MessageBreak==== \eq@linewidth=\the\eq@linewidth, \@totalleftmargin=\the\@totalleftmargin, + \MessageBreak==== Centered Lines=\theb@@le\eq@centerlines, Shift Number=\theb@@le\eq@shiftnumber, + \MessageBreak==== \eq@wdT=\the\eq@wdT, \eq@wdMin=\the\eq@wdMin, + \MessageBreak==== LHS=\theb@@le\EQ@hasLHS: \eq@wdL=\the\eq@wdL, + \MessageBreak==== \eq@firstht=\the\eq@firstht, \eq@vspan=\the\eq@vspan + \MessageBreak==== \eq@wdNum=\the\eq@wdNum + \MessageBreak==== \eq@wdCond=\the\eq@wdCond, \conditionsep=\the\conditionsep, + \MessageBreak==== \leftskip=\the\leftskip, \rightskip=\the\rightskip, + \MessageBreak==== \abovedisplayskip=\the\abovedisplayskip, + \MessageBreak==== \belowdisplayskip=\the\belowdisplayskip + \MessageBreak==== parshape=\eq@parshape}% +} +%</trace> % \end{macrocode} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Set left \& right skips for centered equations, % making allowances for numbers (if any, right, left) and constraint. % === @@ -4989,13 +5196,16 @@ and the derived files \fi\fi % Now, \dim@d,\dim@e is the left & right glue to center each line for centerlines \setlength\dim@e{\eq@wdT-\eq@wdMin}\dim@d=\z@ +% \end{macrocode} % NOTE: Need some work here centering when there's a condition +% \begin{macrocode} % \advance\dim@e-\eq@wdT\multiply\dim@e-1\relax % \if\eq@wdMin<\dim@e\dim@e\eq@wdMin\fi % \multiply\dim@e-1\relax\advance\dim@e\eq@wdT \dim@d\z@ \if\eq@centerlines - \divide\dim@e2\relax\dim@d\dim@e + \divide\dim@e2\relax + \dim@d=\dim@e \fi \setlength\leftskip{\dim@a\@plus\dim@d}% \addtolength\dim@e{\dim@c}% @@ -5006,10 +5216,14 @@ and the derived files \if F\eq@frame\else \dim@b\dim@c \fi - \if\eq@hasNumber\if\eq@shiftnumber\else\if R\eqnumside - \dim@c\eq@wdNum - \ifdim\dim@c>\dim@b\dim@b\dim@c\fi - \fi\fi\fi + \if\@And{\eq@hasNumber}{\@Not{\eq@shiftnumber}}% + \if R\eqnumside + \dim@c\eq@wdNum + \ifdim\dim@c>\dim@b + \dim@b\dim@c + \fi + \fi + \fi % If either of those cases requires hard rightskip, move that part from glue. \ifdim\dim@b>\z@ \addtolength\dim@e{-\dim@c}% @@ -5017,41 +5231,55 @@ and the derived files \fi % And peculiar further special case: in indented environs, width isn't where it would seem \ifdim\eq@wdCond>\z@ - \addtolength\rightskip{-\@totalleftmargin}% + \addtolength\rightskip{-\@totalleftmargin}% \fi \parfillskip\z@skip } % \end{macrocode} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Set the left and right side spacing for indented equations % Some things handled by eq@C@setsides that probably apply here???? -% * centerlines -% * \cs{@totalleftmargin}: SHOULD we move farther right? +% \begin{itemize} +% \item centerlines +% \item \cs{@totalleftmargin}: SHOULD we move farther right? +% \end{itemize} +% Leftskip is normally just the requested indentation % \begin{macrocode} \def\eq@I@setsides{% - % Leftskip is normally just the requested indentation \leftskip\mathindent - % But move left, if shifted number presumably because of clashed w/ number? +% \end{macrocode} +% But move left, if shifted number presumably because of clashed w/ number? +% \begin{macrocode} \if\eq@shiftnumber \setlength\dim@a{\eq@linewidth-\eq@wdT-\mathindent}% \ifdim\dim@a<\z@ \leftskip=\z@ % Or something minimal? - \fi\fi - % Push gently from right. + \fi + \fi +% \end{macrocode} +% Push gently from right. +% \begin{macrocode} \dim@a=\z@ \setlength\dim@b{\eq@linewidth-\leftskip-\eq@wdMin}% - % Special case: if framing be much more rigid(?) - \if F\eq@frame\else +% \end{macrocode} +% Special case: if framing be much more rigid(?) +% \begin{macrocode} + \if F\eq@frame + \else \setlength\dim@a{\eq@linewidth-\leftskip-\eq@wdT} \addtolength\dim@b{-\dim@a}% \fi % Or force the space for right number, if needed - \if\eq@hasNumber\if\eq@shiftnumber\else\if R\eqnumside - \dim@c=\eq@wdNum - \if\dim@c>\dim@a - \addtolength\dim@b{-\dim@c}% - \dim@a=\dim@c - \fi\fi\fi\fi +% \begin{macrocode} + \if\@And{\eq@hasNumber}{\@Not{\eq@shiftnumber}}% + \if R\eqnumside + \dim@c=\eq@wdNum + \if\dim@c>\dim@a + \addtolength\dim@b{-\dim@c}% + \dim@a=\dim@c + \fi + \fi + \fi \setlength\rightskip{\dim@a\@plus\dim@b \@minus\hfuzz }%\hfuzz\z@ \parfillskip\z@skip } @@ -5097,6 +5325,8 @@ and the derived files } % \end{macrocode} % \end{macro} +% The frame is not typeset at the correct horizontal position. Will +% fix later. % \begin{macrocode} \def\eq@addframe{% \hbox to\z@{% @@ -5847,7 +6077,6 @@ and the derived files \let\grp@hasNumber\@False \let\grp@eqs@numbered\@False \let\grp@aligned\@True -\global\let\GRP@top\@True % \end{macrocode} % % \end{macro} @@ -5871,8 +6100,8 @@ and the derived files \end@dgroup } \def\@dgroup[#1]{% - \debugmsg{=== DGROUP ==================================================}% - \let\eq@group\@True \global\let\GRP@top\@True +%<trace> \breqn@debugmsg{=== DGROUP ==================================================}% + \let\eq@group\@True \global\let\eq@GRP@first@dmath\@True \global\GRP@queue\@emptytoks \global\setbox\GRP@box\box\voidb@x \global\let\GRP@label\@empty \global\grp@wdL\z@\global\grp@wdR\z@\global\grp@wdT\z@ @@ -5936,7 +6165,7 @@ and the derived files % \begin{macrocode} \setcounter{equation}{0}% \def\theequation{\theparentequation\alph{equation}}% - \debugmsg{Group Number \theequation}% +%<trace> \breqn@debugmsg{Group Number \theequation}% } % \end{macrocode} % At the end of a group, need to reset the equation counter. @@ -5948,9 +6177,11 @@ and the derived files \newbox\GRP@wholebox % \end{macrocode} % Save data for this equation in the group -% * push the trial data onto end of \cs{GRP@queue} -% * push an hbox onto the front of \cs{GRP@box} -% containing: \cs{EQ@box}, \cs{EQ@copy}, \cs{penalty} 1 and \cs{EQ@numbox} +% \begin{itemize} +% \item push the trial data onto end of \cs{GRP@queue}. +% \item push an hbox onto the front of \cs{GRP@box} containing: +% \cs{EQ@box}, \cs{EQ@copy}, \cs{penalty} 1 and \cs{EQ@numbox}. +% \end{itemize} % \begin{macro}{\grp@push} % % For putting the equation on a queue. @@ -5963,8 +6194,7 @@ and the derived files \hbox{\box\EQ@box\box\EQ@copy\penalty\@ne\copy\EQ@numbox}% \unvbox\GRP@box }% - \global\let\GRP@top\@False - \EQ@trial + \EQ@trial \if\eq@isIntertext\else \ifdim\eq@wdL>\grp@wdL \global\grp@wdL\eq@wdL \fi \ifdim\eq@wdT>\grp@wdT \global\grp@wdT\eq@wdT \fi @@ -5995,34 +6225,44 @@ and the derived files % \begin{macrocode} \def\grp@finish{% % \debug@box\GRP@box -% \debugmsg{\GRP@queue: \the\GRP@queue}% +% \breqn@debugmsg{\GRP@queue: \the\GRP@queue}% % \end{macrocode} % == Now that we know the collective measurements, make final decision % about alignment \& shifting. Check if alignment is still possible % \begin{macrocode} \setlength\dim@a{\grp@wdL+\grp@wdR-4em}% Allowance for shrink? - \if\grp@aligned\ifdim\dim@a>\grp@linewidth - \global\let\grp@aligned\@False - \fi\fi + \if\grp@aligned + \ifdim\dim@a>\grp@linewidth + \global\let\grp@aligned\@False + \fi + \fi % \end{macrocode} % If we're adding an unshifted group number that equations didn't know % about, re-check shifting % \begin{macrocode} \addtolength\dim@a{\grp@wdNum }% Effective length - \if\grp@shiftnumber\else\if\grp@hasNumber\if\grp@eqs@numbered\else\ifdim\dim@a>\grp@linewidth - \global\let\grp@shiftnumber\@True - \fi\fi\fi\fi + \if\grp@shiftnumber + \else + \if\@And{\grp@hasNumber}{\@Not\grp@eqs@numbered} + \ifdim\dim@a>\grp@linewidth + \global\let\grp@shiftnumber\@True + \fi + \fi + \fi % \end{macrocode} % If we can still align, total width is sum of maximum LHS \& RHS % \begin{macrocode} \if\grp@aligned - \global\grp@wdT\grp@wdL\global\advance\grp@wdT\grp@wdR + \global\grp@wdT\grp@wdL + \global\advance\grp@wdT\grp@wdR \fi - \debugmsg{======= DGROUP Formatting - ^^J||===== \grp@wdL=\the\grp@wdL, \grp@wdR=\the\grp@wdR - ^^J||===== Shift Number=\theb@@le\grp@shiftnumber, Eqns. numbered=\theb@@le\grp@eqs@numbered - ^^J||===== Aligned=\theb@@le\grp@aligned - ^^J||===== \grp@wdNum=\the\grp@wdNum}% +%<*trace> + \breqn@debugmsg{======= DGROUP Formatting + \MessageBreak==== \grp@wdL=\the\grp@wdL, \grp@wdR=\the\grp@wdR + \MessageBreak==== Shift Number=\theb@@le\grp@shiftnumber, Eqns. numbered=\theb@@le\grp@eqs@numbered + \MessageBreak==== Aligned=\theb@@le\grp@aligned + \MessageBreak==== \grp@wdNum=\the\grp@wdNum}% +%</trace> % \end{macrocode} % BRM: Originally this stuff was dumped directly, without capturing it % in a \cs{vbox} @@ -6036,9 +6276,17 @@ and the derived files % NOTE: For now, just code up LM number % NOTE: Come back and handle other cases. % NOTE: Vertical spacing is off, perhaps because of inter eqn. glue +% +% A bit of a hack to get the top spacing correct. Fix this logic +% properly some day. Also, we do the calculation in a group for +% maximum safety. % \begin{macrocode} - \eq@topspace{\vskip\parskip}% - \if\grp@hasNumber\if\grp@eqs@numbered\else + \global\let\eq@GRP@first@dmath\@True + \begingroup + \dmath@first@leftskip + \eq@topspace{\vskip\parskip}% + \endgroup + \if\@And{\grp@hasNumber}{\@Not{\grp@eqs@numbered}}% % \eq@topspace{\vskip\parskip}% \if\grp@shiftnumber \copy\GRP@numbox \penalty\@M @@ -6049,13 +6297,17 @@ and the derived files \setlength\skip@c{\dim@a-\ht\GRP@numbox}% \vglue\skip@c% NON discardable \copy\GRP@numbox \penalty\@M -\debugmsg{GROUP NUMBER: preskip:\the\skip@c, postkern:\the\dim@a, height:\the\ht\GRP@wholebox, - ^^J||===== box height:\the\ht\GRP@numbox, box depth:\the\dp\GRP@numbox}% +%<*trace> +\breqn@debugmsg{GROUP NUMBER: preskip:\the\skip@c, postkern:\the\dim@a, height:\the\ht\GRP@wholebox, + \MessageBreak==== box height:\the\ht\GRP@numbox, box depth:\the\dp\GRP@numbox}% +%</trace> \kern-\dim@a \kern-\abovedisplayskip % To cancel the topspace above the first eqn. \fi - \fi\fi + \fi +%<*trace> %\debug@box\GRP@wholebox +%</trace> \unvbox\GRP@wholebox \let\@elt\relax % \end{macrocode} @@ -6205,12 +6457,14 @@ and the derived files \@ifundefined{Mathstrut@}{\let\Mathstrut@\strut}{} \def\darray@cr{\Mathstrut@\cr} \def\col@box{% -%\debugmsg{Col \number\cur@row,\number\cur@col: \the\wd\z@\space x \the\ht\z@+\the\dp\z@}% +%<*trace> +%\breqn@debugmsg{Col \number\cur@row,\number\cur@col: \the\wd\z@\space x \the\ht\z@+\the\dp\z@}% +%</trace> \unhbox\z@ } \newenvironment{darray}{\@optarg\@darray{}}{} \def\@darray[#1]{% - \debugmsg{=== DARRAY ==================================================}% +%<trace> \breqn@debugmsg{=== DARRAY ==================================================}% \if\eq@group\else\eq@prelim\fi % \end{macrocode} % Init the halign preamble to empty, then unless the \quoted{cols} key is @@ -6646,3 +6900,7 @@ and the derived files % \item try to use vadjust for keepglue % % \end{enumerate} +% +% \PrintIndex +% +% \Finale |