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 have a lot of PNG images in my document, which (the document) I'd like to convert to HTML using tex4ht (htlatex). Now the images need to be in EPS format, as htlatex uses DVI mode. So I run convert foo.png foo.eps before I run htlatex. When generating the HTML, tex4ht creates a new PNG out of these EPS images, although I have the original which could (should) be used instead. That would save me quite some time and space.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}

\section{something}
\includegraphics[width=5cm]{mill}
\end{document}

(mill.png is from the ConTeXt distribution, but could be any PNG file.)

share|improve this question
    
I thought it was not so much DVI-mode that requires eps, but the latex command itself. pdflatex can also output dvi by using -output-format=dvibut I don't know if it helps in this situation. –  Mikael Öhman Feb 4 '12 at 13:41
    
@MikaelÖhman that's an interesting thought, I'll do some research on that. –  topskip Feb 4 '12 at 13:55

2 Answers 2

up vote 2 down vote accepted

You must provide extension for your graphics file:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}

\section{something}
\includegraphics[width=5cm]{mill.png}
\end{document}

This compiles fine without need for the eps step

share|improve this answer
    
But png files do not have bounding box? the width will be ignored when run by tex4ht, and original .png size will be used. I tried it on texlive 2013. Only pdflatex will scale the .png file, but not tex4ht –  Nasser Jun 16 at 6:16

I feel stupid, but I can answer my own question. With the following configuration file, htlatex uses EPS and pdflatex uses PNG:

\Preamble{html}
\begin{document}

 \Configure{graphics*}
         {eps}
         {\Picture[pict]{\csname Gin@base\endcsname\PictExt}}

\EndPreamble

Save this file in whatever.cfg and call tex4ht with htlatex myfile whatever.

share|improve this answer

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.