[tex4ht] big problem with table of content when section titles contain math using mathjax

Nasser M. Abbasi nma at 12000.org
Mon Oct 29 22:36:48 CET 2018

Hello, I found a really big problem using mathjax with tex4ht.

When a section or subsection title contain math, the table of content
that shows in HTML is all corrupted. This is only when using mathjax
mode.  Add \cprotect{} around the section of subsection title that
contains math had no effect.

These files were compiled fine as is for years with no problem before
when using svg for math.

I made a MWE to show the problem.

\title{MWE showing the pronblem}


\section{Listing of integrals}
\subsection{\quad $\int e^x \left(1-x^3+x^4-x^5+x^6\right) \, dx$}
\subsection{\quad $\int \frac{e^{\frac{x}{2+x^2}} \left(2-x^2\right)}{2 x+x^3} \, dx$}

Here is a screen shot showing the result


The HTML for toc is
<div class="tableofcontents">
<span class="sectionToc" >1 <a
href="#x1-20001" id="QQ2-1-2">Listing of integrals</a></span>
<br />    <span class="subsectionToc" >1.1 <a
href="#x1-30001.1" id="QQ2-1-3">
\(\DOTSI \intop \ilimits@ e^x \left (1-x^3+x^4-x^5+x^6\right ) \tmspace +\thinmuskip{.1667em} dx\)</a></span>
<br />    <span class="subsectionToc" >1.2 <a
href="#x1-40001.2" id="QQ2-1-4">
\(\DOTSI \intop \ilimits@ \frac{e^{\frac{x}{2+x^2}} \left (2-x^2\right )}{2 x+x^3} \tmspace +\thinmuskip{.1667em} dx\)</a></span>

Compiled the above using same command I used in earlier examples,
which is

make4ht -ulm default  -c ./nma_mathjax.cfg report.tex
      "htm,0,notoc*,p-width,charset=utf-8" " -cunihtf -utf8"

Where nma_mathjax.cfg is


And mathjax-latex-4ht.sty is from


If I compile the same file using svg for math or just using default
setting for make4ht , then the TOC is correct.

      make4ht -ulm default  report.tex

No issue. Again, this from large files that always used to compile
OK and TOC with math in it had no issue showing in HTML before.

Does one need to modify something in the mathjax-latex-4ht.sty to
make the TOC show OK? Do I need to modify something in my Latex to
make it work with mathjax?

TL 2018.

Thank you

More information about the tex4ht mailing list