Skip to content

Commit

Permalink
Prevent math grabbing inside \m@th
Browse files Browse the repository at this point in the history
This is needed as there are places that \m@th is used *within* a math mode construct. For example, \@tabarray uses \m@th, but is itself
used to construct the array env. The result is that if one 're-activates' math grabbing inside \m@th, \mathchoice in particular 'shows up'.

We will need to examine how to deal with truly
nested math-inside-text-using-\m@th later.

A knock-on of this change is we no longer need
to do anything with \mathchoice, as that always
shows up only inside math mode or inside a \m@th construct.
  • Loading branch information
josephwright committed Jan 9, 2023
1 parent 9c7fc26 commit 95b72a3
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 53 deletions.
24 changes: 2 additions & 22 deletions required/latex-lab/latex-lab-mathcapture.dtx
Expand Up @@ -208,22 +208,6 @@
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mathchoice}
% Avoid issues with multiple collection.
% \begin{macrocode}
\cs_gset_protected:Npn \mathchoice #1#2#3#4
{
\bool_if:NTF \l_@@_collected_bool
{ \tex_mathchoice:D {#1} {#2} {#3} {#4} }
{
\bool_set_true:N \l_@@_collected_bool
\tex_mathchoice:D {#1} {#2} {#3} {#4}
\bool_set_false:N \l_@@_collected_bool
}
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Marking math environments}
%
% A general mechanism for math mode environments that do no grab their
Expand Down Expand Up @@ -388,18 +372,14 @@
% \end{macrocode}
%
% \begin{macro}{\@@_m@th:, \m@th}
% Handle non-math use of math mode but allow for nesting.
% Handle non-math use of math mode. At present nesting isn't supported as
% \cs{m@th} pops up in a few places that \emph{are} math mode!
% \begin{macrocode}
\cs_new_eq:NN \@@_m@th: \m@th
\cs_gset_protected:Npn \m@th
{
\bool_set_true:N \l_@@_collected_bool
\@@_m@th:
\exp_args:No \tex_everymath:D
{
\tex_the:D \tex_everymath:D
\bool_set_false:N \l_@@_collected_bool
}
}
% \end{macrocode}
% \end{macro}
Expand Down
4 changes: 0 additions & 4 deletions required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt
Expand Up @@ -32,10 +32,6 @@

\START

\TYPE {-----------------------------------}
\TYPE{==> Unable to properly define \string\@@mathchoice; primitive \string\mathchoice\space no longer primitive.}
\TYPE{==> conflict with breqn/mathcapture ; needs checking}

11-2-28:
\begin{dmath}
f_{h, \ve}(x, y)
Expand Down
3 changes: 0 additions & 3 deletions required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg
@@ -1,9 +1,6 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
-----------------------------------
==> Unable to properly define \@@mathchoice; primitive \mathchoice no longer primitive.
==> conflict with breqn/mathcapture ; needs checking
-----------------------------------
Math env dmath
f_{h, \ve }(x, y) = \ve \bfE _{x, y} \int _0^{\tve } L_{x, \yvf (\ve u)} \vf (x) \,du = h \int L_{x, z} \vf (x) \rho _x(dz) + h \biggl [ \frac {1}{\tve } \biggl ( \bfE _{y} \int _0^{\tve } L_{x, y^x(s)} \vf (x) \,ds - \tve \int L_{x, z} \vf (x) \rho _x(dz) \biggr ) + \frac {1}{\tve } \biggl ( \bfE _{y} \int _0^{\tve } L_{x, y^x(s)} \vf (x) \,ds - \bfE _{x, y} \int _0^{\tve } L_{x, \yvf (\ve s)} \vf (x) \,ds \biggr ) \biggr ]
==> tagging not working properly
Expand Down
3 changes: 0 additions & 3 deletions required/latex-lab/testfiles-mathcapture/mathcapture-009.tlg
Expand Up @@ -3,8 +3,5 @@ Don't change this file in any respect.
-----------------------------------
Math env equation*
\begin {array}{ccc} S^{\mathcal {W}_\Lambda }\otimes T & \stackrel {j}{\longrightarrow } & T \\ \Big \downarrow & & \Big \downarrow \vcenter {\rlap {$\scriptstyle {\mathrm {End}}\,P$}} \\ (S\otimes T)/I & = & (Z\otimes T)/J \end {array}
-----------------------------------
Math env math
\bool_set_false:N \l__math_collected_bool \scriptstyle {\mathrm {End}}\,P
[1
] (mathcapture-009.aux)
2 changes: 0 additions & 2 deletions required/latex-lab/testfiles-mathcapture/mathcapture-012.lvt
Expand Up @@ -58,8 +58,6 @@ The in-text layout: $ u = v + 1 \pmod{n^2} $
\xmapsto{x>0} A \xleftrightarrow[\text{letters}]{} Z
\end{gather}

\TYPE{==> again spurious extra captures above}

11-4-22:
\begin{gather*}
\ropen{a,d}=\closed{a,b} + \lopen{b,c} + \dotsb \\[3pt]
Expand Down
13 changes: 0 additions & 13 deletions required/latex-lab/testfiles-mathcapture/mathcapture-012.tlg
Expand Up @@ -13,19 +13,6 @@ u = v + 1 \pmod {n^2}
Math env gather
A \xLeftarrow {\ x} B \xRightarrow [y\ ]{} C \xLeftrightarrow [y]{\ x\ } D \\ A \xhookleftarrow {x} B \xhookrightarrow [bbb]{a} C \\ \xleftharpoondown {} \xleftharpoonup {} \xleftrightharpoons {xxx} \xrightleftharpoons [yy]{} \xrightharpoondown {} \xrightharpoonup {} \\ \xmapsto {x>0} A \xleftrightarrow [\text {letters}]{} Z
-----------------------------------
Math env math
\bool_set_false:N \l__math_collected_bool \m@th \thickmuskip 0mu\medmuskip \thickmuskip \thinmuskip \thickmuskip \relax \displaystyle \leftharpoonup \mkern -7mu\cleaders \hbox {$\displaystyle \mkern -2mu\relbar \mkern -2mu$}\hfill \mkern -7mu\relbar
-----------------------------------
Math env math
\bool_set_false:N \l__math_collected_bool \m@th \thickmuskip 0mu\medmuskip \thickmuskip \thinmuskip \thickmuskip \relax \displaystyle \relbar \mkern -7mu\cleaders \hbox {$\displaystyle \mkern -2mu\relbar \mkern -2mu$}\hfill \mkern -7mu\rightharpoondown
-----------------------------------
Math env math
\bool_set_false:N \l__math_collected_bool \m@th \thickmuskip 0mu\medmuskip \thickmuskip \thinmuskip \thickmuskip \relax \displaystyle \relbar \mkern -7mu\cleaders \hbox {$\displaystyle \mkern -2mu\relbar \mkern -2mu$}\hfill \mkern -7mu\rightharpoonup
-----------------------------------
Math env math
\bool_set_false:N \l__math_collected_bool \m@th \thickmuskip 0mu\medmuskip \thickmuskip \thinmuskip \thickmuskip \relax \displaystyle \leftharpoondown \mkern -7mu\cleaders \hbox {$\displaystyle \mkern -2mu\relbar \mkern -2mu$}\hfill \mkern -7mu\relbar
==> again spurious extra captures above
-----------------------------------
Math env gather*
\ropen {a,d}=\closed {a,b} + \lopen {b,c} + \dotsb \\[3pt] \open {\frac {a}{b}} \approx \open *{\frac {a}{b}} \neq \closed [\Bigg ]{x}
-----------------------------------
Expand Down
2 changes: 0 additions & 2 deletions required/latex-lab/testfiles-mathcapture/mathcapture-014.lvt
Expand Up @@ -87,7 +87,5 @@ $ \dot{S} \quad \ddot{P} \quad \dddot{Q} \quad \ddddot{R} $
\overbrace[e]{\enspace a_ix^i + a_{i+1}x^{i+1}} + \dots + a_{n-1}x^{n-1}
\end{multline*}

\TYPE{==> some surplus capture with abraces}


\end{document}
4 changes: 0 additions & 4 deletions required/latex-lab/testfiles-mathcapture/mathcapture-014.tlg
Expand Up @@ -27,9 +27,5 @@ Math env gather*
-----------------------------------
Math env multline*
f(x)=a_0+a_1x+a_2x^2+ \overbrace [B]{a_3x^3 + a_4x^4 + \dots + a_{i-1}x^{i-1} + \enspace } ^{\text {some explanation}} \\ \overbrace [e]{\enspace a_ix^i + a_{i+1}x^{i+1}} + \dots + a_{n-1}x^{n-1}
-----------------------------------
Math env math
\bool_set_false:N \l__math_collected_bool \scriptstyle \text {some explanation}
==> some surplus capture with abraces
[1
] (mathcapture-014.aux)

0 comments on commit 95b72a3

Please sign in to comment.