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

Nasser M. Abbasi nma at 12000.org
Sun Aug 11 20:48:18 CEST 2013

On 8/11/2013 8:42 AM, Radhakrishnan CV wrote:

>>
>>
> Here is a more comprehensive example which helps to understand
> \PauseCutAt{...} and \ContCutAt{...} to pause splitting and again continue
> splitting once it is paused.
>

Thank you for another magical solution.  It works very well.

There is some small issue I noticed when I was testing it
relating to TOC and not the splitting part.

May be it is just my misunderstanding.

I have a report class, with 2 chapters, they are the same exact
layout. Each chapter has 2 sections in it, and subsections in
each section. All the same.

I tell htlatex to make TOC at section level (in addition to at the
chapter level) using

\ifdefined\HCode
\TocAt{chapter,section} %show section only in chapters TOC
\TocAt{section,subsection} %show subsection only in sections TOC
\fi

Then I tell it to \PauseCutAt{section} before the second chapter
as you showed so that the second chapter shows in ONE page.

This all works, except that the TOC at the section level do NOT show
up in the second chapter (the one on one page), but it does show up
in the first chapter (that was that was split)

This tells me that \PauseCutAt{section} have a side effect on
generation of TOC at section level as well.

I wanted to see a TOC at the section level, even for the second
chapter.

Is it that htlatex only makes TOC at TOP of web page? and can't
have a local TOC inside a section, when this section is inside
a chapter, and both are in ONE page which is not split?

Please see a MWE example below. I looked at the documentation
here http://www.cvr.cc/?p=323  but was not able to fully follow
it. a Little too advanced for a newbie like me.

This is not a major problem for me, but I just like to understand
if this is how it is supposed to work, or if there is an additional
configuration command one can use for it? It would just be nice to
have a TOC there if possible.

thanks again for all your help and time.

htlatex foo.tex "htm,3"

---------------------------------------
\documentclass{report}
\setcounter{tocdepth}{0}
\setcounter{secnumdepth}{4}
\usepackage{lipsum}

\begin{document}

\title{my web site}
\author{me}
\date{\small\today}
\maketitle

%tell tex4ht to make main toc show only chapters
%thanks to Radhakrishnan CV for this solution
\ifdefined\HCode
\Configure{tableofcontents*}{chapter}
\fi

\tableofcontents

\ifdefined\HCode
\TocAt{chapter,section} %show section only in chapters TOC
\TocAt{section,subsection} %show subsection only in sections TOC
\fi

%---------------------
\chapter{chapter 1}
\lipsum[10]

\section{section 1 in chapter 1}
\lipsum[1-2]

\section{section 2 in chapter 1}
\lipsum[1-2]
\subsection{subsection 1 in section 2 in chapter 1}
\lipsum[1-2]
\subsection{subsection 2 in section 2 in chapter 1}

\section{section 3 in chapter 1}
\lipsum[1-2]

%---------------------

\ifdefined\HCode
\PauseCutAt{section}
\fi

%\ifdefined\HCode   %adding this did not help.
%\TocAt{chapter,section} %show section only in chapters TOC
%\TocAt{section,subsection} %show subsection only in sections TOC
%\fi

\chapter{chapter 2}
\lipsum[10]

\section{section 1 in chapter 2}
\lipsum[1-2]

\section{section 2 in chapter 2}
\lipsum[1-2]
\subsection{subsection 1 in section 2 in chapter 2}
\lipsum[1-2]
\subsection{subsection 2 in section 2 in chapter 2}

\section{section 3 in chapter 2}
\lipsum[1-2]

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

--Nasser