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 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
1  
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
add comment

1 Answer

up vote 5 down vote accepted

Based on tex4ht faq:

Create custom config file:

\Preamble{xhtml}
\Configure{graphics*}
        {png}
        {\Link[\csname Gin@base\endcsname .png target="_blank"]{}{}%  
           \Picture[pict]{\csname Gin@base\endcsname .png
              \space width="40px" height="40px" }%  
         \EndLink
         }
\begin{document}
\EndPreamble

compile with htlatex texfile customcfgfile

share|improve this answer
add 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.