# [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
Sat Aug 10 01:07:30 CEST 2013

I found a solution for this one also! (boy, I am getting good at this :)

The trick is to do

htlatex foo_split.tex "htm,0"

anything else, (1 or 2 or 3, etc...) produces that double TOC.

Now, to do the cutting which was before done using  "htm,2", can
be done using \CutAt{} command either inside the latex file or
in the .cfg  file.

Here is the same example. Now only ONE Toc is generated at the main
page, and "Contents" now has no link on it, which is what I wanted.

htlatex foo_split.tex "htm,0"

-------------------------------------
\documentclass{article}%
\usepackage{ifpdf}
\usepackage{lipsum}

\begin{document}
\title{test toc}
\author{me}
\date{\today}
\maketitle

\ifx\HCode\undefined \else
\CutAt{section}    % tell is to cut as if we did "htm,2", make
\fi                % section separate

\tableofcontents

\section{section 1}
\lipsum{1}
\subsection{subsection 1}
text
\section{section 2}
\lipsum{1}
\section{section 3}
\lipsum{1}

\end{document}
---------------------------------

One should really write a book of all these tricks.  I am still
trying to figure out how to split specific chapters or sections, and
not to split others. I still can't sort the correct way to do this
per unit as the case was with \TocAt{}.... but will keep trying...

--Nasser

On 8/9/2013 6:07 AM, Nasser M. Abbasi wrote:
> Hello;
>
> is generated when splitting a document vs. not splitting the document.
>
> For example, running this:
>
>      htatex foo.tex "htm"
>
> on the file
>
> ------------------------
> \begin{document}
> \tableofcontents
> ....
> \end{document}
> ------------------------
>
> 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:
>
> \begin{document}
> \ifdefined\HCode
> \else
> \tableofcontents
> \fi
> ....
> \end{document}
>
> and now htatex foo.tex "htm,2" will generate only one TOC on main
> page.
>
> 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?
>
>
>           htlatex foo.tex "htm,2"
>
> %--------------
> \documentclass{article}%
> \usepackage{ifpdf}
> \usepackage{lipsum}
>
> \begin{document}
> \title{test toc}
> \author{me}
> \date{\today}
> \maketitle
>
> \tableofcontents
>
> \section{section 1}
>      \lipsum{1}
>      \subsection{subsection 1}
>      text
> \section{section 2}
>      \lipsum{1}
> \section{section 3}
>      \lipsum{1}
> \section{section 4}
>      \lipsum{1}
> \section{section 5}
>      \lipsum{1}
>
> \end{document}
> -----------------------------
>
> thanks,
> --Nasser
>