TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 am using htlatex (or as many people call it tex4ht) to generate html and I have included some graphics. Htlatex seems to ignore all the size arguments I give the image size. I've tried specifying:


All of these have been ignored. Can you specify a size for the image when using htlatex to generate an html version of your document? If yes how does one specify the image size?

Right now I am editing each picture to be the correct size but this is bothersome... I would much rather have one high res picture and then specify a smaller size.

share|improve this question
Do people usually call it htlatex or tex4ht? – Trevor Boyd Smith Jul 27 '12 at 14:01
tex4ht is more general, htlatex is only one script from the bundle, there are also others – michal.h21 Jul 27 '12 at 14:12
see tex.stackexchange.com/a/43801/2891 for some details on how tex4ht process images – michal.h21 Jul 27 '12 at 14:14
also tex.stackexchange.com/q/46156/2891 – michal.h21 Jul 27 '12 at 14:15
I think the latex2html tag doesn't apply to that question. – ℝaphink Sep 14 '12 at 12:19

Following code will help you to grab the width and height dimensions of the graphic provided with your \includegraphics command:

            {\HCode{<img src="}}
            {\HCode{" alt="}}
            {" }
            {\HCode{" }}
       \HCode{ width="\expandafter\the\csname Gin@req@width\endcsname"
       height="\expandafter\the\csname Gin@req@height\endcsname"
share|improve this answer
how do I use this Latex code? (is it a one time bit that goes in the preamble? is it a macro definition that I use each time I include a graphic? does it go in the options for includegraphics?) – Trevor Boyd Smith Sep 18 '12 at 19:56
It is a one time bit to be entered in the preamble. – CV Radhakrishnan Sep 19 '12 at 15:06
Sorry, I am unable to make this work. I put the above code into a working .cfg file, and in my tex file, the image is used as \includegraphics[width = 2in]{figs/test.png}, but the image still appears in fullresolution in the generated html. – M-V Sep 23 '12 at 7:11
You need to keep *.eps versions of your figures. Since tex4ht relies on .dvi and hence dvips driver of graphicx package is made use of, only .eps files will provide all the functionality of \includegraphics. Also, remove the extension .png from your your included graphic file names. – CV Radhakrishnan Sep 24 '12 at 7:06
With TeXLive under Ubuntu I get the error (I report just a small portion) l.134 --- TeX4ht warning --- \Configure{graphics}? --- l.134 --- TeX4ht warning --- \Configure{IMG}? --- and ...such style files MUST BE UPDATED to use Current Standard LaTeX: LaTeX2e.... – mmj Dec 2 '13 at 10:46

Since htlatex seems to generate a DVI first, the following answer helped me: Cannot determine size of graphic

So for setting the displayed size of a 530x260 JPG image in HTML, I did:

share|improve this answer
A screenshot of the output would help and we appreciate full examples, not just one-line-code samples ;-) – Christian Hupfer Aug 5 '14 at 12:54

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.