From 95b72a3aa489f7beba3d588de52733d5032f5926 Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Mon, 9 Jan 2023 09:41:39 +0000 Subject: [PATCH] Prevent math grabbing inside \m@th 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. --- required/latex-lab/latex-lab-mathcapture.dtx | 24 ++----------------- .../testfiles-mathcapture/mathcapture-007.lvt | 4 ---- .../testfiles-mathcapture/mathcapture-007.tlg | 3 --- .../testfiles-mathcapture/mathcapture-009.tlg | 3 --- .../testfiles-mathcapture/mathcapture-012.lvt | 2 -- .../testfiles-mathcapture/mathcapture-012.tlg | 13 ---------- .../testfiles-mathcapture/mathcapture-014.lvt | 2 -- .../testfiles-mathcapture/mathcapture-014.tlg | 4 ---- 8 files changed, 2 insertions(+), 53 deletions(-) diff --git a/required/latex-lab/latex-lab-mathcapture.dtx b/required/latex-lab/latex-lab-mathcapture.dtx index b52e48416..24401e2ba 100644 --- a/required/latex-lab/latex-lab-mathcapture.dtx +++ b/required/latex-lab/latex-lab-mathcapture.dtx @@ -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 @@ -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} diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt b/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt index 81fa58de0..1725f76f0 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt +++ b/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt @@ -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) diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg b/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg index eaf8c4a25..d010e87fc 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg +++ b/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 diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-009.tlg b/required/latex-lab/testfiles-mathcapture/mathcapture-009.tlg index ca2c92996..c9b2a6f89 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-009.tlg +++ b/required/latex-lab/testfiles-mathcapture/mathcapture-009.tlg @@ -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) diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-012.lvt b/required/latex-lab/testfiles-mathcapture/mathcapture-012.lvt index 22fee1722..05c0ed355 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-012.lvt +++ b/required/latex-lab/testfiles-mathcapture/mathcapture-012.lvt @@ -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] diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-012.tlg b/required/latex-lab/testfiles-mathcapture/mathcapture-012.tlg index 0e7ff328d..ba943e19b 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-012.tlg +++ b/required/latex-lab/testfiles-mathcapture/mathcapture-012.tlg @@ -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} ----------------------------------- diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-014.lvt b/required/latex-lab/testfiles-mathcapture/mathcapture-014.lvt index d8e858c18..e14a6dd1e 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-014.lvt +++ b/required/latex-lab/testfiles-mathcapture/mathcapture-014.lvt @@ -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} diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-014.tlg b/required/latex-lab/testfiles-mathcapture/mathcapture-014.tlg index b4cbff201..b6e46cc50 100644 --- a/required/latex-lab/testfiles-mathcapture/mathcapture-014.tlg +++ b/required/latex-lab/testfiles-mathcapture/mathcapture-014.tlg @@ -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)