LaTeX reader/writer: change handling of math environments.

Certain environments in LaTeX will trigger math mode and can't
occur within math mode: e.g., `align` or `equation`.  Previously
we "downshifted" these, parsing an `align` environment as a
Math element with `aligned`, and an `equation` environment as a
regular display math element.  With this shift, we put these in
Math inlines but retain the original environments.

This works because:

1) texmath handles these environments just fine,
2) and so does MathJax;
3) when writing LaTeX we detect these environments in Math elements
   and emit them verbatim instead of putting them in `$..$` or
   `$$..$$`.

Closes #9711. Closes #9296.
This commit is contained in:
John MacFarlane
2025-08-11 17:40:41 -07:00
parent 6b2f66507a
commit 0bbbdbcdb6
8 changed files with 59 additions and 21 deletions
+5 -1
View File
@@ -7,5 +7,9 @@
\begin{table}[h]
\end{table}
^D
[ Para [ Math DisplayMath "[0,1)" ] ]
[ Para
[ Math
DisplayMath "\\begin{equation}\n [0,1)\n\\end{equation}"
]
]
```
+1 -1
View File
@@ -11,7 +11,7 @@ E&=&F
[ Para
[ Math
DisplayMath
"\\begin{aligned}\nA&=&B,\\\\\nC&=&D,\\\\\n%\\end{eqnarray}\n%\\begin{eqnarray}\nE&=&F\n\\end{aligned}"
"\\begin{eqnarray}\nA&=&B,\\\\\nC&=&D,\\\\\n%\\end{eqnarray}\n%\\begin{eqnarray}\nE&=&F\n\\end{eqnarray}"
]
]
```
+6 -1
View File
@@ -4,7 +4,12 @@
[d,\delta]=0.
\end{equation*}
^D
[ Para [ Math DisplayMath "[d,\\delta]=0." ] ]
[ Para
[ Math
DisplayMath
"\\begin{equation*}\n[d,\\delta]=0.\n\\end{equation*}"
]
]
```
```
+5 -1
View File
@@ -7,5 +7,9 @@
y=x^2
\EEQ
^D
[ Para [ Math DisplayMath "y=x^2" ] ]
[ Para
[ Math
DisplayMath "\\begin{equation}\ny=x^2\n\\end{equation}"
]
]
```
+2 -2
View File
@@ -61,9 +61,9 @@ x &= y\\
^D
\(5-67\)
\[\begin{aligned}
\begin{align}
x &= y\\
\end{aligned}\]
\end{align}
\emph{hi}
+1 -1
View File
@@ -118,7 +118,7 @@ Accuracy~\eqref{eq:Accuracy} is the proportion, measuring true results among all
, Para
[ Math
DisplayMath
"\\label{eq:Accuracy}\n Accuracy = \\frac{t_p + t_n}{t_p + f_p + f_n + t_n}"
"\\begin{equation}\n \\label{eq:Accuracy}\n Accuracy = \\frac{t_p + t_n}{t_p + f_p + f_n + t_n}\n\\end{equation}"
]
]
```