[tex4ht] TeX4ht warning --- Cannot determine size of graphic in svg graphics. Does tex4ht support bounding box on svg?

Michal Hoftich michal.h21 at gmail.com
Tue May 19 17:35:16 CEST 2015

> Thanks Michal. I tried the above option you have, but I have not
> been able to get it working. I am on TL 2014. I keep getting
> ----------------------
> (/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
> (./foo.aux))
> l.6 --- TeX4ht warning --- Cannot determine size of graphic in 2.svg (no
> Boundi
> ngBox) ---
> --------------------------------

you need to create a .xbb file for each svg file. you can create it
with `ebb -x` command (I am not sure whether it is installed by
default with TeX Live.

> Here is the tex file:
> -------------------------------
> \documentclass[12pt]{article}
> \usepackage{graphicx}
> \begin{document}
> \includegraphics[width=0.2\paperwidth]{2}
> \end{document}
> --------------------------------
> There is a file called 2.pdf and 2.svg in the folder.
> pdflatex works fine and the image shows small as expected. But
> the HTML shows the image as SVG, but not resized due to the
> above warning.

in this example the image should have width of 1/5 textwidth, original
image size isn't used at all, so the warning shouldn't matter.

> Here is the .cfg I am using (from your last email)
> ------------------------------------
> \Preamble{ext=htm,p-width,pic-align} %work well with something, I forgot
> what
> \DeclareGraphicsExtensions{.svg,.png,.jpg}
> \Configure{Picture}{.svg}
> \makeatletter
> \Configure{graphics*}
> {svg}
> {
>   {\Configure{Needs}{File: \Gin at base.svg}\Needs{}}
>   \Picture[\csname a:GraphicsAlt\endcsname]{\csname
> Gin at base\endcsname.svg width="\expandafter\the\csname
> Gin at req@width\endcsname"  height="\expandafter\the\csname
> Gin at req@height\endcsname"
> }
> }
> \begin{document}
> \EndPreamble
> ----------------------------------------

this config file doesn't use image size information from the .xbb
file. as I said, it doesn't work with explicit setting of image size.
(error `Package graphics Error: Division by 0.` is produced)

> Here is the command I used
> make4ht foo.tex "nma,htm,charset=utf-8" " -cunihtf -utf8"

you can also use

    make4ht -uc nma.cfg foo.tex htm


> also tried
> htlatex foo.tex "nma,htm"
> Both give the same warning and the image do not resize.

of course :)



to the .cfg file under \DeclareGraphicsExtensions if you want to use
original image dimensions. but if you use that with explicit width
setting, it will fail with `Division by 0` error, as I said earlier.
It is maybe graphicx bug, because the same error is produced with
plain LaTeX.

> btw, when one writes \makeatletter  does one need to also add \makeatother
> at the end? I noticed you did not have \makeatother in the above.

I forgot it :)

> Also, since I got your attention, I am confused about one thing:
> When using your build system make4ht, does it still use/read the
> tex4ht.env or does it not need it?  Please let me know if I can
> try anything. I'd like to use your method above, since it saves
> me having to make .eps for each image.

it does use it, but you can modify image generation and conversion in
a build file



More information about the tex4ht mailing list