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

Nasser M. Abbasi nma at 12000.org
Tue May 19 10:07:07 CEST 2015


On 5/18/2015 9:02 AM, Michal Hoftich wrote:
> Hi Nasser,
>
> I think your setup is too complicated.
>
> First of all, you should conditionals for tex4ht in text of your
> document, you should use that only for conditional package loading in
> the preamble. You can configure graphicx package to include pdf image
> when you compile to pdf and svg when you compile with tex4ht. You only
> need to remove the image extension from the document:
>
>
> \documentclass[12pt]{article}
>
> \usepackage{graphicx}
>
> \begin{document}
> % \includegraphics[]{p}
>
> \includegraphics[width=0.5\paperwidth]{p}
> \end{document}
>
> Now you need to decide. If you always use
> \includegraphics[width=something]{imagename}, you can just configure
> graphicx to include svg files and configure tex4ht to support it:
>
>
>
> \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
>
> see \DeclareGraphicsExtensions and \Configure{graphics*}{svg}
>

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) ---
--------------------------------

I tried the build using your make4ht and also using htlatex.

May be I am doing something wrong, but I do not see it.

I have put the folder with the .tex, .cfg and the .svg image
in a zip file if you like to try your self.

http://12000.org/tmp/svg_support/

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.

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
----------------------------------------

Here is the command I used

make4ht foo.tex "nma,htm,charset=utf-8" " -cunihtf -utf8"

also tried

htlatex foo.tex "nma,htm"

Both give the same warning and the image do not resize.

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.

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.

> if you want to include images using their natural size, you need to
> extract the boinding box using `ebb -x imagename.pdf` command. This
> will create file imagename.xbb. Graphicx package with dvipdfmx option
> can then use this file for extracting the bounding box of the image:
>
> \DeclareGraphicsExtensions{.svg,.png,.jpg}
> \documentclass[12pt]{article}
> \ifdefined\HCode
> \usepackage[dvipdfmx]{graphicx}
> \else
>   \usepackage{graphicx}
> \fi
> \begin{document}
>   \includegraphics[]{p}
>
> % \includegraphics[width=0.5\paperwidth]{p}
> \end{document}
>
> and add to the .cfg file under \makeatletter:
>
> \@namedef{Gin at rule@.svg}#1{{svg}{.xbb}{#1}}
> \@namedef{Gin at rule@.SVG}#1{{svg}{.xbb}{#1}}
>
> Regards,
> Michal
>

Thank you,
--Nasser




More information about the tex4ht mailing list