Currently, I tell tex4ht to use svg instead of png for math images. This results in better image quality. However, it is slow in image generation, as it takes about 1-2 seconds for each image to be generated since it has to load the idv file each time to make each image for each math expression.
Is there a way to speed this process up? I'll describe the current process I use for reference.
I edited sudo vi /usr/local/texlive/2014/texmf-dist/tex4ht/base/unix/tex4ht.env
and add these 2 lines
G.svg
Gdvisvgm -n -p %%2 -c 1.2,1.2 -s %%1 > %%3
as shown in this image
Next, edited my tex4ht cfg file (called nma.cfg) and added svg entry
\Preamble{ext=htm,charset="utf-8",p-width,pic-align}
\Configure{Picture}{.svg}
\makeatletter
\Configure{graphics*}
{svg}
{
{\Configure{Needs}{File: \[email protected]}\Needs{}}
\Picture[\csname a:GraphicsAlt\endcsname]{\csname Gin@base\endcsname.svg
\csname a:Gin-dim\endcsname}
}
\begin{document}
\EndPreamble
Next, I call tex4ht on the latex file as follows
make4ht -u foo.tex "nma,htm,pic-align,notoc*"
where make4ht
is found in https://github.com/michal-h21/make4ht
If you do not have make4ht
installed, then the command
htlatex foo.tex "nma,htm,pic-align,charset=utf-8,notoc*" " -cunihtf -utf8"
will work as well. Here is foo.tex with 2 equations which will cause 2 images to be generated
\documentclass[11pt]{article}
\usepackage{graphicx} %must be included
\begin{document}
\[
x = \sin(y)
\]
and
\[
x2 = \sin(y)
\]
\end{document}
Now we see tex4ht loading the idv each time for each image:
......
t4ht.c (2012-07-25-19:28 kpathsea)
t4ht -f/foo.tex
(/usr/local/texlive/2014/texmf-dist/tex4ht/base/unix/tex4ht.env)
Entering foo.lg
System call: dvisvgm -n -p 1 -c 1.2,1.2 -s foo.idv > fo0x.svg
processing page 1
page size: 58.1681pt x 13.0909pt (20.4437mm x 4.60093mm)
page written to <stdout>
1 of 2 pages converted in 0.244021 seconds
System return: 0
System call: dvisvgm -n -p 2 -c 1.2,1.2 -s foo.idv > fo1x.svg
processing page 2
page size: 64.7136pt x 13.0909pt (22.7442mm x 4.60093mm)
page written to <stdout>
1 of 2 pages converted in 0.243742 seconds
System return: 0
Is there a way to speed this up to avoid loading the idv each time for each equation and do them all at once? Currently it takes 4 days to build my large latex file and I need a way to speed this up.