I found a problem using tex4ht with SVG for math.
I needed to make a table and put math in it. I found that the same math inside the table looks bad compared to the math outside the table. After some debugging, it turned out that tex4ht needs the following configuration to fix the math inside the table
\ifdefined\HCode
\Configure{$}{\PicMath}{\EndPicMath}{}
\Configure{PicMath}{}{}{}{class="math";align="absmiddle"}
\fi
I have no idea why that is. Here is a MWE showing the difference in math inside the table vs. outside when the above tex4ht configuration is missing:
\documentclass[11pt]{article}
\usepackage{amsmath,mathtools,amssymb}
\begin{document}
%\ifdefined\HCode
%\Configure{$}{\PicMath}{\EndPicMath}{}
%\Configure{PicMath}{}{}{}{class="math";align="absmiddle"}
%\fi
\begin{align*}
\left( x+y \left( x \right) \right) {\frac {d}{{d}x}}y \left( x \right) &=x-y \left( x \right)\\
{t}^{2}+4\,ty \left( t \right) + \left( 2\,{t}^{2}+2\,y \left( t \right) \right) {\frac {d}{{d}t}}y \left( t \right) &=0\\
t-2\,{{e}^{ty \left( t \right) }}\sin \left( 2\,t \right) +{{e}^{ty \left( t \right) }}\cos \left( 2\,t \right) y \left( t \right) + \left( -3+{{ e}^{ty \left( t \right) }}t\cos \left( 2\,t \right) \right) {\frac {d}{{\rm d}t}}y \left( t \right) &=0
\end{align*}
\begin{center}
\begin{tabular}{|c|c|}\hline
1&$ \left( x+y \left( x \right) \right) {\frac {\rm d}{{\rm d}x}}y \left( x \right) =x-y \left( x \right) $\\\hline
2&$3\,{t}^{2}+4\,ty \left( t \right) + \left( 2\,{t}^{2}+2\,y \left( t \right) \right) {\frac {\rm d}{{\rm d}t}}y \left( t \right) =0$\\\hline
3&$2\,t-2\,{{\rm e}^{ty \left( t \right) }}\sin \left( 2\,t \right) +{{\rm e}^{ty \left( t \right) }}\cos \left( 2\,t \right) y \left( t \right) + \left( -3+{{\rm e}^{ty \left( t \right) }}t\cos \left( 2\,t \right) \right) {\frac {\rm d}{{\rm d}t}}y \left( t \right) =0$\\\hline
\end{tabular}
\end{center}
\end{document}
Then compiled with
rm -f *.svg
make4ht -ul -f html5+dvisvgm_hashes foo.tex "htm,pic-align,p-width,svg"
make4ht -ul -f html5+dvisvgm_hashes foo.tex "htm,pic-align,p-width,svg"
Clearly the math inside the table cells is not correct. Lots of misalignments over the baseline and the spacing between some of the letters is cramped in a number of places. Below is the result of the same code above, but when removing the comments on the \ifdefined
code, so it is now active:
Now the math is correct inside the table. It looks just like the math outside.
Well, you might ask, then why not then keep the \ifdefined
code in there and the problem is solved, right?
But here comes the actual problem.
Keeping the \ifdefined
code in there to fix the math, causes a big problem somewhere else.
Now tex4ht will no longer accept fixed width column for tables p-width
. And I need to have fixed width columns since the actual table will get too wide (it has other columns, not shown here). Making it hard to see the table on the web page without having to scroll all the time.
So now when I want to make a table, and for example have the cells be say 2 inch wide, it will not work.
\documentclass[11pt]{article}
\usepackage{amsmath,mathtools,amssymb}
\begin{document}
\ifdefined\HCode
\Configure{$}{\PicMath}{\EndPicMath}{}
\Configure{PicMath}{}{}{}{class="math";align="absmiddle"}
\fi
\begin{center}
\begin{tabular}{|p{1in}|p{2in}|}\hline
1&$ \left( x+y \left( x \right) \right) {\frac {\rm d}{{\rm d}x}}y \left( x \right) =x-y \left( x \right) $\\\hline
2&$3\,{t}^{2}+4\,ty \left( t \right) + \left( 2\,{t}^{2}+2\,y \left( t \right) \right) {\frac {\rm d}{{\rm d}t}}y \left( t \right) =0$\\\hline
3&$2\,t-2\,{{\rm e}^{ty \left( t \right) }}\sin \left( 2\,t \right) +{{\rm e}^{ty \left( t \right) }}\cos \left( 2\,t \right) y \left( t \right) + \left( -3+{{\rm e}^{ty \left( t \right) }}t\cos \left( 2\,t \right) \right) {\frac {\rm d}{{\rm d}t}}y \left( t \right) =0$\\\hline
\end{tabular}
\end{center}
\end{document}
Now
rm -f *.svg
make4ht -ul -f html5+dvisvgm_hashes foo.tex "htm,pic-align,p-width,svg"
tex4ht just ignored p-width
. To get the width to work, I had to remove the \ifdefined
code, like this:
\documentclass[11pt]{article}
\usepackage{amsmath,mathtools,amssymb}
\begin{document}
\begin{center}
\begin{tabular}{|p{1in}|p{2in}|}\hline
1&$ \left( x+y \left( x \right) \right) {\frac {\rm d}{{\rm d}x}}y \left( x \right) =x-y \left( x \right) $\\\hline
2&$3\,{t}^{2}+4\,ty \left( t \right) + \left( 2\,{t}^{2}+2\,y \left( t \right) \right) {\frac {\rm d}{{\rm d}t}}y \left( t \right) =0$\\\hline
3&$2\,t-2\,{{\rm e}^{ty \left( t \right) }}\sin \left( 2\,t \right) +{{\rm e}^{ty \left( t \right) }}\cos \left( 2\,t \right) y \left( t \right) + \left( -3+{{\rm e}^{ty \left( t \right) }}t\cos \left( 2\,t \right) \right) {\frac {\rm d}{{\rm d}t}}y \left( t \right) =0$\\\hline
\end{tabular}
\end{center}
\end{document}
Now p-width
works. But the math became bad again. So back to square one.
I need to be able to have table with fixed width columns, and also have the math look as nice as math outside the table, and still use SVG. But there is a conflict.
For some reason, make4ht math is not rendered correctly inside table cells when using SVG and also using \Configure{$}{\PicMath}{\EndPicMath}{}
at same time. May be it is dvisvgm issue. I do not know.
Is there a way around this?
I am using latest TL 2018, with most recent updates for make4ht and tex4ht.
pic-tabular
option. It will make picture for the whole tablemake4ht -ul -f html5+dvisvgm_hashes foo.tex "htm,pic-align,p-width,pic-tabular,svg"
but the it did not have any effect. Table is not an image. Did it work for you? Math inside table cells still looked bad. But even it can be made to work, this is not practical solution for long term. As the table has lots of text as well as math. If the whole table is an image, it means one can't copy any text using the mouse from the webpage where the table is showing, as it is one big image. As a workaround, might be OK though.pic-m
to make all inline math picturemake4ht -ulm draft -f html5+dvisvgm_hashes sample.tex "htm,pic-m,pic-align,svg,p-width"
works for me, without any custom configurations.\ifdefined\HCode
in there, and without it. The table column width did not change as it should. Did the width of the column when you tried it? Thanks.