Is there some smart macro I could add in the preamble to handle this LaTeX auto-generated code?
I use Maple's latex()
command to convert results to LaTeX that I then compile using texlive in a separate document.
Sometimes it generates the wrong LaTeX or broken LaTeX. Here is an example of one such case:
The above output is send to a latex file and wrapped inside \begin{equation}
and \end{equation}
. I picked equation
environment to put the result inside, but I can change this if it helps in conversions.
This is all done using an automated script. I do not use any of Maple style sheets or anything else. I simply just take the latex() output and process that using texlive standard setup.
I have hundreds of such equations, so manually editing any broken Maple LaTeX output is not possible and since each time I re-run the script the edits will be lost.
Is there a way to make a macro that will convert the above to use \begin{cases}
with an enclosing \end{cases}
using some smart replacement rule to make LaTeX and amsmath happy?
Here is the error, and a MWE:
MWE
\documentclass[11pt,notitlepage]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%smart renewcommand here? or \let?
\begin{document}
\begin{equation}
x-
\cases{-2\,\sqrt {-y \left( x \right) }&$y \left( x \right) \leq 0$\cr
2\,\sqrt {y \left( x \right) }&$0<y \left( x \right) $\cr}+{\it \_C1}=0_{{1}}
\end{equation}
\end{document}
and
pdflatex foo.tex
(/usr/local/texlive/2014/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2014/texmf-dist/tex/latex/amsfonts/umsb.fd)
! Package amsmath Error: Old form `\cases' should be \begin{cases}.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.9 \cases
{-2\,\sqrt {-y \left( x \right) }&$y \left( x \right) \leq 0$\cr
?
\cases
” has nothing to do withamsmath
; it is in the LaTeX kernel because it was in Plain TeX. I'm quite surprised that Maple uses that deprecated form, as thecases
environment was included in the originalamslatex
back in 1990.Package amsmath Error:
. thanks