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.


2 Answers 2


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"
  • 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?) Sep 18, 2012 at 19:56
  • It is a one time bit to be entered in the preamble. Sep 19, 2012 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, 2012 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. Sep 24, 2012 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, 2013 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:

  • 1
    A screenshot of the output would help and we appreciate full examples, not just one-line-code samples ;-)
    – user31729
    Aug 5, 2014 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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