[tex4ht] SVG or PNG ?

Tomas Davidek Tomas.Davidek at cern.ch
Sun Jan 24 14:15:06 CET 2021


Hello,

    can someone please explain what are pros and cons of using graphics 
in PNG or SVG for the LaTeX to HTML conversion? Naively I would guess 
SVG is better since it is vectorized format, but after playing with that 
I encounter the following issues:

1. png (default?) with make4ht -a debug -u pictures_t4h.tex

Some LaTeX vector graphics (picture environment, commands \line, \vector 
etc) does not convert to PNG files. In the attached example, the first 
picture comes out ok, while the 2nd is missing the lines and curly 
lines. Surprisingly, the DVI file is almost ok (all lines are there, 
just some labels are missing), but the resulting PNG file only contains 
the label. The above command reports several error messages from dvipng:

[INFO]    make4ht-lib: executing: t4ht  "pictures_t4h.dvi"
GPL Ghostscript 9.53.3: Unrecoverable error, exit code 1
dvipng warning: No image output from inclusion of raw PostScript GPL 
Ghostscript 9.53.3: Unrecoverable error, exit code 1
dvipng warning: No image output from inclusion of raw PostScript GPL 
Ghostscript 9.53.3: Unrecoverable error, exit code 1

Is that a t4ht issue?

2. svg with make4ht -a debug -u pictures_t4h.tex "svg"

In this approach the 2nd picture comes out perfectly ok, but there are 
some non-vector EPS files that do not convert to SVG, like the third 
plot. The EPS -> PDF conversion proceeds well, but then pdf2svg results 
in an empty white picture of the corresponding size. I also tried to use 
inkscape for the latter conversion, with the same result.

As a possible workaround I can think of converting the problematic EPS 
files to PNG manually and account for that in the LaTeX code by e.g.

\ifpdf \includegraphics{myfigure.eps} \else 
\includegraphics{myfigure.png}\fi

But probably there is a smarter way to go?

One more general question - with the "svg" option, all graphics (i.e. 
math, plots etc) are converted to SVG instead of PNG, right? There is no 
way to force e.g. plots to appear in PNG and math in SVG, or is there?

Best regards,

                            Tomas


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pictures_t4h.tex
Type: text/x-tex
Size: 3200 bytes
Desc: not available
URL: <https://tug.org/pipermail/tex4ht/attachments/20210124/14e9109c/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: street_stevenson_layout.eps
Type: image/x-eps
Size: 577028 bytes
Desc: not available
URL: <https://tug.org/pipermail/tex4ht/attachments/20210124/14e9109c/attachment-0003.bin>


More information about the tex4ht mailing list.