The env
file is stored in %texmf-home%/texmf-dist/tex4ht/base/unix
or %texmf-home%/texmf-dist/tex4ht/base/win32
, depending on your operating system. For testing purposes, it is best to make copy of that file in your working directory.
The structure of this file is little bit strange:
<tag>
Gsome command and the parameters
Ganother command
</tag>
<anothertag>
GNext command
Gcommand again
</anothertag>
Spaces are important. All lines with space at the beginning are ignored. Tagged sections are sometimes ignored. Quoting tex4ht.env
itself:
Tagged script segments ... are scanned only if their names are specified within -ctag switches of tex4ht.c and t4ht.c. When -c switches are not supplied, a -cdefault is implicitly assumed.
In the example, only GNext command
is actually executed. If you look at actual tex4ht.env
file, you can see that there are several configurations for output of images. Default is
<convert>
G.png
Gdvips -E -q -Ppdf -f %%1 -pp %%2 > zz%%4.ps
Ggs -sDEVICE=pngalpha -sOutputFile=%%3 -r110x110 -dEPSCrop -dBackgroundColor=16#ffffff -dTextAlphaBits=2 -dGraphicsAlphaBits=2 -q -dbatch -dNOPAUSE zz%%4.ps -c quit
Grm zz%%4.ps
G.svg
Gdvips -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.eps
Gpstoedit -f svg zz%%4.eps %%3
G.
Gdvips -E -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
Gconvert -trim +repage -density 110x110 -transparent '#FFFFFF' zz%%4.ps %%3
</convert>
lines
G.
Gdvips -E -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
Gconvert -trim +repage -density 110x110 -transparent '#FFFFFF' zz%%4.ps %%3
means, that default conversion uses dvips
command to convert picture to the eps file and then using convert to the final output format.
There is also section
<dvipng>
G.png
Gdvipng -T tight -x 1440 -D 96 -bg Transparent -pp %%2:%%2 %%1 -o %%3
G.gif
Gdvipng -T tight -x 1440 -D 96 -bg Transparent -gif -pp %%2:%%2 %%1 -o %%3
G.
Gdvips -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
Gconvert -crop 0x0 -density 110x110 -transparent '#FFFFFF' zz%%4.ps %%3
Grm zz%%4.ps
</dvipng>
Which uses dvipng
instead of convert
and dvips
and in my opinion the output is better. So to use this configuration, just erase spaces before <convert>
and </convert>
, and add space at the beginning of <dvipng>
and </dvipng>
Another opinion is to use svg
images instead of the png
. Just add :
G.svg
Gdvisvgm -n -p %%2 -c 1.2,1.2 -s %%1 > %%3
Create the file myconfig.cfg
:
\Preamble{xhtml}
\Configure{Picture}{.svg}
\begin{document}
\EndPreamble
and call:
htlatex file "myconfig"
Edit:
Another option is to to use make4ht build system. You can specify image conversion command in the build file, see the chapter on that matter