# More TeX4ht issues with chrome and safari

Take the following simple latex file

\documentclass{article}
\usepackage{amsfonts,amsmath}
\newcommand\R{\mathbb{R}}

\begin{document}

$\overrightarrow{AB}$

$|\mathbf{v}|$

$e^{x^2+y^2}$

$\{ x\in\R | x<0 \}$

\begin{align*}
f & = 1+2+3+4+\dots+n\\
& = \binom{n+1}2
\end{align*}

\end{document}


and run it through tex4ht/make4ht using the configuration file from TeX4ht issue with chrome

\Preamble{xhtml,mathml,html5}
\Configure{HTML}{\HCode{<html lang="en">\Hnewline}}{\HCode{\Hnewline</html>}}

src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_CHTML">
</script>\Hnewline}}
\begin{document}

\EndPreamble


(for example, use make4ht -u -c file.cfg file.tex). On firefox, safari and chrome this produces a web page with errors that look something like

The problem is with the mathjax settings. If, instead, I change the configuration file to use

\Configure{@HEAD}{\HCode{\Hnewline<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_CHTML">
</script>\Hnewline}}


then this page displays correctly on firefox but superscripts and subscripts, for example, do not display correctly on chrome and everything is pear-shaped on safari:

This shows how this web page produced by tex4ht displays on firefox, chrome and safari, respectively.

I have tried all of the mathjax settings given on http://docs.mathjax.org/en/latest/config-files.html, as well as trying to configure mathjax directly using MathJax.Hub.Config, but I cannot find a way to get these examples to work. Firefox displays this page well with several of the mathjax configurations, chrome does OK with some and safari is not happy at all.

I have also tried using Michal's mathjax-latex-4ht package, described in Converting latex to html using exsheets, and keeping equations as latex. This is almost perfect except that it doesn't cope with the \R macro in my MWE:

Is there a way to configure tex4ht and mathjax to play well with this example on all browsers? Annoyingly, pandoc seems to produce sensible output here but in my real application I have some significant post-processing to do, which is possible using tex4ht and I am not sure if this can be done starting with pandoc.

• Why the down vote? ... – Andrew Jun 26 '17 at 10:03

This is caused by bug in configuration for \mathbf command:

\Configure{mathbf}%
{\bgroup \Tg<\a:mathml mi mathvariant="bold">\PauseMathClass}%
{\Tg</\a:mathml mi>\egroup }%


tex4ht automatically add markup around math variables and operators, but this is disabled by \PauseMathClass command in this configuration, because the markup is added explicitly in this case. The automatic markup must be turned on after end of \mathbf, otherwise it will result in invalid markup. Because your second math example contains \mathbf, all following examples contain invalid markup. We need to use \EndPauseMathClass command to turn markup on again.

I will fix this issue in tex4ht sources, but it will take some time before the fix goes to TeXLive, so you can use the following configuration in the meantime.

\Preamble{xhtml,mathml,html5}
\Configure{HTML}{\HCode{<html lang="en">\Hnewline}}{\HCode{\Hnewline</html>}}