[tex4ht] trying to understand how to use mathjax in tex4ht

Nasser M. Abbasi nma at 12000.org
Sat Sep 8 13:08:23 CEST 2018


I am trying mathjax in tex4ht. But I still do not understand
some basic things.

Given latex code, which compiles OK using pdflatex/lualatex
and also compiles OK using tex4ht when not using mathjax, why
would same code fail to compile when telling tex4ht to use mathjax
for math?

I posted one example about 3 weeks ago. But here is another
simpler example. I can come up with many more example, as this is only the
second file I am trying to compile with mathjax and I have hundreds of
thousands of latex files in my source tree.

I will show all the steps used and the error:

--------------
documentclass[11pt]{article}%
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx}%
\begin{document}

\begin{enumerate}

\item This is one item with equation
\begin{equation}
x=y\tag{1}
\end{equation}
\newline\newline Where in the above $k$ is the time step (also written as
\end{enumerate}
\end{document}
-----------------------

The above is valid latex. It compiles with no error using lualatex.tex
and it compiles with no error using

make4ht -u foo.tex "htm,1,charset=utf-8" " -cunihtf -utf8"

But the second I add mathjax to my .cfg, to tell tex4ht to use
mathjax for math, it gives an error

make4ht -u -c ./nma_mathjax.cfg foo.tex
                   "htm,1,charset=utf-8" " -cunihtf -utf8"

--------------------------------------
(/usr/local/texlive/2018/texmf-dist/tex/generic/tex4ht/html-mml.4ht)
(/usr/local/texlive/2018/texmf-dist/tex/generic/tex4ht/html5.4ht)) (./foo.aux))

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
  ...

l.12 \newline
              \newline Where in the above $k$ is the time step (also written as
?
---------------------------

The only difference, is that I added my cfg which tells it to use mathjax.
Here is the nma_mathjax.cfg

cat nma_mathjax.cfg
-------------------------------------
\Preamble{mathml}
\Configure{VERSION}{}
    \Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
    \Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
    \Configure{@HEAD}{}
    \Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
    \Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
    (http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
    \Configure{@HEAD}{\HCode{<link
             rel="stylesheet" type="text/css"
             href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}

\Configure{@HEAD}{\HCode{%
       <script type="text/x-mathjax-config">
         MathJax.Hub.Config({
           extensions: ["tex2jax.js"],
           jax: ["input/TeX", "output/HTML-CSS"],
           tex2jax: {
             \unexpanded{inlineMath: [ ['$','$'], ["\\(","\\)"] ],}
             \unexpanded{displayMath: [ ['$$','$$'], ["\\[","\\]"] ],}
             processEscapes: true
           },
           "HTML-CSS": { fonts: ["TeX"] }
         });
       </script>
}}

\Configure{@HEAD}{\HCode{<script type="text/javascript"
      src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
}}

\Configure{@HEAD}{\HCode{<style type="text/css">
      .MathJax_MathML {text-indent: 0;}
</style>}}

\begin{document}

\EndPreamble
------------------------

Am I using wrong options for matjax with tex4ht? What are the correct
command line options to use when one wants to use make4ht and
mathjax?

I wanted to try mathjax, but if I had to go change my latex code to
make it compile, then this is a no starter for me.

Using TL 2018 on ubuntu

thanks
--Nasser


More information about the tex4ht mailing list