TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Related question tex4ht: limit toc

I give up trying things. This is too hard.

I have this document

\section A
\section B
  \subsection B.1
  \subsection B.2
\section C

I want one main TOC, but also want TOC for each section that includes its subsections. I can break the document to 2 levels using htlatex. Hence the main level will have this toc

section A
section B
 subsection B.1
 subsection B.2
section C

then when clicking on section B link, it open a new page as expected, where now all the sections B.1 and B.2 are in that one html page as expected. but I want this page to have another TOC in it as well, since it has many subsections there. So I need a TOC like this

section B
 subsection B.1
 subsection B.2

on its own HTML page. But now there is no such TOC there. there is only one main global TOC on the first HTML page.

This is the command I use

 htlatex foo.tex "htm,2"

I also tried config file with \ConfigureToc{chapter}{section}{}{}{} in it. But I get only one TOC.


    \ConfigureToc{chapter}{section}{}{}{} %?
  %\TocAt{chapter,section} ?

 htlatex foo.tex "nma.cfg,htm,2" " -cunihtf" 

also tried

 htlatex foo.tex "nma.cfg,htm,3" " -cunihtf" 

Any idea how to make a TOC in each separate HTML page?

share|improve this question
up vote 3 down vote accepted

Try this foo.cfg


First parameter of \TocAt requires section level which should be configured, then follows list of section levels to be printed


There is some info if you run htlatex foo "foo, 2, info" in the foo.log file:

Tables of Contents

Created from the entries collected in the previous compilation within
a jobname.4tc file.

\ConfigureToc{unit-name} ......................4

   #1 before unit number
   #2 before content
   #3 before page number
   #4 at end

   * Empty arguments request the omission of the corresponding field.

   * \TocCount  Specifies the entry count withing the jobname.4tc file.

   * \TitleCount Count of entries submitted to the toc file

   * An alternative to \ConfigureToc{unit-name}:

      \def\toc<unit-name>#1#2#3{<before unit number>#1<before content>#2%
                             <before page number>#3<at end>}


           {\Picture[*]{pic.jpg width="13"  height="13"}~}
           {\HCode{<br />}}


   Configures the link offered in the third arguments of \ConfigureToc

   Example:   \Configure{TocLink}{\Link{#2}{#3}#4\EndLink}


    #1           section type for which local tables of contents
                 \Toc#1 are requested
    #2,#3,...    sectioning types to be included in the tables of

    The non-leading arguments may be preceded by slashes '/', in
    which cases the arguments specify end points for the tables.

    The default setting requests automatic insertion of the local
    tables immediately after the sectioning heads.

    A star `*' character may be introduced, between the  \TocAt and
    the left brace, to request the appearances of the tables of
    contents at the end of the units' prefaces.

    A hyphen `-' character, on the other hand, disables the automatic
    insertions of the local tables.

    In case of a single argument, the command removes the
    existing definition of \Toc#1.


    The definition  of the local table of contents can be redefined
    within \csname Toc#1\endcsname.



       \Css{div.sectionTOCS {
                           width : 30\%;
                           float : right;
                      text-align : left;
                  vertical-align : top;
                     margin-left : 1em;
                       font-size : 85\%;
                background-color : \#DDDDDD;

    Example: Table of content before the section title.

          {\Tocsection \let\saveTocsection=\Tocsection
           \ifvmode \IgnorePar\fi \EndP\IgnorePar
           \HCode{<h3 class="sectionHead">}\TitleMark\space\HtmlParOff}
          {\HCode{</h3>}\HtmlParOn\ShowPar \IgnoreIndent \par}


   #1 before the tables of contents
   #2 after the tables of contents
share|improve this answer
that was it ! thanks. I was very close :) it will be nice if there is an explanation to how to use these TocAt and \ConfigureToc. I am sure they are explained somewhere. Actually what we need is a book on tex4ht. As it has so many options and configurations, hard to keep up with it has. Many things scattered all over the net about it in different documents with different dates and such.... – Nasser May 28 '13 at 14:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.