[tex4ht] Macro parameter bug
Michal Hoftich
michal.h21 at gmail.com
Wed Mar 10 22:46:18 CET 2021
Dear Francis,
On Wed, Mar 10, 2021 at 05:46:41PM +0000, Francis Wright wrote:
>I'm using TeX4ht to generate HTML including mathematics to be processed
>by MathJax from LaTeX source files. MathJax supports macro and
>environment definitions provided they are within a math environment,
>and this works fine via TeX4ht provided the definition has no
>parameters. But if I use parameters, the # characters get doubled. I
>currently post-process my HTML files to convert ## back to #, which
>works, but it would be nice if TeX4ht didn't double them in the first
>place. Is there a better way to handle this? I can't find any way to
>escape or encode the # characters to avoid this.
Interesting issue, thanks for the report. I think easiest solution is to
change catcode of # to letter before the MathJax configuration, like in
the following configuration file:
%%%%%%%%%%%%%%%%%%
\Preamble{xhtml}
\catcode`\#=11
\Configure{MathJaxConfig}{{
tex: {
tags: "ams",
\detokenize{%
macros: {
hello: ["\\sqrt{#1}",1],
sl: "\\it",
}
}
}
}}
% don't forget to return catcode back to the original value
\catcode`\#=6
\begin{document}
\EndPreamble
%%%%%%%%%%%%%%%%%%
It is converted as:
<script>window.MathJax = { tex: { tags: "ams", macros: {
hello: ["\\sqrt{#1}",1],
sl: "\\it",
} } }</script>
in the HTML file, which works correctly.
Best regards,
Michal
More information about the tex4ht
mailing list.