I recently updated my Ubuntu environment from 18.04 to 22.04 and I noticed that the default behavior of tex4ht (or htlatex) with respect to included graphics significantly changed.
Consider the basic example ex.tex
\documentclass{article}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur $2+3=5$:
\[a=b+c\]
\begin{centering}
\includegraphics[width=0.5\textwidth]{myimage.eps}
\end{centering}
\end{document}
Now the result of the basic conversion command:
htlatex ex.tex "xhtml, charset=utf-8, pic-m, gif", "-cunihtf -utf8"
is the creation of two gif files: ex0x.gif, ex1x.gif
(corresponding to formulas) and one png file:myimage.png
which is a converted graphics.
However, in Ubuntu 18.04 the result of the same command was completely different - it produced three gifs: ex0x.gif, ex1x.gif, ex2x.gif
with the third gif corresponding to included graphics.
This change of default behavior leads to the following problems in my working environment:
- There is no longer a common pattern for the names, and event types (gif+png) of graphics generated by htlatex. This complicates the further post-processing of the generated files.
- In the old behavior, the image generated form the included graphics has the correct pixel dimension (at least the width). That is the width produced by tex4ht in the
<img>
tag was the same as the pixel width of the generated file. In the current behavior this is not the case, as the png is generated with fixed density relative to the bounding box. In my case it sometimes is too small, and sometimes is too large.
So I have the following question: is it possible to mimic the old behavior of htlatex, that is to force it to convert the included eps graphics in the same way as other pictures generated by math formulas?
Some more info:
- I used to generate gif's, but it is ok for me to switch to png's, so the
gif
option is not important. - I do see how
tex4ht
generates png files from eps graphics - its the following fragment in the source code (tex4ht-html4.tex
)
\Configure{graphics*}
{eps}
{\openin15=\csname Gin@base\endcsname\PictExt\relax%
\ifeof15%
\Needs{\a:EpsConvert}%
\fi%
\closein15%
{\Configure{Needs}{File: \Gin@base\PictExt}\Needs{}}%
\Picture[\a:GraphicsAlt]{{\Gin@base\PictExt} |<graphics dim|>}}
|<graphics default extensions|>
....
\Configure{EpsConvert}{"\a:Ghostscript\space -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -r\gr:density\space -sDEVICE=pngalpha -sOutputFile="\[email protected]" "\[email protected]" "}
but I somehow can not find the old source code for this conversion (with old behavior).
- I am not completely sure if this is really a problem with tex4ht or with latex itself (or some of its packages, graphicx?)
- I can manage the problem with the lack of the common pattern for the generated png files, but the problem with wrong pixel dimensions (widths) of the generated files is really annoying.