[tex4ht] How to prevent 2 table of contents showing on the HTML page when splitting a document htlatex foo.tex "htm, 2" ?

Nasser M. Abbasi nma at 12000.org
Fri Aug 9 13:07:32 CEST 2013


I have always been very confused about how the main table of contents
is generated when splitting a document vs. not splitting the document.

For example, running this:

    htatex foo.tex "htm"

on the file


produces ONE toc on the main page, which is what one expects. It has
label on it called "Contents" but this is just text, not a link.

Now on the same file, running this:

   htatex foo.tex "htm,2"

produces the same TOC as first example above, but now it makes "Contents"
to be an actual link which clicking on it sends one to another copy of the TOC
on a new html page, looking the same as the one on the main index.htm page.

Is there a way to make it produce only ONE toc on index.htm (first page) and
with no links to another TOC?  Just like in the first example, even if I wanted
split document?  

I really do not want a link to a another TOC, when I have the TOC in front of
me as well. Very confusing.

One easy solution is this: To remove \tableofcontents command:


and now htatex foo.tex "htm,2" will generate only one TOC on main

Problem with this is that if I change my mind later, and want no splitting

        htatex foo.tex "htm"

Then I have to remember to edit the latex file and remove the above
conditional logic, else now no TOC is generated at all.

Is it that htlatex generates a TOC on its own when document is split,
in addition to the original \tableofcontents and that is why one ends
up with 2 of them?  I'd like to just use \tableofcontents and not
have to worry about an additional TOC showing up with split documents.

What is the correct way to handle all of this?

MWE, please run with

         htlatex foo.tex "htm,2"


\title{test toc}


\section{section 1}
    \subsection{subsection 1}
\section{section 2}
\section{section 3}
\section{section 4}
\section{section 5}



More information about the tex4ht mailing list