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 have a document that is to be compiled in PDF (using pdflatex) and XHTML (using tex4ht). For the XHTML version, I wish to have the images linking to their source in a new window (target="_blank").

Now, this is perfectly possible by some fiddling with \HCode, but I prefer not having to write this every time when I include a graphic in my TeX source.

Is there a \Configure command I can use in my tex4ht config file, so that an a-tag is wrapped around the resulting img-tag automatically?

Note: I noticed \Configure{IMG}, but I assume that's for generated images, + there is not clear "image source" variable I can use.

share|improve this question
Welcome to TeX.sx! A tip: You can use backticks ` to mark your inline code. – Corentin Oct 23 '12 at 10:07
Oh, sorry, I was wondering if that was possible or not. Thanks for the edits! – hbro Oct 23 '12 at 11:25
@hbro see tug.org/applications/tex4ht/mn5.html#QQ1-5-28 – michal.h21 Oct 23 '12 at 11:36
@michal.h21 You sir, are my hero! Maybe make an actual answer out of it that I can promote? – hbro Oct 23 '12 at 12:05
up vote 5 down vote accepted

Based on tex4ht faq:

Create custom config file:

        {\Link[\csname Gin@base\endcsname .png target="_blank"]{}{}%  
           \Picture[pict]{\csname Gin@base\endcsname .png
              \space width="40px" height="40px" }%  

compile with htlatex texfile customcfgfile

share|improve this answer

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.