[tex4ht] Including vector graphics (graphicx and PDF files)

Michal Hoftich michal.h21 at gmail.com
Thu Jan 7 16:23:06 CET 2016


Dear Hans Georg,

On Thu, Jan 7, 2016 at 11:08 AM, Hans Georg Schaathun
<georg+tex at schaathun.net> wrote:
> Dear all,
>
> I have a number of externally created vector graphics objects
> which I need to include in TeX document to be compiled with
> tex4ht.  The problem is that the resulting pixmap graphics (PNG)
> has inadequate resolution.  Does anyone have a working fix for this?

You can change the resolution with `graphics-<res>` option for
tex4ht.sty, so you can try

htlatex graphcis.tex "xhtml,2,mathml,graphics-144,charset=utf-8" "
-cmozhtf -utf8" \
     "-cvalidate"

for example. But it changes only calculation of the dimensions in the
<img> element, you need also to change resolution of the png image
itself. You can change it in tex4ht.env, but easier is to use make4ht
build file. See graphcis.mk4, in particular line:

Make:image("png$",
"dvipng -bg Transparent -T tight -o ${output} -D 144  -pp ${page} ${source}")

dvipng is used for graphics conversion, -D option passes the
resolution. To translate your options to make4ht, call

make4ht -u graphcis.tex "xhtml,2,mathml,graphics-144" "" " -cvalidate"


>
> I would normally have an original file.pdf and a converted file.eps,
> both of which look like vector graphics, and then use:
> \usepackage{graphicx}
> \includegraphics{file}
> This works well with pdflatex, and except for the poor pixmap
> resolution, ok with htlatex.
>
> The preferred solution would be to use SVG vector graphics on the web
> page.  Whether tex4ht does the PDF->SVG conversion or I do it separately
> matters little.  I have tried to google, but all the hits seems to be
> concerned with generating SVG from tikz and maths, which is not
> quite the problem.

You can convert your images to svg using inkcape:

inkscape -z fplot.eps --export-plain-svg=fplot.svg

but you need to configure tex4ht to include svg images, see attached
file hej.cfg. You can change the value in `\emwidth` command to
influence the displayed image size.


Best regards,
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graphics.mk4
Type: application/octet-stream
Size: 202 bytes
Desc: not available
URL: <http://tug.org/pipermail/tex4ht/attachments/20160107/c855165c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hej.cfg
Type: application/octet-stream
Size: 792 bytes
Desc: not available
URL: <http://tug.org/pipermail/tex4ht/attachments/20160107/c855165c/attachment-0001.obj>


More information about the tex4ht mailing list