# tex4ht problems with footnotes

I have a problem with footnotes and tex4ht. The following document has a wrong next pointer in subsection 1 and a bad previous pointer in subsection 3:

\documentclass{book}
\begin{document}
\chapter{chap}
\section{A}
\subsection{aa}
xxx\footnote{A}yyy
\subsection{ab}
text
\subsection{ac}
text
\end{document}


The command I use to generate html files is: htlatex main xhtml,4,next. To reproduce: open main.html and click on 1.1.1 "aa" and then click on "next" to go to 1.1.3 (instead of 1.1.2).

When running the above command a second time, everything works fine. What is the correct way to get a sane document at the first run? That is with a directory that contains only the .tex file and no intermediate files?

-
Just an observation: I don't know about tex4ht, but I just rendered your example to html using plastex and it behaves correctly on the first run. plastex.sourceforge.net – Tim A Mar 30 '12 at 14:55
I took the liberty to open a bug at the tex4ht bug database. I will report here any informations from the devs others than a bug fix. – ppr Oct 25 '13 at 14:25

The short answer is there is no way to get a sane document at the first run.

LaTeX is designed to be run two times (at least) to create a correct document structure. At the first run, LaTeX produces files which will be use the second time to create a correct structure.

This is not a tex4ht issue.

-
by default, tex4ht run latex three times, to get correct links. it seems in this particular case even three runs are not enough, as on second tex4ht run (after 6 latex runs!), links are correct – michal.h21 Oct 24 '13 at 19:39
Indeed ! sorry for the mistake. So, it seems to me it's a bug inside tex4ht. Perhaps tex4ht dev should be interested by this post. – ppr Oct 25 '13 at 14:05