TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following MWE:


Lorem ipsum dolor sit amet, \(k_\delta=\frac{3 \mathit{EJ}}{l^3}\) consectetur:
\begin{equation*}k_\delta=\frac{3 \mathit{EJ}}{l^3}\end{equation*}


which compiles fine to html (with htlatex example.tex "myconfig, xhtml, charset=utf-8" " -cunihtf -utf8" under Ubuntu TeXLive), myconfig.cfg being

    {\Picture[pict]{\csname Gin@base\endcsname .jpg
        \space width="\expandafter\the\csname Gin@req@width\endcsname"}}
    {\Picture[pict]{\csname Gin@base\endcsname .png
        \space width="\expandafter\the\csname Gin@req@width\endcsname"}}

Looking for a workaround to the unsolved problem of small image sizes in html output, I wrote a Python script which parses html source and doubles width and height of all images, getting in face of a new problem, poor quality of 'doubled' eps images. So I tried to increase density from 110x110 to 220x220 in tex4ht.env, <convert> section:

Gconvert -trim +repage -density 220x220 -transparent '#FFFFFF' zz%%4.ps %%3

This actually increased the resolution of eps images, so that now I can double their size in html source with my Python script, but also increased the size of math formula images (whose size is not affected by my Python script because they don't hold width nor height attributes).

Is there a way to increase eps images resolution without affecting math images size?

Here is a screenshot of the html output with doubled size of math formulas:

enter image description here

share|improve this question
up vote 2 down vote accepted

It seems I managed to find a solution by myself. I rolled back the change to tex4ht.env, so that math formulas rendered as image are safe now, and I added the following section to my above mentioned preamble myconfig.cfg:

    {\Needs{"convert -density 110x110 \csname Gin@base\endcsname.eps \csname Gin@base\endcsname.png"}
    \Picture[pict]{\csname Gin@base\endcsname.png}}

This way eps images are managed in a different way (dvi code is bypassed, as said here), so that now they lack width attribute in html source; however such lack is perfectly fine because now eps images look bigger in html output, their size is satisfactory and they don't need to be "externally" enlarged through my post-production Python script.

Here is a screenshot of original example after solution:

enter image description here


I actually discovered that, although above solution is able to enlarge eps images, their size is independent from the size specified in LaTeX source, and inconsistent with jpg and png images, which retain the width and height in html output. If you are looking for a consistent solution, the eps section of myconfig.cfg should be

    {\Needs{"convert -density 110x110 \csname Gin@base\endcsname.eps \csname Gin@base\endcsname.png"}
    \Picture[pict]{\csname Gin@base\endcsname.png
        \space width="\expandafter\the\csname Gin@req@width\endcsname"}}

This way width and height attributes in html output are retained also for eps images, and their size is consistent with jpg and png images, as I describe also in the problem I cited before.

share|improve this answer
Why not just use the geometry option as in: Gconvert -trim +repage -density 220 -geometry 50% -transparent '#FFFFFF' zz%%4.ps %%3 or the resample option as in Gconvert -trim +repage -density 220 -resample 120 -transparent '#FFFFFF' zz%%4.ps %%3` – Nasser Dec 31 '13 at 23:02
I tried your code but they did not work, at least for me. – mmj Jan 1 '14 at 9:22
No problem. It works for me just fine. Gconvert -trim +repage -density 220 -geometry 50% -transparent '#FFFFFF' zz%%4.ps %%3 is also documented here tug.org/applications/tex4ht/mn3.html "Increase the density (number of dots per inch) when converting the pictures, and then sub-sample the picture." – Nasser Jan 1 '14 at 13:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.