# Including ToC from second volume in first volume, and vice versa

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.

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

...


• Neat suggestion, though you may want to insert a \makeatother command following the \endgroup statement.
• @Mico -- in the example, \makeatletter is after \begingroup, so it will just disappear at the \endgroup. Jan 24 '12 at 13:53