There are number of ways to add htlatex commands to latex document. But the document has to still work with pdflatex.
Here is one way to do it, using ifx
\documentclass{report} \usepackage{hyperref} \begin{document} \tableofcontents \ifx\HCode\undefined \else \href{foo.htm}{HTML} \TocAt{chapter,section,subsection,subsubsection} \fi \chapter{chapter 1} \section{section 1 in chapter 1} \subsection{subsection 1 in section 1 in chapter 1} \subsection{subsection 2 in section 1 in chapter 1} \subsubsection{subsubsection 1 subsection 2 in section 1 in chapter 1} \end{document}
Another way is to use HCode
\documentclass{report} \usepackage{hyperref} \begin{document} \tableofcontents %--------------------- \ifdefined\HCode \href{foo.htm}{HTML} \TocAt{chapter,section,subsection,subsubsection} \fi \chapter{chapter 1} \section{section 1 in chapter 1} \subsection{subsection 1 in section 1 in chapter 1} \subsection{subsection 2 in section 1 in chapter 1} \subsubsection{subsubsection 1 subsection 2 in section 1 in chapter 1} \end{document}