[tex4ht] why \newcommand has no effect when compiling to HTML using mathjax mode, why?
Nasser M. Abbasi
nma at 12000.org
Wed Nov 21 01:44:35 CET 2018
Maple generates wrong Latex code. It generates \tauL when it should
be \tau L.
As a workaround until Maplesoft fixes its latex code (which will never
happen), I defined a command to change \tauL to \tau L and
added it to the preample.
This solution works OK in pdf and also when compiling to HTML in SVG.
But when compiling using mathjax mode, the \newcommand is not having
any effect, as the generated HTML still shows \tauL.
Here is a MWE
===================================
\documentclass[11pt]{article}
\usepackage{amsmath,mathtools,amssymb}
%\newcommand{\tauL}{\tau L} %Another option to use
\usepackage{xspace}
\newcommand{\tauL}{\ensuremath{\tau L}\xspace}
\begin{document}
\[
{\rm d}\tauL \sin(x) %bad code generated by Maple.
\]
\end{document}
====================================
Here is how the HTML looks in mathjax vs. svg
https://www.12000.org/tmp/11202018/screen_shot.png
As a workaround, I used the method given by Michal and add this
configuration
%thanks to Michal Hoftich. Added Nov 18, 2018 to handle Maple Latex export problem
\Configure{@HEAD}{\HCode{
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
\unexpanded{
sc : "\\small\\rm",
sl: "\\it",
LommelS: ["\\operatorname{LommelS\#1}",1],
tauL: "\\tau L" <----- add this, now error is gone
}
},
}
});
</script>
}}
And now it works in mathjax.
But my question is: Why \newcommand inside Latex had no effect
when compiling to mathjax but it work in SVG?
Thanks
--Nasser
More information about the tex4ht
mailing list