[Tex/LaTex] \mathds from dsfont package works with latex and not with htlatex

fontshtlatexmath-mode

When using dsfont package with latex, rendering is fine :

\usepackage{dsfont}
$A\,\otimes\,\mathds{1}_{q}$

here the result :

latex result

Unfortunately, this doesn't work with htlatex :

htlatex result

I have also tried with :

$A\,\otimes\,\mathds{1}$$_{q}$

but problem remains.

I suspect the 2 possibilities with dsfont and doublestroke packages on my MacOS.X. Indeed, I get the 2 following paths while searching for dsfont.sty :

$ locate dsfont.sty

/opt/local/lib/perl5/vendor_perl/5.24/LaTeXML/Package/dsfont.sty.ltxml
/opt/local/share/texmf-texlive/tex/latex/doublestroke/dsfont.sty

Anyone has ever got this issue and is there a solution to get $\mathds{1}_{q}$ command with the same rendering as latex.

Regards

Best Answer

This issue is not caused by tex4ht, the math is rendered by MathJax. It seems that it doesn't support the \mathds command, so you need to provide some definition for MathJax. Moreover, it seems that it doesn't support blackboard numbers, so you need to find another solution, like providing direct Unicode value for doublestroke one. This can be done using custom macro for this symbol.

Try this TeX file:

\documentclass{article}
\usepackage{dsfont}
\newcommand\dsone{\mathds{1}}
\begin{document}

$A\,\otimes\,\dsone_{q}$
\end{document}

The dsone can be defined in this way:

\RequirePackage{mathjax-latex-4ht}
\Preamble{xhtml}
\begin{document}
\Configure{@HEAD}{\HCode{\unexpanded{<script type="text/x-mathjax-config"> MathJax.Hub.Config({ 
        TeX: {Macros : {  mathlarger: ["{\\large \#1}",1], dsone: "\\unicode{x1D7D9}" }},
        "HTML-CSS": { mtextFontInherit: true }
});</script>}}}
\EndPreamble

This is the rendering:

enter image description here

Related Question