[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


%\newcommand{\tauL}{\tau L} %Another option to use

\newcommand{\tauL}{\ensuremath{\tau L}\xspace}

    {\rm d}\tauL \sin(x) %bad code generated by Maple.

Here is how the HTML looks in mathjax vs. svg


As a workaround, I used the method given by Michal and add this

%thanks to Michal Hoftich. Added Nov 18, 2018 to handle Maple Latex export problem
<script type="text/x-mathjax-config">
     TeX: {
       Macros: {
         sc : "\\small\\rm",
         sl: "\\it",
	LommelS: ["\\operatorname{LommelS\#1}",1],
	tauL: "\\tau L"    <----- add this, now error is gone

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?


More information about the tex4ht mailing list