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

Kevin Fjelsted kfjelsted at gmail.com
Sat Aug 10 15:33:23 CEST 2013


WHere are you obtaining the HTATEX utility?
I googled that command and found nothing. :)

On Aug 9, 2013, at 6:07 AM, Nasser M. Abbasi <nma at 12000.org> wrote:

> Hello;
> 
> 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
> 
> ------------------------
> \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?
> 
> MWE, please run with
> 
>        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




More information about the tex4ht mailing list