I use make4ht and use SVG for images. This works well, and I can use

\includegraphics[width=\textwidth]{p1} or
\includegraphics[width=\paperwidth]{p1} or
\includegraphics[width=0.6\textwidth]{p1} etc... and it will adjust
image size correctly. I am using some magic configuration
code in my .cfg file by Michal to do this.

But for some reason, \includegraphics[width=\columnwidth]{p1}
did not scale the image to the columnwidth. pdflatex
and lualatex do.

I can easily workaround this for now, by using

       \includegraphics[width=0.5\textwidth]{p1}

when using 2 columns, or

      \includegraphics[width=0.33\textwidth]{p1}

when using 3 columns and so on. But it will be better if tex4ht
did it automatically like with \textwidth and \paperwidth.

Here is a MWE. I put the needed code from the .cfg inside the
latex file, so it is self contained and everything in one file:

------------------------------------------------
\documentclass[12pt]{article}%
\usepackage{multicol}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{blindtext}

\setlength{\columnseprule}{1pt}

\begin{document}
\ifx\HCode\undefined \else
\DeclareGraphicsExtensions{.svg}
\Configure{Picture}{.svg}
\makeatletter
\newcommand\emwidth{10}
\newcommand\CalcRem[1]{\strip@pt\dimexpr(#1)/\emwidth}
\Configure{graphics*}
  {svg}
  {\Picture[pict]{\csname Gin@base\endcsname.svg
  \space style="width:\CalcRem{\Gin@req@width}em;"
  }%
  \special{t4ht+@File: \csname Gin@base\endcsname.svg}
  }
\makeatother
\fi

\begin{multicols}{3}
\blindtext

\includegraphics[width=0.9\columnwidth]{p1}

\blindtext

\includegraphics[width=0.9\columnwidth]{p1}

\blindtext

\includegraphics[width=0.9\columnwidth]{p1}

\blindtext

\includegraphics[width=\columnwidth]{p1}
\end{multicols}
\end{document}
-------------------------------

Compiled with

make4ht --lua -u foo.tex "htm"

Here is screen shot of the result in HTML

http://12000.org/tmp/020316/screen_shot_pdf.png

And this is in pdf

http://12000.org/tmp/020316/screen_shot_pdf.png

The image p1.svg and p1.pdf used in the above MWE, are in this zip file

http://12000.org/tmp/020316/multi_image.zip

Using TL 2015 on linux. Is it possible to make tex4ht adjust image
to columnwidth automatically also?

thanks,
--Nasser

Reply via email to