[texhax] Index in Table of Contents

Ramamoorthi Bhaskar bhaskar51 at gmail.com
Mon May 31 05:00:06 CEST 2010


I think I have a solution.

Just before the *\printindex* command, I inserted the command *\newpage* and
then the command* \addcontentsline{toc}{chapter}{\protect\numberline{}Index}
*

That seems to produce a Table of Contents with the correct page number for
the Index without forcing a page break for the index.

I hope this is a stable solution.

R. Bhaskar

106 Larchwood Drive
Cambridge, MA 02138
617-501-2110



On Sun, May 30, 2010 at 2:19 PM, Barbara Beeton <bnb at ams.org> wrote:

>     I've been trying to generate a table of contents entry that includes
> the
>    Index.  The standard \printindex produces a gorgeous Index of course.
>  But
>    neither \*printindex* nor an* \addcontentsline{toc}{chapter}{\numberline
>    ~Index}* produce an entry for Index in the Table of Contents.  All the
>    other entries in the Table of Contents are at the Chapter Level only.
>    Any suggestions, please?
>
> try this.
> determine the correct page number for the
> first page of the index, and substitute it
> for NN in this line:
>
>  \addtocontents{toc}{chapter}{Index}{NN}
>
> insert this directly *before* \printindex .
>
> the "standard" latex document classes don't
> insert the titles of starred (unnumbered)
> chapters in the t-of-c.  \printindex reads
> in the .ind file with the assumption that
> the index entries are wrapped in
>  \begin{theindex}
>  ...
>  \end{theindex}
> and the generation of a contents line would
> be triggered in the processing of the \begin
> expansion.  if you add the line after
> \printindex, it would still be okay as long
> as you explicitly give the correct page
> number, but if you use \addcontentsline and
> expect an automatic page number, that will
> be incorrect.  of course, you can fiddle with
> the page counter and make it work automatically,
> but it's really a pain.
>
> the ams document class amsbook.cls *does*
> include all unnumbered chapters and sections
> in the t-of-c.  this is a design decision.
> if you have the determination to look at the
> code, you will find the difference in the
> definitions of \@schapter in amsbook.cls
> and book.cls; compare these with the defs
> of \@chapter.
>
>    I have a feeling this is a dumb question, but I can't find the source
> files
>    for the Mittleback and Goosens Latex Companion which does have an entry
> for
>    the Index in the Table of Contents!
>
> you won't be able to find those source files.
> the latex companion is copyright, and not
> public.  the fact that the source file for
> the texbook is public is owing to the
> unusual generosity of don knuth; however,
> please note that it should not be tex'ed
> without explicit permission (which has been
> granted only for purposes of timing tests
> and validation of tex implementations on
> various platforms, with the output not to
> be distributed).
>                                                 -- bb
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20100530/2402c682/attachment.html>


More information about the texhax mailing list