# how to fix inline math alignment in svg mode when using tex4ht?

fyi, reported also to tex4ht bug tracking https://puszcza.gnu.org.ua/bugs/index.php?424

This is a problem I knew about for years now, and never got the chance to ask about it except now.

When using svg for math with tex4ht, the inline math in some places does not come out as well aligned with the text around it.

It is either a little below the baseline or sometime above.

This only affects in-line math. This problem does not show up when using mathjax.

I have now tried every combination I can think of, and can't find a fix. I will show the MWE I used, and show every attempt I tried.

\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}

%This below is needed for tex4ht, without, inline math does not
%even render well at all
\ifx\HCode\undefined \else
\Configure{$}{\PicMath}{\EndPicMath}{} \fi But$\ln x=\frac{s}{\pi}\ln b$, hence$x=e^{s\frac{\ln b}{\pi}}, and the above becomes \begin{align*} \ln x&=\frac{s}{\pi}\ln b \end{align*} \end{document}  ## Trial 1 Command (all on one line) make4ht -ulm default -f html5+dvisvgm_hashes foo.tex "htm,pic-align,notoc*,p-width,charset=utf-8,svg" "-cmozhtf -utf8"  ## Trial 2 This is the same as above, but without using \ifx code, just to show you what happens \documentclass[11pt]{article} \usepackage{amsmath} \begin{document} But\ln x=\frac{s}{\pi}\ln b$, hence$x=e^{s\frac{\ln b}{\pi}}, and the above becomes \begin{align*} \ln x&=\frac{s}{\pi}\ln b \end{align*} \end{document}  Command (all on one line) make4ht -ulm default -f html5+dvisvgm_hashes foo.tex "htm,pic-align,notoc*,p-width,charset=utf-8,svg" "-cmozhtf -utf8"  You see that without using the \Configure{}{\PicMath}{\EndPicMath}{} the inline math is all broken. Part of it is image and part is not. So in all the examples below, will use the first MWE shown above which include \Configure{}{\PicMath}{\EndPicMath}{} ## Trial 3 In this try, removed the trailing "-cmozhtf -utf8" to see if this will help. It had no effect Command (all on one line) make4ht -ulm default -f html5+dvisvgm_hashes foo.tex "htm,pic-align,notoc*,p-width,charset=utf-8,svg"  ## Trial 4 In this try, put back the trailing "-cmozhtf -utf8" but removed the option pic-align to see if will help. Now it got even worst, the math inside the display is broken. Command (all on one line) make4ht -ulm default -f html5+dvisvgm_hashes foo.tex "htm,notoc*,p-width,charset=utf-8,svg" "-cmozhtf -utf8"  ## Trial 5 In this one, I used the most simple command to see what happens, on this MWE \documentclass[11pt]{article} \usepackage{amsmath} \begin{document} But\ln x=\frac{s}{\pi}\ln b$, hence$x=e^{s\frac{\ln b}{\pi}}, and the above becomes \begin{align*} \ln x&=\frac{s}{\pi}\ln b \end{align*} \end{document}  Using  make4ht -ul -f html5+dvisvgm_hashes foo.tex "htm,svg"  Still not working ## Trial 6 In this trial, went back to top MWE with \Configure{}{\PicMath}{\EndPicMath}{} in it, and put back the pic-align there, since it is clear this option is needed, but removed the p-width option to see what happens. It had no effect

make4ht -ulm default -f html5+dvisvgm_hashes foo.tex
"htm,pic-align,notoc*,charset=utf-8,svg" "-cmozhtf -utf8"


## Trial 7

In this one, removed the -f html5+dvisvgm_hashes option. It had no effect on alignment

make4ht -ulm default foo.tex
"htm,pic-align,notoc*,charset=utf-8,svg" "-cmozhtf -utf8"


I can keep tring different options like this. I used Chrome to view all these outputs. Btw, I think this problem shows up when using images for math period. Not just specific for SVG. For example, doing this make4ht foo.tex (which uses png for math) shows the same problem with alignment for inline math.

Could some tex4ht expert please suggest a fix for this problem? The output file must have .htm extension in any solution since that is what I use. Not .xhtml or such.

I am using TL 2019 on Linux.