# Referencing an equation from a different chapter of the same document with tex4ht

I am trying to convert to HTML a big LaTeX document (book class) subdivided into several chapters. I am using tex4ht. My problem is that, if I choose to export each chapter as separate pages, when I reference an equation from a different chapter, I get ??? instead of the equation number. The following snippet illustrates this issue.

\documentclass{book}

\begin{document}

\chapter{First}
$$1+1=2 \label{eq1}$$

\chapter{Second}
Reference to first chapter's equation: $\ref{eq1}$.
$$2+2=4 \label{eq2}$$

\end{document}

If I convert this file (snippet.tex) to HTML using make4ht --utf8 snippet.tex "mathlm,mathjax", then it works fine. I get the following:

However, if I use make4ht --utf8 snippet.tex "mathlm,mathjax,2" instead, the page corresponding to chapter 2 looks like that:

Notice also that, in this second case, the equation number is now 1, which means that there are two equations 1 within the same document. I have tried to add the chapter number in the equation number, by adding \renewcommand{\theequation}{\thechapter.\arabic{equation}} in the preamble of my TeX file, but it has no effect.

• I think you use a wrong option: it should be mathml instead of mathlm. You use pure MathJax now, which means that references to equations don't work correctly. Sep 23 at 20:41
• Indeed, that was a stupid mistake. Thank you very much for your help. Sep 24 at 19:47