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

Radhakrishnan CV cvr at river-valley.org
Sun Aug 11 08:36:42 CEST 2013

On Sun, Aug 11, 2013 at 7:29 AM, Nasser M. Abbasi <nma at 12000.org> wrote:

> A little bit of progress, but no solution yet.  I thought I update
> in case someone can help with this last part.
>
> I found a way to remove the section entry from the main tableofcontents
> (on first page) so that only chapters show up, like this:
>
> 1. chapter 1
> 2. chapter 2
>
> Before it was like this:
>
> 1. chapter 1
>    1.1 section 1
> 2. chapter 2
>    2.1 section 1
>
> This is good, which is what I wanted. The problem is that this
> solution now removed section and anything above it entries from
> the local table(s) of contents that I had in each chapter later on.
>
> I am not able to figure how to get that back.
>

I think, the following might help you:

%----------------------------------
\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

\Configure{tableofcontents*}{chapter}
\tableofcontents

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

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

htlatex <filename> 'html,2'

Best regards
--