[latex3-commits] [git/LaTeX3-latex3-latex2e] everymath: Allow for nesting \[/\] in envs (363e6161)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Dec 9 18:03:25 CET 2022


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

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

commit 363e61617455f04ef235c9e855d62f691ad85c6d
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Dec 9 17:03:25 2022 +0000

    Allow for nesting \[/\] in envs
    
    For this to work fully, we will need to either expose
    the bool or to provide a 'wrapper' function.


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

363e61617455f04ef235c9e855d62f691ad85c6d
 required/latex-lab/latex-lab-everymath.dtx | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/required/latex-lab/latex-lab-everymath.dtx b/required/latex-lab/latex-lab-everymath.dtx
index 61fedfc0..e8ab9afd 100644
--- a/required/latex-lab/latex-lab-everymath.dtx
+++ b/required/latex-lab/latex-lab-everymath.dtx
@@ -179,6 +179,15 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_grab_eqn:w}
+%   For the most common use of \cs{[}/\cs{]}: turn into an environment.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_grab_eqn:w % \[
+  #1 \]
+  { \begin { equation* } #1 \end { equation* } }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Document commands}
 %
 % \begin{macro}{\(, \)}
@@ -247,11 +256,18 @@
 %    \begin{macrocode}
 \AddToHook { begindocument }
   {
-    \cs_gset_protected:Npn \[ #1 \]
+    \cs_gset_protected:Npn \[ % \]
       {
-        \begin{ equation* } #1 \end { equation* }
+        \bool_if:NTF \l_@@_env_bool
+          { \begin { equation* } }
+          { \@@_grab_eqn:w }
       } % \[
-    \cs_gset_protected:Npn \] { }
+    \cs_gset_protected:Npn \]
+      {
+        \bool_if:NTF \l_@@_env_bool
+          { \end{ equation* } }
+          { \@badmath }
+      }
     \cs_undefine:c { [ \c_space_tl }
     \cs_undefine:c { ] \c_space_tl }
   }





More information about the latex3-commits mailing list.