summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/breqn/mathstyle.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/breqn/mathstyle.dtx')
-rw-r--r--macros/latex/contrib/breqn/mathstyle.dtx111
1 files changed, 82 insertions, 29 deletions
diff --git a/macros/latex/contrib/breqn/mathstyle.dtx b/macros/latex/contrib/breqn/mathstyle.dtx
index 6df4e9426a..94aad71329 100644
--- a/macros/latex/contrib/breqn/mathstyle.dtx
+++ b/macros/latex/contrib/breqn/mathstyle.dtx
@@ -57,8 +57,8 @@
% \fi
%
% \title{The \textsf{mathstyle} package}
-% \def\fileversion{0.98i}
-% \def\filedate{2020/02/18}
+% \def\fileversion{0.98j}
+% \def\filedate{2020/04/19}
% \date{\filedate\quad\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}}
%
@@ -151,7 +151,7 @@
%<*package>
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\ProvidesExplPackage{mathstyle}{2020/02/18}{0.98i}{Tracking mathstyle implicitly}
+\ProvidesExplPackage{mathstyle}{2020/04/19}{0.98j}{Tracking mathstyle implicitly}
\ExplSyntaxOff
% \end{macrocode}
%
@@ -215,6 +215,7 @@
% \end{macro}
%
% \begin{macro}{\mathstyle}
+% \begin{macro}{\mathstyledenom}
% A counter for the math style: 0--display, 2--text, 4--script, 6--scriptscript.
% The logic is that display maths will explicitly
% set \verb|\mathstyle| to zero (see above), so by default it is set to the
@@ -224,12 +225,14 @@
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\endcsname\relax
- \chardef\mathstyle\@ne
+ \chardef\mathstyle=2\relax
+ \chardef\mathstyledenom=0\relax
\else
\directlua{tex.enableprimitives("", {"mathstyle"})}
\fi
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% Save the four style changing primitives, \cs{mathchoice} and the
% fraction commands.
@@ -247,18 +250,18 @@
\@saveprimitive\abovewithdelims\@@abovewithdelims
% \end{macrocode}
% Then we redeclare the four style changing primitives: set the value of
-% \cs{mathstyle} if Lua\TeX{} is not in use.q
+% \cs{mathstyle} if Lua\TeX{} is not in use.
% \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\endcsname\relax
\DeclareRobustCommand{\displaystyle}{%
- \@@displaystyle \chardef\mathstyle\z@}
+ \@@displaystyle \chardef\mathstyle0\relax}
\DeclareRobustCommand{\textstyle}{%
- \@@textstyle \chardef\mathstyle\tw@}
+ \@@textstyle \chardef\mathstyle2\relax}
\DeclareRobustCommand{\scriptstyle}{%
- \@@scriptstyle \chardef\mathstyle4 }
+ \@@scriptstyle \chardef\mathstyle4\relax}
\DeclareRobustCommand{\scriptscriptstyle}{%
- \@@scriptscriptstyle \chardef\mathstyle6 }
+ \@@scriptscriptstyle \chardef\mathstyle6\relax}
\fi
% \end{macrocode}
% First we get the primitive operations. These should have been
@@ -283,8 +286,10 @@
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname directlua\endcsname\relax
\def\subsupstyle{%
- \ifnum\mathstyle<5 \chardef\mathstyle4 %
- \else \chardef\mathstyle6 %
+ \ifnum\mathstyle<4\relax
+ \chardef\mathstyle\numexpr4+\mathstyledenom\relax
+ \else
+ \chardef\mathstyle\numexpr6+\mathstyledenom\relax
\fi
}
\else
@@ -338,17 +343,69 @@
% \end{macro}
%
% \begin{macro}{\genfrac}
+% The amsmath definition:
+% \begin{verbatim}
+% \DeclareRobustCommand{\genfrac}[4]{%
+% \def\@tempa{#1#2}%
+% \edef\@tempb{\@nx\@genfrac\@mathstyle{#4}%
+% \csname @@\ifx @#3@over\else above\fi
+% \ifx\@tempa\@empty \else withdelims\fi\endcsname}
+% \@tempb{#1#2#3}}
+% \end{verbatim}
+% with arguments:
+% \begin{itemize}
+% \item left-delim
+% \item right-delim
+% \item line thickness (default if empty)
+% \item mathstyle override
+% \item numerator
+% \item denominator
+% \end{itemize}
% The fractions. Note that this uses the same names as in
% \pkg{amsmath}. Much the same except here they call \cs{fracstyle}.
% \begin{macrocode}
\DeclareRobustCommand\genfrac[6]{%
- {#1\fracstyle
+ {%
+ % emulate old amsmath syntax:
+ \if 0#4\relax\displaystyle\else
+ \if 1#4\relax\textstyle\else
+ \if 2#4\relax\scriptstyle\else
+ \if 3#4\relax\scriptscriptstyle\else
+ #4%
+ \fi\fi\fi\fi
+ \fracstyle
{\begingroup #5\endgroup
- \csname @@\ifx\maxdimen#4\maxdimen over\else above\fi
- \if @#2@\else withdelims\fi\endcsname #2#3\relax
- #6}%
+ \csname @@\ifx\maxdimen#3\maxdimen over\else above\fi
+ \if @#1@\else withdelims\fi\endcsname #1 #2 #3\relax
+ \ifnum\mathstyledenom=0\relax
+ \chardef\mathstyledenom=1\relax
+ \edef\mathstyle@tempa{\number\mathstyle}%
+ \chardef\mathstyle=\numexpr\mathstyle@tempa+1\relax
+ \fi
+ #6%
+ \chardef\mathstyledenom=0\relax}%
}%
}
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax\else
+\DeclareRobustCommand\genfrac[6]{%
+ {%
+ % emulate old amsmath syntax:
+ \if 0#4\relax\displaystyle\else
+ \if 1#4\relax\textstyle\else
+ \if 2#4\relax\scriptstyle\else
+ \if 3#4\relax\scriptscriptstyle\else
+ #4%
+ \fi\fi\fi\fi
+ \fracstyle
+ {\begingroup #5\endgroup
+ \csname @@\ifx\maxdimen#3\maxdimen over\else above\fi
+ \if @#1@\else withdelims\fi\endcsname #1 #2 #3\relax
+ #6%
+ }%
+ }%
+}
+\fi
% \end{macrocode}
% \changes{v0.90}{2011/08/03}{\cs{fracstyle} must be called \emph{after}
% changing to the required style}
@@ -360,14 +417,14 @@
\renewcommand{\frac}{\genfrac{}{}{}{}}
\providecommand{\dfrac}{}
\providecommand{\tfrac}{}
-\renewcommand{\dfrac}{\genfrac\displaystyle{}{}{}}
-\renewcommand{\tfrac}{\genfrac\textstyle{}{}{}}
+\renewcommand{\dfrac}{\genfrac{}{}{}\displaystyle}
+\renewcommand{\tfrac}{\genfrac{}{}{}\displaystyle}
\providecommand{\binom}{}
\providecommand{\tbinom}{}
\providecommand{\dbinom}{}
-\renewcommand{\binom}{\genfrac{}(){0pt}}
-\renewcommand{\dbinom}{\genfrac\displaystyle(){0pt}}
-\renewcommand{\tbinom}{\genfrac\textstyle(){0pt}}
+\renewcommand{\binom}{\genfrac(){0pt}{}}
+\renewcommand{\dbinom}{\genfrac(){0pt}\displaystyle}
+\renewcommand{\tbinom}{\genfrac(){0pt}\textstyle}
% \end{macrocode}
% The \cs{fracstyle} command is a switch to go one level down but no
@@ -377,15 +434,11 @@
\expandafter\ifx\csname directlua\endcsname\relax
\def\fracstyle{%
\ifcase\numexpr\mathstyle\relax
- \chardef\mathstyle=\@ne
- \or
- \chardef\mathstyle=\@ne
- \or
- \chardef\mathstyle=\tw@
- \or
- \chardef\mathstyle=\tw@
- \else
- \chardef\mathstyle=\thr@@
+ \chardef\mathstyle=0\relax % 0
+ \or \chardef\mathstyle=1\relax % 1
+ \or \chardef\mathstyle=2\relax % 2
+ \or \chardef\mathstyle=3\relax % 3
+ \else \chardef\mathstyle=3\relax % 4 or more
\fi
}
\else