# tex4ht (or tex4ebook) is not compatible with ^\mathbb, _\mathfrak, etc

To export many mathematical articles and surveys to Kindle from the LaTeX source code, I am trying to use tex4ebook. It seems to me that I still need to hack many LaTeX codes to finish the compilation, especially I found a case, which is pretty common in LaTeX codes but not compatible with tex4ht (I think): calligraphic letters in subscripts like _\mathfrak m or ^\mathcal T in math mode. A sample code is:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
Given a topological space $X$ with a circle $\mathbb T$-action, let's look at the space of fixed points $X^\mathbb T$.
\end{document}


When running tex4ebook, it indicates an error at ^\mathbb during compilation, while no error is shown during the ordinary LaTeX compilation. I want to ask the reason for that, and suggestions for better practice. Thanks!

• Syntax like _\mathbb A or ^\mathbb{B}, only works by accident. So advising users to use _{\mathbb{A}} is the right call. – daleif Nov 9 '18 at 12:58
• I'm always amazed that x_\mathbb{A} crops up (but it does crop up all the time), how do people even notice that "works" and start using it. No normal tex command parses its arguments in that way, try \frac\mathbb{A}\mathbb{B} It is a peculiarity of the primitive ^ and _ parsing (which is why it doesn't work in tex4ht which needs to define _ and ^ as macros to add additional processing) – David Carlisle Nov 9 '18 at 13:29
• @DavidCarlisle I cannot tell about others, but I believe that we usually start to learn LaTeX, as a tool, by practice, or a mixture of practice and manuals, without thoroughly understanding the syntax. The other point seems to be a relatively loose syntactical (or convenient) structure of TeX, in comparison to, say, the Lisp language (inconvenient). – Yai0Phah Nov 9 '18 at 14:00

You definitely should use X^{\mathbb{T}}\$, the syntax you use, while it works with LaTeX, cannot be supported by tex4ht configurations. The only way to support it to convert math to pictures. Which doesn't look nice, but it preserves the original appearance of math. It may work on Kindle (but not really well).

The pictures for inline math can be requested using pic-m option for tex4ht. It can be used in tex4ebook in the following way:

tex4ebook -f mobi filename.tex "pic-m"


With this option, I don't get error with your sample. The output looks like this in the browser:

Compare it with normal math:

You need to test it on actual Kindle, because I am not sure about it's support for math characters in text, or how the math pictures will look with the default Kindle font.

• Thank you for your answer and an additional remark about pic-m. Kindle doesn't work well for math pictures, as they are shown significantly smaller than the text. It seems to me that I can only use kindle to read articles non-seriously. The only good solution should be MathML, claimed to be supported in the future. – Yai0Phah Nov 9 '18 at 17:53
• @FrankScience if Kindles get MathML support, it would fix all issues. Meanwhile, you can change the resolution of the math pictures in the .mk4 build file, see the image conversion section. You can also try the SVG pictures using svg option along with pic-m. – michal.h21 Nov 9 '18 at 20:51
• Thanks. For svg option, are you referring to one of your answer? I don't know whether changing the resolution will work. The DPI of my kindle is 167ppi (the cheapest one), which seems to be the default setting in tex4ebook? – Yai0Phah Nov 10 '18 at 13:17
• @FrankScience dvisvgm can scale images, so the siza can match the text and the quality should be better than with png images. – michal.h21 Nov 10 '18 at 20:06