I have a long LaTeX document with lots of figures that were included using commands of the form


Everything compiles fine with pdfLaTeX. I planned to convert the document into HTML using TeX4ht, but it seems that TeX4ht does not understand the page= attributes in \includegraphics.

Are there any easy solutions? Ideally, I would prefer to keep my main Latex source unmodified and just tweak the preamble.

2 Answers 2


Sorry for being late. Following code is likely to help the Jukka:


    pdftops -eps -f \GPT@page\space -l \GPT@page\space \[email protected] \Gin@base-\[email protected]"
    convert \Gin@base-\[email protected] \Gin@base-\[email protected]
    \Picture[pict]{\Gin@base-\[email protected]}%

\Includegraphics[10]{foo.pdf} should work now both with pdfLaTeX and TeX4ht.

  • 1
    We are glad to have you here in TeX.SX. A warm welcome to you.
    – user11232
    Commented Sep 15, 2012 at 6:44

TeX4ht does not use pdfTeX in PDF mode, but dvips instead. However dvips can neither read PDF files nor multipage files. Page 10 can be extracted and converted to eps with epstopdf of xpdf:

epstopdf -eps -f 10 -l 10 foo.pdf foo-10.eps

Or ghostscript can be used, e.g.:

gs -dFirstPage=10 -dLastPage=10 -sDEVICE=epswrite -dBATCH -dNOPAUSE -sOutputFile=foo-10.eps foo.pdf

Then in the source:


And package ifpdf is needed in the preamble:

  • Something along these lines certainly works, but it requires changes in the body of the Latex document. I wonder if I could easily redefine \includegraphics; moreover, perhaps I could have Latex run gs automatically to when needed? Commented Aug 28, 2012 at 18:02
  • It could be done, looking at package epstopdf that support external conversion programs for pdfTeX in PDF mode, I would expect several hundred lines of code. Commented Aug 28, 2012 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .