I have been successfully using the configuration described in the excellent answer to keeping equations as latex, so as to use MathJax. Now I wish to also use the exsheets package (for creating questions with solutions), which is compatible with tex4ht except that displayed equations don't work inside a question environment (provided one wishes to keep equations as latex, as I do).
Specifically, the tex file
\documentclass{article}
\usepackage[]{amsmath}
\usepackage{exsheets}
\usepackage[T1]{fontenc}
\begin{document}
This first question compiles fine:
\begin{question}
Here's an inline equation: \( a=0 \).
\end{question}
This next question produces desired output, but gives error ``Missing \} inserted'':
\begin{question}
Here's a displayed equation (using brackets)
\[ x=1 \]
\end{question}
This last question gives errors ''Argument of verbatim has an extra \}'' and ''Paragraph ended before verbatim was complete'':
\begin{question}
Here's a displayed equation (using equation*)
\begin{equation}
y=2
\end{equation}
\end{question}
\end{document}
with configuration file
\usepackage{verbatim}
\Preamble{html}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
%\Configure{@HEAD}{\HCode{<link href="basic.css" rel="stylesheet" type="text/css" />\Hnewline}}
\Configure{@HEAD}{\HCode{
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
extensions: ["color.js"],
equationNumbers: { autoNumber: "AMS" }
},
extensions: ["tex2jax.js"],
tex2jax: {
\unexpanded{
inlineMath: [ ['\$','\$'], ["\\\(","\\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],}
processEscapes: true,
processEnvironments: true
}
});
</script>\Hnewline
}}
\Configure{@HEAD}{\HCode{ <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> \Hnewline}}
\newtoks\eqtoks
\def\AltMathOne#1${\eqtoks{$#1$}%
\HCode{\the\eqtoks}$}
\Configure{$}{}{}{\expandafter\AltMathOne}
\def\AltlMath#1\){\eqtoks{\(#1\)}%
\HCode{\the\eqtoks}}
\Configure{()}{\AltlMath}{}
\def\AltlDisplay#1\]{\eqtoks{\[#1\]}%
\HCode{\the\eqtoks}}
\Configure{[]}{\AltlDisplay}{}
\begin{document}
\newcommand\VerbMath[1]{%
\renewenvironment{#1}{%
\NoFonts%
\string\begin\{#1\}%
\verbatim}{\endverbatim\string\end\{#1\}\EndNoFonts}%
}
\VerbMath{align}
\VerbMath{equation}
\VerbMath{equation*}
\EndPreamble
produces the output
Inside of the question environment, inline equations compile just fine, while displayed equations with brackets output ok but compile with an error, and displayed equations using equation
do not produce the desired output.
Update: I realize now this issue is caused by the fact that verbatim material is not allowed inside exsheets environments; see this question. So I'm wondering if a command similar to VerbMath can be defined without using the verbatim package, i.e. a command that will keep the entirety of \begin{equation} EQUATION HERE \end{equation} unchanged in the html output, so as to be processed by MathJax.