3

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.

 foo.tex:
 \documentclass[]{article}%
 \begin{document}
 \tableofcontents
    \section{A}
    \section{B}
      \subsection{B1}
      \subsection{B2}
      \subsection{B3}
    \section{C}
 \end{document}

 foo.cfg:        
 \Preamble{xhtml,mathml,NoFonts,ext=htm,charset="utf-8"}
    \ConfigureToc{chapter}{section}{}{}{} %?
  \begin{document}
  %\TocAt{chapter,section} ?
  \EndPreamble

 command:
 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?

1 Answer 1

4

Try this foo.cfg

\Preamble{xhtml,mathml,NoFonts,ext=htm,charset="utf-8"}
  \begin{document}
  \TocAt{section,subsection}
  \EndPreamble

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

Edit

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>}


   Example:

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


\Configure{TocLink}..................4

   Configures the link offered in the third arguments of \ConfigureToc

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

\TocAt{#1,#2,#3,...}

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

    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.

    Example:
      \TocAt{mychapter,mysection,mysubsection,/myappendix,/mypart}
      \TocAt-{mysection,mysubsection,/mylikesection}
      \section{...}...\Tocmysection

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

    Example:

       \TocAt{section}
       \def\Tocsection{\TableOfContents[section]}

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

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


\Configure{TocAt}......................2
\Configure{TocAt*}.....................2

   #1 before the tables of contents
   #2 after the tables of contents
1
  • 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
    Commented May 28, 2013 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .