Take the 2-minute tour ×
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.

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:

width=\textwidth
width=2in
width=1024px
width=1024pt

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
1  
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
1  
I think the latex2html tag doesn't apply to that question. –  ℝaphink Sep 14 '12 at 12:19
show 1 more comment

1 Answer

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

 \makeatletter
    \Configure{graphics}
     {\bgroup
         \Configure{IMG}
            {\HCode{<img src="}}
            {\HCode{" alt="}}
            {" }
            {\HCode{" }}
            {}%
      \Picture+[PIC]{}}
     {\EndPicture
       \HCode{ width="\expandafter\the\csname Gin@req@width\endcsname"
       height="\expandafter\the\csname Gin@req@height\endcsname"
        />}%
      \egroup}
 \makeatother
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
show 1 more comment

Your Answer

 
discard

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.