2

This is tex4ht issue only. This MWE

\documentclass[12pt,notitlepage]{book}   
\usepackage{amsmath} 
\begin{document}
\chapter{Listing of integrals}
\section{Integrals 1 to 100}
\subsection{$\exp \sin(x)$}
test

\end{document}

When compiled using the command

 make4ht -ulm default -a debug report.tex "mathjax,htm,fn-in,4,notoc*"

gives this HTML

enter image description here

Where did \qopname\relax stuff come from? Here is the raw HTML

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link rel='stylesheet' type='text/css' href='report.css' /> 
<meta content='report.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", }, }; </script> 
 <script async='async' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript' id='MathJax-script'></script>  
</head><body>

<!-- l. 4 --><p class='indent'>

</p>   
<div class='tableofcontents'>
<span class='chapterToc'>1 <a href='rech1.htm#x2-10001' id='QQ2-2-1'>Listing of integrals</a></span>
<br />    <span class='sectionToc'>1.1 <a href='rese1.htm#x3-20001.1' id='QQ2-3-2'>Integrals 1 to 100</a></span>
<br />     <span class='subsectionToc'>1.1.1 <a href='resu1.htm#x4-30001.1.1' id='QQ2-4-3'>\(\qopname \relax o{exp}\sin (x)\)</a></span>
</div> 
</body> 
</html>

This only happens when using \exp command I found, and when using mathjax. When compiling using

 make4ht -ulm default -a debug report.tex "htm,fn-in,4,notoc*"

The output is correct

enter image description here

I reported this also to tex4ht bug tracking and added link back to this post (easier to post images here).

TL 2021 on Linux

>which make4ht
/usr/local/texlive/2021/bin/x86_64-linux/make4ht
4
  • Got it. I will delete earlier comment. Sep 14, 2021 at 17:43
  • The function exp sin(x) is not really a function that usually shows up in math.
    – Gaussler
    Sep 14, 2021 at 19:25
  • @Gaussler it is made up example to show the problem with using $\exp$. But how is this really relevant to the issue? The point is in using $\exp$. But feel free to change the example to $\exp x$ and the problem still shows up.
    – Nasser
    Sep 14, 2021 at 20:12
  • It’s not extremely relevant. But going slightly off-topic in the comments is usually being tolerated on this site.
    – Gaussler
    Sep 14, 2021 at 20:16

1 Answer 1

3

As described in the documentation, you can use the \fixmathjaxtoc command to fix commands that should be preserved in TOC. \sin already is preserved, so you need to use it just for \exp:

\Preamble{xhtml}
\fixmathjaxtoc\exp
\begin{document}
\EndPreamble

enter image description here

2
  • Thanks Michal. I did not know about this. But it means this is trial and error. How is one supposed to know which latex math command can or can not go into section title? Why are not all Latex math commands automatically supported, as with pdf? There must be good reason why.
    – Nasser
    Sep 14, 2021 at 18:01
  • 2
    @Nasser this is because all commands must be explicitly supported by \mathjaxtoc, so I added the most common ones and then others by requests. It is bit unfortunate, but I don't know a better solution. It is best to remember that any math command in section title when you use MathJax can cause issues.
    – michal.h21
    Sep 14, 2021 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .