# Apparent conflict between hyperref and tex4ht packages

I am trying to use both the hyperref and tex4ht packages to format a textbook into a web textbook. Everything works except if I comment out chapter one, but if I include chapter one in the document, I get:

/usr/local/texlive/2011/texmf-dist/tex/generic/tex4ht/hyperref.4ht:314: LaTeX Error: Command \Hy@SectionHShift already defined.
Or name \end... illegal, see p.192 of the manual in '.


I tried using savesym to resolve the conflict but it didn't seem to work. Any ideas? I have no idea why only chapter one of the document doesn't work... there is no difference between it and any of the other chapters.

Also, I created this very simple document to see if I could use hyperref and tex4ht there, but it comes up with the exact same error that I pasted above:

\documentclass{article}
\usepackage[html]{tex4ht}
\usepackage{hyperref}
\title{hello}
\author{Me}
\begin{document}
\maketitle
\section{The first}

\section{The second}

\href{www.amazon.com}{amazon}

\end{document}


If anyone has any ideas, I would be much obliged.

-
I only get the error if I compile with pdflatex. Your example works if I use latex or htlatex. – Ian Thompson Jun 20 '12 at 21:01
@IanThompson you could turn your comment into an answer. – Gonzalo Medina Jun 20 '12 at 22:16
I don't think one has to \usepackage{tex4ht} which is loaded automatically when htlatex is called. – egreg Jun 20 '12 at 22:21

I only get the error if I compile with pdflatex. Your example works if I use latex or htlatex.

-
You're right, I just tried it and that's true for me too. However, it still creates an error with my more complex document(this applies whether or not I take out \usepackage{tex4ht} or not). It starts telling me that I have an error in almost every line... and this is a document that compiles just fine when I don't have the tex4ht or hyperref packages. Again, the other chapters work fine. Thanks! – J Jones Jun 20 '12 at 22:36
Also, in the book I'm using: \usepackage[html,3,sections+]{tex4ht} so I think I do need to keep that in explicitly... although I'm not entirely sure at this point. – J Jones Jun 20 '12 at 22:45
Sorry for my mess of comments, I'm new to this forum. I just wanted to add one last thing, which is that without explicitly including the package tex4ht with the html option, even the simple document does not format correctly as an html document. Thanks again. – J Jones Jun 20 '12 at 22:54
@JaneJones you can pass these options to htlatex as htlatex filename "html,3,sections+" – michal.h21 Jun 20 '12 at 23:22
Even if I use that syntax "htlatex filename "html,3,sections+", if I include hyperref, I still can't format a complex document without getting this error: /usr/local/texlive/2011/texmf-dist/tex/generic/tex4ht/hyperref.4ht:314: LaTeX E rror: Command \Hy@SectionHShift already defined. Or name \end... illegal, see p.192 of the manual in '. – J Jones Jun 22 '12 at 21:39