# tex4ebook (or htlatex) doesn't treat (mathematical) accents properly?

I tried some codes like

\documentclass{amsart}

\begin{document}
Let's see $\widehat{\mathcal F}=\hat F=\bar F=\tilde F=\overline F$.
\end{document}


with default compilation. Only \overline is rendered correctly. I look into the generated html code, it seems to me that these accents are taken into account (there is a code <span class='accentwidehat'>...</span>), but usual browsers don't take this into account. Any workaround for that? Thanks.

Since you are targeting eBooks with poor MathML and even CSS support, I guess the only universal fix is to use images for math. Try the pic-m option for converting all inline math to images:

tex4ebook filename.tex "pic-m"


The result:

There ale also some undocumented options that requires images for accented characters:

tex4ebook filename.tex "new-accents,accent-,mathaccent-"


Beware that it may request pictures even for accented characters in text, which may be undesirable.

Edit:

I've extracted code for picture accents from tex4ht sources. It should keep text accents normal. Try the following config file:

\Preamble{xhtml,new-accents}
\Configure{HAccent}\vec{}{\Picture+{}}{\EndPicture}
\Configure{HAccent}\widehat{}{\Picture+{}}{\EndPicture}
\Configure{HAccent}\bar{}{\Picture+{}}{\EndPicture}
\Configure{HAccent}\hat{AEIOUaeiou{}}{\Picture+{}}{\EndPicture}
\Configure{HAccent}\tilde{AOaoNn{}}{\Picture+{}}{\EndPicture}
\Configure{HAccent}\widetilde{}{\Picture+{}}{\EndPicture}
\begin{document}
\EndPreamble


edit2:

There seems to be clash between new-accents and babel. In this case, we can try to redefine the accent commands to use pictures directly:

\RequirePackage{etoolbox}
\Preamble{xhtml}
\def\patchaccent#1{%
\csletcs{orig#1}{#1}
\expandafter\def\csname #1\endcsname##1{\Picture+{}\csname orig#1\endcsname{##1}\EndPicture}
}
\patchaccent{widehat}
\patchaccent{hat}
\patchaccent{bar}
\patchaccent{tilde}
\patchaccent{overline}
\begin{document}
\EndPreamble

• I wonder whether we have a finer control of what should be converted to images. pic-m is usually not satisfactory. By the way, by "browsers", I mean not only ebook viewers but also web browsers. I load the generated html file by Firefox and Chromium, and neither of these browsers recognizes accentwidehat (I mean, technically, the generated code of accentwidehat is not recognized by web browsers, rather than not generating codes). – Yai0Phah Apr 1 at 10:06
• @FrankScience I meant that MathML is not supported by browsers. I don't think math accents are really possible to emulate using pure CSS and HTML. especially when the accent is over multiple letters. – michal.h21 Apr 1 at 13:22
• OK, so I wonder whether there are tricks to specify several commands to be converted into images. I noticed that even if I don't enable pic-m, some parts of inline math formulae are converted into images. – Yai0Phah Apr 1 at 13:41
• @FrankScience I've updated my answer with some new options – michal.h21 Apr 1 at 14:09
• Thanks. I wonder whether I can hack several 4ht files in texmf-dist/tex/generic/tex4ht, like html0.4ht, html32.4ht, html4.4ht to override the default settings. I found that the code about \widehat appears at \:CheckOption{new-accents}. – Yai0Phah Apr 1 at 15:50