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

At exporting a LaTeX file to HTML via tex4ht I have to write some HTML comments to the HTML source. So I would like to write the HTML code in the LaTeX file and let tex4ht export it directly. How can I achieve this? Are there some special LaTeX commands to do this?

share|improve this question
I found a solution: \HCode{<!--comment-->} but now I can't export to pdf any more. Is there a way to mask out this tex4ht command for other latex interpreters? – raulix Jun 9 '11 at 22:03
\def\HCode#1{} should disable the command. – Caramdir Jun 9 '11 at 22:31
raulix: You should add that (with Caramdir's comment) as an answer so that others who look for this will see that it has an answer. – Loop Space Jun 10 '11 at 7:05
you can also use ifpdf if you're using pdf(la)tex or ifxetex if you're using XeTeX. – ℝaphink Jun 10 '11 at 7:52

It works. tex4ht writes the comment and pdflatex ignores the tag. Fine.

share|improve this answer
To get this to work with both pdflatex and htlatex I needed to use \ifpdf\def\HCode#1{}\fi. – Peter Grill Oct 1 '14 at 18:09

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.