8

I am preparing a book which will be printed in two separate volumes, and I'd like to show in the ToC the full content in both, either in two separate ToCs (Index for Volume I / Index for Volume II), or as a single ToC where the volume number becomes an unnumbered part which contains chapters and sections for that book.

I have looked around, but I can't find an answer. I am using memoir if it makes any difference.

1 Answer 1

7

This should work. Suppose the other volume is named volumetwo and the file volumetwo.toc already exists.

\makeatletter
\def\tableofcontentsfrom#1#2{
\section*{#2\@mkboth{\MakeUppercase#2}{\MakeUppercase#2}}%
\begingroup\makeatletter%
  \@input{#1.toc}%
\endgroup%
}
\makeatother

\tableofcontentsfrom{volumetwo}{Contents of Volume 2}

(It is a modification of original \tablofcontents and \@starttoc macros.)

Automated variant with one long TOC for both volumes (I just hadn't automated the choice of the top-level according to book/report/article class)

\makeatletter
\def\gentoc#1{
\section*{#1\@mkboth{\MakeUppercase#1}{\MakeUppercase#1}}%
\begingroup\makeatletter%
 \let\l@toplevel\l@part%    use for BOOK class
% \let\l@toplevel\l@chapter% use for REPORT class
% \let\l@toplevel\l@section% use for ARTICLE class
\let\l@part\l@chapter%
\let\l@chapter\l@section%
\let\l@section\l@subsection%
\let\l@subsection\l@subsubsection%
}
\def\endgentoc{%
\endgroup%
}
\def\gentocfile#1#2{\l@toplevel{#1}{0}\@input{#2.toc}}
\makeatother

...

\begin{gentoc}{Complete Table of Contents}
\gentocfile{First volume}{volumeone}
\gentocfile{Second volume}{volumetwo}
\end{gentoc}
10
  • Thanks a lot, I'll try it in a couple of hours and report back.
    – ludoo
    Jan 24, 2012 at 11:12
  • Neat suggestion, though you may want to insert a \makeatother command following the \endgroup statement.
    – Mico
    Jan 24, 2012 at 12:59
  • @Mico: Sorry, but I don't catch what you mean. The example I provided is fully operational.
    – yo'
    Jan 24, 2012 at 13:02
  • 2
    @Mico -- in the example, \makeatletter is after \begingroup, so it will just disappear at the \endgroup. Jan 24, 2012 at 13:53
  • 1
    In the end I went with a slightly different approach: each volume will have its own detailed toc, but before that I will place a general toc that includes volume I/II as parts, and each book's chapters skipping sections, using a hand-edited file. \makeatletter \def\pianoDellOpera#1{ \section*{#1\@mkboth{\MakeUppercase#1}{\MakeUppercase#1}}% \begingroup\makeatletter% \@input{piano_dell_opera.toc}% \endgroup% } It's exactly what I needed, thanks to everybody who contributed to this thread!
    – ludoo
    Jan 25, 2012 at 10:30

You must log in to answer this question.

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