This question is specific only to TeX4ht.

When using MathJax mode in tex4ht, it fails to render the section title which contains $\ln$, but it works for all other symbols I tried so far.

What is so special about $\ln$?



This is a document

\section{$\int \arcsin(x) \ln x  \,dx$}

\section{$\int \arcsin(x) \sqrt x \,dx$}

\section{$\int \arcsin(x) \sin x  \,dx$}


It must be compiled as follows to see the problem:

 make4ht -ulm default  foo.tex "htm,1,mathjax"

In the above, the split level is 1. Anything more than 0 is needed to show the problem.

Now the HTML looks like this:

Mathematica graphics

Not using mathjax mode with tex4ht also solves the problem.

Here is the raw HTML generated. Notice that \qopname \relax o{ln}x is generated by tex4ht before mathjax does anything.

<!DOCTYPE html>
<html lang="en-US" xml:lang="en-US" >
<meta  charset="utf-8" />
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" type="text/css" href="foo.css" />
<meta name="src" content="foo.tex" />
 <script type="text/x-mathjax-config"> MathJax.Hub.Config({ 'fast-preview': {disabled: true}, TeX: { extensions: ["color.js","AMSmath.js"], equationNumbers: { autoNumber: "AMS" } }, extensions: ["tex2jax.js"], tex2jax: {  inlineMath: [ ["\\\(","\\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true } }); </script>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<!--l. 6--><p class="noindent" >This is a document
<div class="tableofcontents">
<span class="sectionToc" >1 <a
href="#x1-10001" id="QQ2-1-1">\(\int \arcsin (x) \qopname \relax o{ln}x \,dx\)</a></span>
<br />   <span class="sectionToc" >2 <a
href="#x1-20002" id="QQ2-1-2">\(\int \arcsin (x) \sqrt x \,dx\)</a></span>
<br />   <span class="sectionToc" >3 <a
href="#x1-30003" id="QQ2-1-3">\(\int \arcsin (x) \sin x \,dx\)</a></span>
<h3 class="sectionHead"><span class="titlemark">1   </span> <a
 id="x1-10001"></a>\(\int \arcsin (x) \ln x \,dx\)</h3>
<!--l. 9--><p class="noindent" >test
</p><!--l. 11--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">2   </span> <a
 id="x1-20002"></a>\(\int \arcsin (x) \sqrt x \,dx\)</h3>
<!--l. 12--><p class="noindent" >test
</p><!--l. 14--><p class="noindent" >
<h3 class="sectionHead"><span class="titlemark">3   </span> <a
 id="x1-30003"></a>\(\int \arcsin (x) \sin x \,dx\)</h3>


Is this a bug in TeX4ht? I will also report this to texh4t bug tracking now and add a link to this post (it easier to explain this here as one can add screen shots).

I am using TeX Live 2019 on Linux.


amsmath defines math operators in a non-robust way, so they are partially expanded before written into an auxiliary file, e.g. while writing the table of contents. To fix this, tex4ht loads a file .../texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht which adjust these definitions. The most interesting part for us is:


(These are all the lines with \fixmathjaxtoc)

So you asked what is special about \ln? It is not in this list. What can you do about it? Add \fixmathjaxtoc\ln to your document. (It has to come after \begin{document} because the definition of \fixmathjaxtoc is loaded pretty late. Also you want to make sure that yourdocument still works without tex4ht, so check first that the command really exists):


This is a document

\section{$\int \arcsin(x) \ln x  \,dx$}

\section{$\int \arcsin(x) \sqrt x \,dx$}

\section{$\int \arcsin(x) \sin x  \,dx$}


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.