This page has examples from
LearnLaTeX.org which failed to produce
resaonable output with the the default make4ht
configuration
2,mathjax
.
Configuration files have been added to address these issues. Not successful in all cases, and quite possibly not using the best make4ht/tex4ht configuration technique. Improvements welcome!
% !TeX make4ht \documentclass{article} \usepackage[T1]{fontenc} \newcommand{\diff}{\mathop{}\!d} % For italic % \newcommand{\diff}{\mathop{}\!\mathrm{d}} % For upright \begin{document} A paragraph about a larger equation \[ \int_{-\infty}^{+\infty} e^{-x^2} \diff x \] \end{document}
This now works with the current learnlatex4ht,2,mathml,mathjax,svg
configuration which expands all TeX macros during the conversion.
It also worked with learnlatex4ht,2,mathjax,svg
with a
configuration that inserted the current definition
of \diff
at begin document inside math so MathJax
saw it.
% !TeX make4ht \documentclass[a4paper]{article} \usepackage[T1]{fontenc} \usepackage{bm} \begin{document} $(x+\mathbf{y})(x-\mathbf{y})=x^{2}-{\mathbf{y}}^{2}$ $(x+\bm{y})(x-\bm{y}) \bm{=} x^{2}-{\bm{y}}^{2}$ $\alpha + \bm{\alpha} < \beta + \bm{\beta}$ \end{document}
A bm.4ht
file added that defines \bm
to
be \boldsymbol
, this is the recommended definition for
MathJax, although a more generic bm.4ht
that did not
mask the system supplied one would be better.
% !TeX make4ht \documentclass[a4paper]{article} \usepackage[T1]{fontenc} \usepackage{mathtools} \begin{document} \[ \begin{pmatrix*}[r] 10&11\\ 1&2\\ -5&-6 \end{pmatrix*} \] \end{document}
The mathtools
package is not supported by MathJax by default. The
AMS had
a MathJax2
extension
There is discussion of updating that to MathJax3 (there is a
mathjax3 branch at that GitHub) see also
at Stackexchange
% !TeX make4ht % !TEX lualatex \documentclass[a4paper]{article} \usepackage{unicode-math} \setmainfont{TeX Gyre Pagella} \setmathfont{TeX Gyre Pagella Math} \begin{document} One two three \[ \log \alpha + \log \beta = \log(\alpha\beta) \] Unicode Math Alphanumerics \[A + \symfrak{A}+\symbf{A}+ \symcal{A} + \symscr{A}+ \symbb{A}\] \end{document}
a local unicode-math-hooks.4ht suppresses font loading (to match the fontspec configurig and aliases \sym... to \math...
% !TeX make4ht % !TEX xelatex \documentclass{article} \usepackage{fontspec} \setmainfont{texgyretermes-regular.otf} \newfontfamily\cjkfont{FandolSong-Regular.otf} \begin{document} ABC → αβγ → {\cjkfont 你好} \end{document}
This example now works after adding \xeuniuseblock
declarations
to learnlatex4ht.cfg
as suggested by Michal.
% !TeX make4ht %!TEX lualatex \documentclass{article} \begin{document} $ 2\pi \approx \directlua{ tex.print(2 * math.pi) } $ \directlua{tex.print('$ 4\string\\pi \string\\approx' .. 4 * math.pi .. '$')} \end{document}
This fails if the tex syntax mathjax configuration is used, but passes now with `mathml,mathjax` as the math is expanded by TeX.
% !TeX make4ht \documentclass{article} \usepackage[T1]{fontenc} \usepackage{mhchem} \begin{document} \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} \end{document}
For the current mathml,mathjax
configuration
mhchem.4ht
wraps itself in \(\)
so seen my MathJax TeX input parser.
For tex-mathjax configuration mhchem.4ht
redefined\ce
to wrap itself in \ensuremath
so it is seen by MathJax
which has existing mhchem
support.
% !TeX make4ht \documentclass{article} \usepackage[T1]{fontenc} \usepackage[linguistics]{forest} \begin{document} \begin{forest} [VP [DP\\John ] [V’ [V\\sent ] [DP\\Mary ] [DP[D\\a][NP\\letter]] ] ] \end{forest} \end{document}
This now works using the svg option and Michal's svg driver
% !TeX make4ht \documentclass{article} \usepackage[T1]{fontenc} \usepackage{xskak} \begin{document} \newchessgame \mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6} \xskakset{moveid=2w}% \chessboard[setfen=\xskakget{nextfen}]\\[1ex] Position after 2.\,\xskakget{lan} \chessboard[pgfstyle=cross, color=blue, setfen=\xskakget{nextfen}, getpiecelists, markfields={\cblistP,\cblistp}] \end{document}
A xskak.4ht
is provided that almost gets this right,
generating images for the xskak commands The board has
an alt
text that is the fen description of the board
position (Ulrike tells me that chess people know what this means).
% !TeX make4ht \documentclass{article} \usepackage[T1]{fontenc} \usepackage{pgfplots} \pgfplotsset{width=7cm,compat=1.17} \begin{document} \begin{tikzpicture} \begin{axis}[] % density of Normal distribution: \addplot [ red, domain=-3e-3:3e-3, samples=201, ] {exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))}; \end{axis} \end{tikzpicture} \end{document}
This now works using the svg option and Michal's svg driver
% !TeX make4ht \documentclass{article} \usepackage[T1]{fontenc} \usepackage{musixtex} \begin{document} \begin{music} \parindent10mm \instrumentnumber{1} % a single instrument \setname1{Piano} % whose name is Piano \setstaffs1{2} % with two staffs \generalmeter{\meterfrac44} % 4/4 meter chosen \startextract % starting real score \Notes\ibu0f0\qb0{cge}\tbu0\qb0g|\hl j\en \Notes\ibu0f0\qb0{cge}\tbu0\qb0g|\ql l\sk\ql n\en \bar \Notes\ibu0f0\qb0{dgf}|\qlp i\en \notes\tbu0\qb0g|\ibbl1j3\qb1j\tbl1\qb1k\en \Notes\ibu0f0\qb0{cge}\tbu0\qb0g|\hl j\en \zendextract % terminate excerpt \end{music} \end{document}
A Configuration musixtex.4ht
is provided so that music
environments
generate an image.