[latex3-commits] [git/LaTeX3-latex3-latex2e] everymath: Add \RegisterMathEnviornment/\math_register_env:n (dead7cda)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri Jan 6 14:44:27 CET 2023
Repository : https://github.com/latex3/latex2e
On branch : everymath
Link : https://github.com/latex3/latex2e/commit/dead7cda5ce268f567e8b9bf9b36bf2f264012f2
>---------------------------------------------------------------
commit dead7cda5ce268f567e8b9bf9b36bf2f264012f2
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Jan 6 13:39:41 2023 +0000
Add \RegisterMathEnviornment/\math_register_env:n
Could be \Install...?
Support for breqn not quite right yet and needs
tagging disabling. Support for tikzcd still lacking:
likely needs custom code.
>---------------------------------------------------------------
dead7cda5ce268f567e8b9bf9b36bf2f264012f2
required/latex-lab/latex-lab-mathcapture.dtx | 91 +++++++++++++---------
.../testfiles-mathcapture/mathcapture-007.lvt | 5 +-
.../testfiles-mathcapture/mathcapture-007.tlg | 24 +++---
.../testfiles-mathcapture/mathcapture-011.lvt | 5 +-
.../testfiles-mathcapture/mathcapture-011.tlg | 20 ++---
5 files changed, 77 insertions(+), 68 deletions(-)
diff --git a/required/latex-lab/latex-lab-mathcapture.dtx b/required/latex-lab/latex-lab-mathcapture.dtx
index 697496b7..f7df95c8 100644
--- a/required/latex-lab/latex-lab-mathcapture.dtx
+++ b/required/latex-lab/latex-lab-mathcapture.dtx
@@ -57,8 +57,18 @@
%\end{verbatim}
% would only result in a single capture of the tokens
% ``\verb*/a \in A \text{ for all $a<5$}/''.
-
-% It provides one code-level interface to use this captured input.
+%
+% \subsection{Code level interfaces}
+%
+% \begin{function}{\math_register_env:n}
+% \begin{syntax}
+% \cs{math_register_env:n} \Arg{env}
+% \end{syntax}
+% Registers the \meta{env} as a math environment which should be captured
+% and made available. This is necessary for all top-level math mode
+% environments: low-level errors may result if these are not correct
+% set up.
+% \end{function}
%
% \begin{function}{\math_processor:n}
% \begin{syntax}
@@ -68,6 +78,18 @@
% \meta{tokens}, which will receive the content as |#1|.
% \end{function}
%
+% \subsection{Document level interfaces}
+%
+% \begin{function}{\RegisterMathEnvironment}
+% \begin{syntax}
+% \cs{RegisterMathEnvironment} \Arg{env}
+% \end{syntax}
+% Registers the \meta{env} as a math environment which should be captured
+% and made available. This is necessary for all top-level math mode
+% environments: low-level errors may result if these are not correct
+% set up.
+% \end{function}
+%
% \MaybeStop{\setlength\IndexMin{200pt} \PrintIndex }
%
% \section{The Implementation}
@@ -179,6 +201,35 @@
% \end{macrocode}
% \end{macro}
%
+% \subsection{Marking math environments}
+%
+% A general mechanism for math mode environments that do no grab their
+% content (\emph{cf.}~most \pkg{amsmath} environments).
+%
+% \begin{macro}{\math_register_env:n}
+% \begin{macro}{\RegisterMathEnvironment}
+% Set up to capture environment content and make available.
+% \begin{macrocode}
+\cs_new_protected:Npn \math_register_env:n #1
+ {
+ \cs_gset_eq:cc { @@_env_ #1 _begin: } {#1}
+ \cs_gset_eq:cc { @@_env_ #1 _end: } { end #1 }
+ \ExpandArgs { nnx } \RenewDocumentEnvironment {#1} { b }
+ {
+ \bool_set_true:N \exp_not:N \l_@@_collected_bool
+ \exp_not:N \@@_process:n {####1}
+ \exp_not:c { @@_env_ #1 _begin: }
+ ####1
+ \exp_not:c { @@_env_ #1 _end: }
+ }
+ { }
+ }
+\NewDocumentCommand \RegisterMathEnvironment { m }
+ { \math_register_env:n {#1} }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Document commands}
%
% \begin{macro}
@@ -191,24 +242,8 @@
% \begin{macrocode}
\tl_gput_right:Nn \@kernel at before@begindocument
{
- \cs_new_eq:NN \@@_equation_begin: \equation
- \cs_new_eq:NN \@@_equation_end: \endequation
- \RenewDocumentEnvironment { equation } { b }
- {
- \bool_set_true:N \l_@@_collected_bool
- \@@_process:n {#1}
- \@@_equation_begin: #1 \@@_equation_end:
- }
- { }
- \cs_new_eq:Nc \@@_equation_star_begin: { equation* }
- \cs_new_eq:Nc \@@_equation_star_end: { endequation* }
- \RenewDocumentEnvironment { equation* } { b }
- {
- \bool_set_true:N \l_@@_collected_bool
- \@@_process:n {#1}
- \@@_equation_star_begin: #1 \@@_equation_star_end:
- }
- { }
+ \math_register_env:n { equation }
+ \math_register_env:n { equation* }
}
% \end{macrocode}
% \end{macro}
@@ -315,24 +350,10 @@
%
% \subsection{Modifying kernel environments}
%
-% \begin{macro}{\eqnarray, \@@_eqnarray_begin:}
-% \begin{macro}{\endeqnarray, \@@_eqnarray_end:}
% We need to cover this even though it is of course not encouraged.
% \begin{macrocode}
-\cs_new_eq:NN \@@_eqnarray_begin: \eqnarray
-\cs_new_eq:NN \@@_eqnarray_end: \endeqnarray
-\RenewDocumentEnvironment { eqnarray } { b }
- {
- \bool_set_true:N \l_@@_collected_bool
- \@@_process:n {#1}
- \@@_eqnarray_begin:
- #1
- \@@_eqnarray_end:
- }
- { }
+\math_register_env:n { eqnarray }
% \end{macrocode}
-% \end{macro}
-% \end{macro}
%
% Places where math mode is (ab)used.
% \begin{macrocode}
diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt b/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt
index a242be30..fc5a48f0 100644
--- a/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt
+++ b/required/latex-lab/testfiles-mathcapture/mathcapture-007.lvt
@@ -1,6 +1,6 @@
% breqn examples ...
-\DocumentMetadata{testphase=phase-II}
+%\DocumentMetadata{testphase=phase-II}
\documentclass{article}
@@ -38,6 +38,8 @@
\TYPE{next examples die ....}
+\RegisterMathEnvironment{dmath}
+
11-2-28:
\begin{dmath}
f_{h, \ve}(x, y)
@@ -52,6 +54,7 @@
\vf(x) \,ds \biggr) \biggr]
\end{dmath}
+\RegisterMathEnvironment{dgroup*}
11-2-28:
\begin{dgroup*}
diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg b/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg
index d7b54bc9..c90415ac 100644
--- a/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg
+++ b/required/latex-lab/testfiles-mathcapture/mathcapture-007.tlg
@@ -1,17 +1,13 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
next examples die ....
-)
-Runaway argument?
-\displaystyle \penalty -\@Mi f_{h, \ve }(x, y) = \ve \bfE _{x, y} \int \ETC.
-! File ended while scanning use of \__math_grab_dollar:w.
-<inserted text>
- \par
-<*> \input mathcapture-007.lvt
-I suspect you have forgotten a `}', causing me
-to read past where you wanted me to stop.
-I'll try to recover; but if the error is serious,
-you'd better type `E' or `X' now and fix your file.
-! Emergency stop.
-<*> \input mathcapture-007.lvt
-*** (job aborted, no legal \end found)
+-----------------------------------
+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 ]
+-----------------------------------
+\begin {dmath} (a+b)^2 = a^2+2ab+b^2 \end {dmath} \begin {dmath} (a-b)^2 = a^2-2ab+b^2 \end {dmath} \begin {dmath*} (a+b)(a-b) = a^2-b^2 \end {dmath*}
+-----------------------------------
+(a+b)^2 = a^2+2ab+b^2
+-----------------------------------
+(a-b)^2 = a^2-2ab+b^2
+-----------------------------------
+\frac {1}{x} \condition {for $x\ne 0$}
diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-011.lvt b/required/latex-lab/testfiles-mathcapture/mathcapture-011.lvt
index 147b0862..275ea2b2 100644
--- a/required/latex-lab/testfiles-mathcapture/mathcapture-011.lvt
+++ b/required/latex-lab/testfiles-mathcapture/mathcapture-011.lvt
@@ -36,6 +36,7 @@
\TYPE{????? just loading cases but not amsmath now gives an error}
\TYPE {-----------------------------------}
+\RegisterMathEnvironment{smallmatrix}
11-3-3:
To show the effect of the matrix on surrounding
@@ -44,9 +45,7 @@ $\left(\begin{smallmatrix}
-1 & 0 \\ 0 & -1 \end{smallmatrix}\right)$
and follow it with some more text on the next line.
-\TYPE {-----------------------------------}
-\TYPE{???????????????????????? another case for "I'm a math display" interface}
-
+\RegisterMathEnvironment{subnumcases}
11-3-7:
\begin{subnumcases}{f(x) = \label{L1}}
diff --git a/required/latex-lab/testfiles-mathcapture/mathcapture-011.tlg b/required/latex-lab/testfiles-mathcapture/mathcapture-011.tlg
index c48fc11a..7c7f671f 100644
--- a/required/latex-lab/testfiles-mathcapture/mathcapture-011.tlg
+++ b/required/latex-lab/testfiles-mathcapture/mathcapture-011.tlg
@@ -6,18 +6,8 @@ Don't change this file in any respect.
-----------------------------------
\left (\begin {smallmatrix} -1 & 0 \\ 0 & -1 \end {smallmatrix}\right )
-----------------------------------
-???????????????????????? another case for "I'm a math display" interface
-)
-Runaway argument?
-\numc at opts \refstepcounter {equation}\setbox \z@ \hbox {\def \@currentlabel \ETC.
-! File ended while scanning use of \__math_grab_dollardollar:w.
-<inserted text>
- \par
-<*> \input mathcapture-011.lvt
-I suspect you have forgotten a `}', causing me
-to read past where you wanted me to stop.
-I'll try to recover; but if the error is serious,
-you'd better type `E' or `X' now and fix your file.
-! Emergency stop.
-<*> \input mathcapture-011.lvt
-*** (job aborted, no legal \end found)
+-1 & 0 \\ 0 & -1
+-----------------------------------
+{f(x) = \label {L1}} -1 & if $x<0$\,, \\ 0 & if $x=0$\,, \tag {$*$} \\ 1 & if $x>0$\,. \label {L2}
+[1
+] (mathcapture-011.aux)
More information about the latex3-commits
mailing list.