[tex4ht] two figures in one row

Michal Hoftich michal.h21 at gmail.com
Wed Jan 27 14:46:05 CET 2021


Hello Tomáš,

>in the configuration file, which I adopted. Nevertheless, in some cases 
>the figures can't be automatically converted to SVG, so I made the 
>conversion to PNG manually and for such figures I use this code
>
>\begin{figure}
>
>\centering
>
>\ifpdf
>
>\includegraphics[width=0.49\linewidth]{fig_1.eps} 
>\includegraphics[width=0.49\linewidth]{fig_2.eps}
>
>\else
>
>\begin{tabular}{cc}
>
>\includegraphics{fig_1.png} & \includegraphics{fig_2.png}
>
>\end{tabular}
>
>\fi
>
>\end{figure}
>
>It works rather well, but there are two issues:


It is not a good idea to have markup like this in your document. Instead 
of \ifpdf, I would use custom command that can be redefined in the .cfg 
file:

\newcommand\twoimages[2]{%
\includegraphics[width=0.49\linewidth]{#1}%
\includegraphics[width=0.49\linewidth]{#2}%
}

And in the .cfg file, you can use

\renewcommand\twoimages[2]{%
some code
}

This way you don't need to change code in your document when you find 
that something don't work well :)


>
>1. what is the best way to scale the figures for the HTML document? I 
>played with [scale=XX] option of includegraphics, but it does a bit 
>tricky and not always leading to expected results

Maybe try to create the .xbb files for png images:

$ ebb -x *.png

Without .xbb file, TeX4ht doesn't know dimensions of images, so scaling 
cannot work, I think.


>
>2. as some tables contain a lot of maths, I prefer to use pic-tabular 
>option. Nevertheless, it clashes with the figures within the tabular 
>environment. Is there any other way to achieve two PNG files to 
>display in one row? The above mentioned configuration command does not 
>seem to help in these cases....


I would output some HTML and CSS for the \twoimages command I introduces 
earlier. For example:

\renewcommand\twoimages[2]{\ifvmode\IgnorePar\fi\EndP\HCode{<div 
class="twoimages">}%
\includegraphics{#1}%
\includegraphics{#2}%
\ifvmode\IgnorePar\fi\EndP%
\HCode{</div>}
}

\Css{.twoimages img{width: 40\%; height:auto}}

Best regards,
Michal


More information about the tex4ht mailing list.