[tex4ht] How to make table of contents use correct settings of \setcounter{tocdepth} for \tableofcontents ?

Nasser M. Abbasi nma at 12000.org
Sat Aug 10 23:56:33 CEST 2013


I do not know if this is a bug or a feature of tex4ht that can
be modified by additional configurations. But I have a very simple
file, with chapter and sections.

All what I wanted is to have the main \tableofcontents show only
chapters in it, and not chapters and sections.

pdflatex output is correct, the TOC there shows only chapters. But
tex4ht insist in showing the chapter and the section in the TOC.

Here is MWE. \setcounter{tocdepth}{0} causes only chapters to show
up in the PDF's TOC, which is what I want, but not in HTML.
\setcounter{tocdepth}{1} causes chapters+section to show up in
the TOC of the PDF, but HTML shows now subsections as well. It seems
htlatex has one extra step in counting?

So, I said let me try \setcounter{tocdepth}{-1} may be that will make
htlatex think it is actually "0" now. But no luck, this caused
no TOC at all to be shown in HTML. So I have no idea what logic is used.

Do I have to use \ConfigureToc{??}{}{}{}{} somehow here? But this is
for the main (top) tableofcontents.

Any advice in how to make htlatex produce only chapters in this example?
I just wanted it to show the same TOC as the PDF in this example.

htlatex foo.tex "htm"

----------------------------------
\documentclass{report}%
\usepackage{lipsum}
\setcounter{tocdepth}{0} %this causes only chapters to show up
                          %but only in PDF. In html, it shows
                          %section as well in the TOC, why?
\begin{document}

\title{test TOC with tex4ht 2}
\author{me}
\date{\today}
\maketitle

\tableofcontents

%-----------
\chapter{chapter 1}
\lipsum{1}
\section{section 1 under chapter 1}
text
\subsection{subsection 1 under section 1 under chapter 1}
text
\subsubsection{subsubsection 1}

%----------------
\chapter{chapter 2}
\lipsum{1}
\section{section 1 under chapter 2}
\end{document}
----------------------------------

thanks
--Nasser


More information about the tex4ht mailing list