I found a solution !

It turned out one can issue these \TocAt{} commands any where in
the document, and modify them between sections/chapters as needed.

Here is a MWE which generates a local TOC for first chapter only,
which is clickable, but no TOC for the second chapter. This works
with tex4ht and pdflatex. The trick is to issue\TocAt{}  BEFORE
start of a chapter or a section you want to control. Since the effect
of these commands starts from the point they are issued. This is the
point I did not know, but by error and trial found it.

You can run this with

pdflatex foo.tex
htlatex  foo.tex  "htm"
htlatex  foo.tex "htm,2"

----------------------
\documentclass{report}%
\usepackage{ifpdf}
\usepackage{lipsum}
\usepackage{minitoc}

\begin{document}

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

\ifx\HCode\undefined
\dominitoc  %only for pdf
\fi

\tableofcontents

\ifx\HCode\undefined \else
\TocAt{chapter,section,subsection}  %do it before chapter
\fi

\chapter{chapter 1}
\ifx\HCode\undefined
\minitoc
\fi

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


\ifx\HCode\undefined
\else
\TocAt{chapter}  %RESET it to NO TOC before chapter
\fi

\chapter{chapter 2}

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

--Nasser

On 8/9/2013 3:10 PM, Nasser M. Abbasi wrote:
Hello;

I am trying to generate table of contents for different pages
in a very large and split document, and also control where the
TOC gets displayed.

Some sections or chapters can be too small to require a TOC, and some
are larger and a TOC will be useful there or I might not want a TOC
at some of them.

The common solution now is to use \TocAt{chapter,section,subsection}
to make a TOC for each chapter which contains entries for sections
and subsections inside that chapter. This works fine. For example,
If one does not want a TOC for each chapter, then \TocAt{chapter} will
do the trick.

The problem is that this method affects the WHOLE document. i.e it
is global. So one can not select which chapter or which section to
have a TOC for like with pdflatex output.

minitoc canbe used for this, but when I tried on a small example, the
minitoc was generated but it had no links. This makes it not
very useful. i.e. the actual entries in the TOC are not clickable
like the main TOC, but contains raw text.

Here is a MWE using minitoc with tex4ht, and below it
is another MWE showing the use of \TocAt{}

htlatex foo.tex "htm,2"

-------------------------------
\documentclass{report}%
\usepackage{ifpdf}
\usepackage{lipsum}
\usepackage{minitoc}

\begin{document}
\title{test minTOC with tex4ht}
\author{me}
\date{\today}
\maketitle
\dominitoc
\tableofcontents

\chapter{chapter 1}
\minitoc  %make TOC only for this chapter
    \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}  % No TOC here
    \lipsum{1}
\section{section 1 under chapter 2}
\end{document}
-------------------------

This below will generate a clickable TOC for each separate
chapter. (but again, I only wanted one for the first chapter
in this example)

htlatex foo.tex "htm,2"
also tried
htlatex foo.tex "htm,2,minitoc<"

----------------------------------
\documentclass{report}%
\usepackage{ifpdf}
\usepackage{lipsum}
\usepackage{minitoc}

\begin{document}
   \ifx\HCode\undefined \else
   \TocAt{chapter,section,subsection}
   \fi

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

\ifdefined\HCode
\else
\dominitoc
\fi

\tableofcontents

\chapter{chapter 1}
\ifdefined\HCode
\else
\minitoc  %make TOC only for this chapter
\fi

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

Is it possible to add full support to minitoc or is there a way
to control TOC per section/chapter level? May be using some
\Configure command I can use where I want to TOC to show up or not?

references:
------------
1. http://tug.org/applications/tex4ht/mn11.html#QQ1-11-55
2. http://www.ctan.org/pkg/minitoc
3. http://tug.org/pipermail/tex4ht/2011q1/000250.html

thank you,
--Nasser


Reply via email to