[latex3-commits] [git/LaTeX3-latex3-latex2e] everymath: Suppress \relax from \ensuremath (b8a822c5)

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Dec 11 21:51:39 CET 2022


Repository : https://github.com/latex3/latex2e
On branch  : everymath
Link       : https://github.com/latex3/latex2e/commit/b8a822c5b294f9dd9c0482bc45aaf8afd2c7239c

>---------------------------------------------------------------

commit b8a822c5b294f9dd9c0482bc45aaf8afd2c7239c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sun Dec 11 20:51:39 2022 +0000

    Suppress \relax from \ensuremath


>---------------------------------------------------------------

b8a822c5b294f9dd9c0482bc45aaf8afd2c7239c
 required/latex-lab/latex-lab-everymath.dtx     | 23 +++++++++++++++++++++++
 required/latex-lab/testfiles/everymath-001.lvt |  2 ++
 required/latex-lab/testfiles/everymath-001.tlg |  1 +
 3 files changed, 26 insertions(+)

diff --git a/required/latex-lab/latex-lab-everymath.dtx b/required/latex-lab/latex-lab-everymath.dtx
index 47b360cb..fcd8d56e 100644
--- a/required/latex-lab/latex-lab-everymath.dtx
+++ b/required/latex-lab/latex-lab-everymath.dtx
@@ -260,6 +260,29 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\ensuremath}
+%   The \cs{relax} added here is needed for the \TeX{}, but not for the
+%   grabbed content, so we suppress it and handle collection 
+%    \begin{macrocode}
+\cs_gset_protected:Npn \ensuremath #1
+  {
+    \mode_if_math:TF
+      {#1}
+      {
+        \bool_if:NTF \l_@@_collected_bool
+          { \@ensuredmath {#1} }
+          {
+            \bool_set_true:N \l_@@_collected_bool
+            \@@_process:n {#1}
+            \@ensuredmath {#1}
+            \bool_set_false:N \l_@@_collected_bool
+
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{\cs{everymath} and \cs{everydisplay}}
 %
 % The business end for grabbing inline math and \enquote{raw} \TeX{}
diff --git a/required/latex-lab/testfiles/everymath-001.lvt b/required/latex-lab/testfiles/everymath-001.lvt
index b0d96c0d..b33b4d34 100644
--- a/required/latex-lab/testfiles/everymath-001.lvt
+++ b/required/latex-lab/testfiles/everymath-001.lvt
@@ -48,4 +48,6 @@ Try $g_{\hbox{foo$b$}}$
   a & b & c \\
 \end{tabular}
 
+Some text \ensuremath{\alpha}.
+
 \END
diff --git a/required/latex-lab/testfiles/everymath-001.tlg b/required/latex-lab/testfiles/everymath-001.tlg
index 9aa01cb5..74cbb99d 100644
--- a/required/latex-lab/testfiles/everymath-001.tlg
+++ b/required/latex-lab/testfiles/everymath-001.tlg
@@ -4,3 +4,4 @@ y = mx + c
 y = mx + c
 y = mx + c \hskip 1em\relax \hbox {for all $c$}
 g_{\hbox {foo$b$}}
+\alpha 





More information about the latex3-commits mailing list.