summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/breqn/breqn.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/breqn/breqn.dtx')
-rw-r--r--macros/latex/contrib/breqn/breqn.dtx135
1 files changed, 50 insertions, 85 deletions
diff --git a/macros/latex/contrib/breqn/breqn.dtx b/macros/latex/contrib/breqn/breqn.dtx
index 1d0bee5c8f..3222bb8945 100644
--- a/macros/latex/contrib/breqn/breqn.dtx
+++ b/macros/latex/contrib/breqn/breqn.dtx
@@ -3,7 +3,7 @@
% Copyright (C) 1997-2003 by Michael J. Downes
% Copyright (C) 2007-2008 by Morten Hoegholm
% Copyright (C) 2007-2014 by Lars Madsen
-% Copyright (C) 2007-2014 by Will Robertson
+% Copyright (C) 2007-2020 by Will Robertson
% Copyright (C) 2010-2017 by Joseph Wright
%
% This work may be distributed and/or modified under the
@@ -57,9 +57,6 @@
\usepackage{geometry}
-\AtBeginDocument{\addtocontents{toc}{\protect\begin{multicols}{2}}}
-\AtEndDocument{\addtocontents{toc}{\protect\end{multicols}}}
-
\def\partname{Part}
\definecolor{hilite}{rgb}{0.2,0.4,0.7}
@@ -153,8 +150,8 @@
%
%
% \title{The \pkg{breqn} package}
-% \def\fileversion{0.98g}
-% \def\filedate{2019/10/15}
+% \def\fileversion{0.98h}
+% \def\filedate{2020/02/16}
% \date{\pkg{breqn} bundle: \filedate\space\fileversion}
% \author{Authors: Michael J. Downes, Morten H\o gholm\\ Maintained by Morten H\o gholm, Will Robertson\\ Feedback: \texttt{https://github.com/wspr/breqn/issues}}
%
@@ -399,12 +396,12 @@
% \env{dmath} or \env{dgroup} environments, and some of them require an
% argument, which is something that cannot be done through the normal
% package option mechanism. Therefore most of the \pkg{breqn} package
-% options are designed to be set with a \cs{setkeys} command after the
+% options are designed to be set with the \cs{breqnsetup} command after the
% package is loaded. For example, to load the package and set the
% maximum delimiter nesting depth for line breaks to~1:
% \begin{verbatim}
% \usepackage{breqn}
-% \setkeys{breqn}{breakdepth={1}}
+% \breqnsetup{breakdepth={1}}
% \end{verbatim}
%
% See the discussion of environment options, Section~\vref{envopts}, for
@@ -1384,7 +1381,7 @@
% Declare package name and date.
% \begin{macrocode}
\RequirePackage{expl3}
-\ProvidesExplPackage{breqn}{2019/10/15}{0.98g}{Breaking equations}
+\ProvidesExplPackage{breqn}{2020/02/16}{0.98h}{Breaking equations}
% \end{macrocode}
% Regrettably, \pkg{breqn} is internally a mess, so we have to take
% some odd steps.
@@ -1395,10 +1392,6 @@
%
% \section{Package options}
%
-% 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.
-%
% First we need to get the catcodes sorted out.
% \begin{macrocode}
\edef\breqnpopcats{%
@@ -1419,6 +1412,19 @@
%
%
% \section{Required packages}
+%
+% Although breqn can be loaded without amsmath, there's not much point, and explicitly
+% loading amsmath here prevents loading-order issues later.
+% \begin{macrocode}
+\RequirePackage{amsmath}
+% \end{macrocode}
+%
+% Similarly, if graphicx is loaded atbegindocument there is a catcode clash, so load it here too.
+% (see test file 00-clash-1.lvt)
+% \begin{macrocode}
+\RequirePackage{graphicx}
+% \end{macrocode}
+%
% The \pkg{flexisym} package makes it possible to attach
% extra actions to math symbols, in particular mathbin, mathrel, mathopen,
% and mathclose symbols.
@@ -1445,69 +1451,14 @@
% \end{macrocode}
%
%
-% And add an \cs{options} cmd for processing package
-% options that require an argument. Maybe this will get added to
-% the \pkg{keyval} package eventually.
-% \begin{macrocode}
-\@ifundefined{options}{%
-% \end{macrocode}
-%
-%
-% \begin{macro}{\options}
-% Get the package options and run setkeys on them.
-% \begin{macrocode}
-\newcommand{\options}[2]{%
- \expandafter\options@a\csname opt@#1.sty\endcsname{#2}%
- \setkeys{#1}{#2}%
-}
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\options@a}
-% \begin{macro}{\options@b}
-% \begin{macro}{\options@c}
-% \begin{macro}{\options@d}
-% Redefine \cs{opt@pkgname.sty} as we go along to take out
-% the options that are handled and leave the ones that are not.
-% \begin{macrocode}
-\def\options@a#1#2{%
- \edef\@tempa{\options@b#2,\@empty\@nil}%
- \ifx#1\relax \let#1\@empty\fi
- \xdef#1{#1\ifx#1\@empty\@xp\@gobble\@tempa\@empty\else\@tempa \fi}%
-}
-% \end{macrocode}
-% Add the next option, and recurse if there remain more
-% options.
-% \begin{macrocode}
-\def\options@b#1,#2#3\@nil{%
- \options@c#1 \@nil
- \ifx#2\@empty \else\options@b#2#3\@nil\fi
-}
-% \end{macrocode}
-% Discard everything after the first space.
+% \begin{macro}{\breqnsetup}
% \begin{macrocode}
-\def\options@c#1 #2\@nil{\options@d#1=\@nil}
+\newcommand{\breqnsetup}[1]{\setkeys{breqn}{#1}}
% \end{macrocode}
-% Discard everything after the first = sign; add a comma only if the
-% remainder is not empty.
-% \begin{macrocode}
-\def\options@d#1=#2\@nil{\ifx\@empty #1\@empty\else,\fi#1}
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
% \end{macro}
%
%
%
-% The tail of the \cs{@ifundefined} test.
-% \begin{macrocode}
-}{}% end @ifundefined test
-% \end{macrocode}
-%
-%
-%
%
% \section{Some useful tools}
%
@@ -1674,7 +1625,7 @@
% \end{macro}
%
%
-% \begin{macro}{\@ifstar}
+% \begin{macro}{\breqn@ifstar}
% Similarly let's remove space-skipping from \cs{@ifstar}
% because in some rare case of \dbslash inside an equation, followed by
% a space and a \verb"*" where the \verb"*" is intended as the math
@@ -1687,7 +1638,7 @@
% written as \dbslash \verb"*" by any one who really wants the
% \verb"*" to act as a modifier for the \dbslash command.
% \begin{macrocode}
-\def\@ifstar#1#2{%
+\def\breqn@ifstar#1#2{%
\let\@tempd*\def\@tempa*{#1}\def\@tempb{#2}%
\futurelet\@tempc\@ifnexta
}
@@ -1695,11 +1646,11 @@
% \end{macro}
%
%
-% \begin{macro}{\@optarg}
+% \begin{macro}{\breqn@optarg}
% Utility function for reading an optional arg
% \emph{without} skipping over any intervening spaces.
% \begin{macrocode}
-\def\@optarg#1#2{\@ifnext[{#1}{#1[#2]}}
+\def\breqn@optarg#1#2{\@ifnext[{#1}{#1[#2]}}
% \end{macrocode}
% \end{macro}
%
@@ -2641,7 +2592,7 @@
% \end{literalcode}
% WSPR: added the option for a label prefix, designed to be used in the preamble like so:
% \begin{literalcode}
-% \setkeys{breqn}{labelprefix={eq:}}
+% \breqnsetup{labelprefix={eq:}}
% \end{literalcode}
% \begin{macrocode}
\define@key{breqn}{label}{%
@@ -2905,7 +2856,7 @@
% \begin{macrocode}
\newenvironment{dmath}{%
\@dmath@start@hook
- \let\eq@hasNumber\@True \@optarg\@dmath{}}{}
+ \let\eq@hasNumber\@True \breqn@optarg\@dmath{}}{}
\def\@dmath[#1]{%
%<trace> \breqn@debugmsg{=== DMATH ==================================================}%
\everydisplay\expandafter{\the\everydisplay \display@setup}%
@@ -2966,7 +2917,7 @@
% \begin{macrocode}
\newenvironment{dmath*}{%
\@dmath@start@hook
- \let\eq@hasNumber\@False \@optarg\@dmath{}%
+ \let\eq@hasNumber\@False \breqn@optarg\@dmath{}%
}{}
\@namedef{end@dmath*}{\end@dmath}
\@namedef{enddmath*}#1{\check@punct@or@qed}
@@ -3409,6 +3360,20 @@
% doesn't help end users much; it works better to use it during package
% testing by the maintainer.
%
+% Note to self: I always forget how this redefinition works. Here's a summary.
+% The approach is:
+% \begin{verbatim}
+% \def\enddmath#1{\check@punct@or@qed}
+% \end{verbatim}
+% When hitting the end of the dmath environment we then have:
+% \begin{verbatim}
+% \csname end#1\endcsname \latex@end{#1}
+% \enddmath \latex@end{dmath}
+% \check@punct@or@qed {dmath} % <- \enddmath absorbs one arg
+% \xdef\found@punct{\@empty}\def\finish@end{\csname end@dmath\endcsname\latex@end{dmath}}\check@punct
+% \end{verbatim}
+% At which point \verb|\check@punct| is `past' the end of the environment and can look ahead.
+%
%
% If a particular environment needs to call a different end action, the
% end command of the environment should be defined to gobble two args and
@@ -3791,7 +3756,7 @@
% \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
+% \cs{left} \cs{right} pairs, \cs{ss@scan} gets involved. It seems to produce
% a separate box marked w/\cs{penalty} 3. But it appears that \cs{eq@repack}
% is only expecting a single box for the LHS; when it measures that
% box it's missing the (typically larger) bracketted section,
@@ -4066,7 +4031,7 @@
% break.
% \begin{macrocode}
\def\eq@newline{%
- \@ifstar{\eq@newlinea\@M}{\eq@newlinea\eqinterlinepenalty}}
+ \breqn@ifstar{\eq@newlinea\@M}{\eq@newlinea\eqinterlinepenalty}}
\def\eq@newlinea#1{%
\@ifnext[{\eq@newlineb{#1}}{\eq@newlineb{#1}[\maxdimen]}}
\def\eq@newlineb#1[#2]{\penalty-\@M}
@@ -6254,13 +6219,13 @@
% series don't all fit in a single line, they are continued onto extra
% lines in a ragged-center format.
% \begin{macrocode}
-\newenvironment{dseries}{\let\eq@hasNumber\@True \@optarg\@dseries{}}{}%
+\newenvironment{dseries}{\let\eq@hasNumber\@True \breqn@optarg\@dseries{}}{}%
\def\enddseries#1{\check@punct@or@qed}%
% \end{macrocode}
%
% And the unnumbered version of same.
% \begin{macrocode}
-\newenvironment{dseries*}{\let\eq@hasNumber\@False \@optarg\@dseries{}}{}%
+\newenvironment{dseries*}{\let\eq@hasNumber\@False \breqn@optarg\@dseries{}}{}%
\@namedef{enddseries*}#1{\check@punct@or@qed}%
\@namedef{end@dseries*}{\end@dseries}%
\def\@dseries[#1]{%
@@ -6459,7 +6424,7 @@
% \begin{macrocode}
\newenvironment{dgroup}{%
\@dgroup@start@hook
- \let\grp@hasNumber\@True\@optarg\@dgroup{}%
+ \let\grp@hasNumber\@True\breqn@optarg\@dgroup{}%
}{%
\end@dgroup
}
@@ -6468,7 +6433,7 @@
% \begin{macrocode}
\newtoks\GRP@queue
\newenvironment{dgroup*}{%
- \let\grp@hasNumber\@False\@optarg\@dgroup{}%
+ \let\grp@hasNumber\@False\breqn@optarg\@dgroup{}%
}{%
\end@dgroup
}
@@ -6835,7 +6800,7 @@
%</trace>
\unhbox\z@
}
-\newenvironment{darray}{\@optarg\@darray{}}{}
+\newenvironment{darray}{\breqn@optarg\@darray{}}{}
\def\@darray[#1]{%
%<trace> \breqn@debugmsg{=== DARRAY ==================================================}%
\if\eq@group\else\eq@prelim\fi
@@ -6915,7 +6880,7 @@
% \begin{macrocode}
\newcommand\condition{%
\begingroup\@tempswatrue
- \@ifstar{\@tempswafalse \condition@a}{\condition@a}}
+ \breqn@ifstar{\@tempswafalse \condition@a}{\condition@a}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\condition@a}