5

To simplify the management of multiple books, I put all of them together into them together into one file, then used \cleardoublepage, \setcounter{page}{1} and a new titlepage environment to specify the beginning of the second document.

\documentclass{book}
\begin{document}
    \begin{titlepage}
        This is the first title page.
    \end{titlepage}
    \tableofcontents
    \chapter{This chapter should appear in the first title page}

    \cleardoublepage
    \setcounter{page}{1}
    \begin{titlepage}
        This is the second title page.
    \end{titlepage}
    \tableofcontents
    \chapter{This chapter should appear in the first second page}
    \chapter{This chapter should also appear in the first second page}
\end{document}

However, the first tableofcontents loads displays all chapters and the second tableofcontents shows no chapters.

  • Is \cleardoublepage and \setcounter{page}{1} the proper way to reset the document?
  • How can I have more than one table of contents within the same file?
Village
  • 13,603
  • 23
  • 116
  • 219
  • LaTeX way of creating a table of contents is to write a line for each TOC entry into a file named \jobname.toc. (I.e. every time a \section or so is encountered.) The \tableofcontents macro basically (via the \@starttoc macro) reads in that file and clears it afterwards. Therefore, you can't "abuse" the \tableofcontents for your purpose. – 5gon12eder Dec 17 '11 at 01:54
  • 1
    It might be a better solution to have them in different files and then join only the pdfs with the iad of the pdfpages package. PS. It's a pity that you deleted your question about "omitting" once-used counters: this is something many people might find useful, I was just about to start coding that;). – mbork Dec 17 '11 at 02:00
  • The titletoc package, for example, would let you have multiple independent ToCs, but simply resetting the page counter will produce problems with hyperref (the typical pdfTeX warning (ext4): destination with the same identifier (name{page.4}) has been already used, duplicate ignored warnings). It's better to work on different .tex files and possibly use xr or to use memoir (as suggested in another of your questions). – Gonzalo Medina Dec 17 '11 at 02:12
  • 1
    Oh, sorry, I thought that question was not a good question because I found inparaenum does what I needed. Now, I see maybe others need that too. I have reposted the question. – Village Dec 17 '11 at 02:12

1 Answers1

7

The titletoc package provides the tools that you want using \startlist{toc} and \printlist{toc}.

See Section 7.4 of the documentation for more details- a complete MWE follows.

\documentclass{book}
\usepackage{titletoc}

\begin{document}

\begin{titlepage}
        This is the first title page.
\end{titlepage}

\startlist{toc}
\printlist{toc}{}{\section*{My first toc}}
\chapter{This chapter should appear in the first title page}

\cleardoublepage
\setcounter{page}{1}
\begin{titlepage}
       This is the second title page.
\end{titlepage}

\startlist{toc}
\printlist{toc}{}{\section*{My second toc}}

\chapter{This chapter should appear in the first second page}
\chapter{This chapter should also appear in the first second page}

\end{document}
cmhughes
  • 100,947