2

The following MWE:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[ \begin{split} a &= b \\ c &= d \end{split} \]

\end{document}

compiles fine with pdflatex, but when I run make4ht on it, I get the following error:

! Package amsmath Error: \begin{split} won't work here.

See the amsmath package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.7 \[ \begin{split} a &= b \\ c &= d \end{split}
                                                  \]

Is this an incompatibility of tex4ht? Is there an easy way to deal with this? I could just use align* in this instance, but there is a reason that I want to use split instead.

3

You can try the following configuration file:

\Preamble{xhtml}
\makeatletter
\DeclareRobustCommand\[{%
\bgroup%
  \mathdisplay@push%
  \st@rredtrue \global\@eqnswfalse%
  \mathdisplay{equation*}%
\csname st:Math\endcsname
}

\DeclareRobustCommand\]{%
\csname ed:Math\endcsname
  \endmathdisplay{equation*}%
  \mathdisplay@pop%
  \ignorespacesafterend%
\egroup
}
\makeatother
\Configure{[]}{\Picture*{}}{\EndPicture}
\begin{document}
\EndPreamble

It does basically the same thing as amsmath + the ability to use the \Configure{[]} command. It is used to convert the display math as picture in this example. Note that this configuration will not work for MathMl or MathJax.

enter image description here

For MathML, use:

\Preamble{xhtml}
\DeclareRobustCommand{\[}{\begin{equation*}}
\DeclareRobustCommand{\]}{\end{equation*}}
\begin{document}
\EndPreamble

Your code works well in the MathJax node without any configurations.

  • It's helpful to have both versions of this; I do use MathML. This is a bit off-topic, but does the mathjax method you are referring to effectively generate mathml and then run it through mathjax to generate HTML+CSS (or some other output)? I was meaning to look into how this works but didn't get the time yet. – Alex Watson Oct 10 at 16:17
  • @AlexWatson the MathJax support can either keep the math TeX code, use MathJax to render MathML, or generate HTML + CSS using MathJax node. See the mathjaxnode extension for make4ht. – michal.h21 Oct 10 at 16:48
1

The extended help information (pressing H) mentions Did you forget a preceding \begin{equation}? This leads to a workaround: use \begin{equation*} instead of \[ and similarly at the end.

MWE:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{split} a &= b \\ c &= d \end{split}
\end{equation*}

\end{document}

Result:

enter image description here

  • You're quite right. I would never have thought of this! I always thought that these were more or less synonyms, but I see that they have very different definitions in both standard latex and with tex4ht loaded. – Alex Watson Oct 9 at 16:07
  • @AlexWatson it does seem to be a bug/incompatibility of amsmath and tex4ht, in which amsmath expects the presence of an equation to be checkable by certain tests/booleans which are modified by tex4ht in such a way that the test fails. That can most likely be fixed in either package (with tex4ht being the more obvious candidate for fixing because that code introduces the problem). But if equation* is ok for you then it's probably not worth the trouble looking for a bug fix :) – Marijn Oct 9 at 16:13
  • 2
    amsmath redefines \[ to \begin{equation}, but this fails with tex4ht configurations for display math. I know about this issue for some time, but haven't found a correct solution for all cases yet. You know, we need to support MathML, MathJax, etc. Something that works for sample cases may be broken for more complex ones. – michal.h21 Oct 9 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.