# Split a book into multiple volumes

I have a book with 15 chapters and a table of contents. I have been asked to repackage it as two separate volumes, one including Chapters 0-9 and the second including Chapters 9-14 (yes, Chapter 9 is in both volumes). I would like the page numbering in volume II to continue from volume I, and I would like the TOC for each volume to contain only the items that are actually in that volume.

This seems fairly easy, except that I don't know how to make the page numbering in volume II start in the right place without including the aux files from volume I, thereby putting those in the volume II TOC as well.

I'm sure this is a simple problem, but I can't find any help on google (or here). I am using the book document class, and it's probably too late to change to memoir.

• If your book is fairly static you can just use \setcounter{page}{998} in the second volume, or do you want a way to pick up the number automatically whenever you edit the first volume? May 2 '13 at 15:18
• Maybe the xr package could be used. May 2 '13 at 15:21
• not a direct answer, but some other facets of the multi-volume situation are addressed in Managing volumes of books. May 2 '13 at 15:44
• @DavidCarlisle If necessary I can use this, but I would really prefer a way to automatically pick up the page number. If there were a way to just clear out all of the entries in the toc but remember where you were, that would work. But it sounds like there's not. May 2 '13 at 17:14
• I played around with \includeonly and \chapter* followed by \addcontentsline to get Volume 2 pagination without toc entries. It seems as if \section* does what you want but \chapter* doesn't. No time to hack more now. Maybe someone else can take this (or another idea) further. May 2 '13 at 18:33

Here are two answers. (You've already said you don't like the second one; I'm leaving it because someone might find it useful some day.)

First:

With this TeX source

\documentclass{book}

\usepackage{etoolbox}
\newtoggle{volumeone}

%\toggletrue{volumeone}
\togglefalse{volumeone}

\iftoggle{volumeone}{
\includeonly{ch1,ch2}
}{
\includeonly{ch2,ch3}
}

\begin{document}
\tableofcontents
\include{ch1} % \chapter{one} contents
\include{ch2} % \chapter{two} contents
\include{ch3} % \chapter{three} contents
\end{document}


run pdflatex several times (to stabilize all references). Here is book.toc:

\contentsline {section}{\numberline {1.1}one}{4}
\contentsline {section}{\numberline {1.2}two}{4}
\contentsline {chapter}{\numberline {2}two}{5}
\contentsline {section}{\numberline {2.1}one}{5}
\contentsline {section}{\numberline {2.2}two}{5}
\contentsline {chapter}{\numberline {3}three}{7}
\contentsline {section}{\numberline {3.1}one}{7}
\contentsline {section}{\numberline {3.2}two}{7}


Edit that file, to remove the first two lines (all the references to Chapter one). Then rerun pdflatex once.

This works for me on Windows 7,

\$ pdflatex -version
MiKTeX-pdfTeX 2.9.4535 (1.40.13) (MiKTeX 2.9)


since pdflatex hasn't noticed that the toc file is out of date.

You could automate this workflow with a shell script or batch file, using perl or python or awk to edit the toc.

Second: pagination is right but lots of other things need fixing - headers, chapter counters, references ... . I don't know how.

\documentclass{book}

\usepackage{etoolbox}
\newtoggle{volumeone}

\toggletrue{volumeone}
%\togglefalse{volumeone}

\iftoggle{volumeone}{
\includeonly{ch1,ch2,ch3}
}{
\includeonly{ch3,ch4}
}

\newcommand{\tocline}[1]{%
}

\newcommand{\mychapter}[1]{%
%do everything the actual \chapter
%command does except enter a line in
}

\newcommand{\mysection}{%
%check volumeone toggle, omit from toc as approprate
}

\begin{document}

\tableofcontents

\mychapter{one}
\iftoggle{volumeone}{\tocline{one}}{}
\include{ch1} % contents of chapter one in ch1.tex

\mychapter{two}
\iftoggle{volumeone}{\tocline{two}}{}
\include{ch2}

\mychapter{three}
\tocline{three} % in both volumes
\include{ch3}

\mychapter{four}
\iftoggle{volumeone}{}{\tocline{four}}
\include{ch4}

\end{document}


toggle the toggle

• Huh. Presumably you could \setcounter{chapter}{whatever} inside the if/then/else as well so that chapter headings would be OK and you wouldn't even need the tocline commands (there are chapter commands in each chapter). This is nice, it's too bad that it requires an internal switch. But no reason you couldn't turn this into two separate tex files, each setting the switch a different way. May 4 '13 at 0:46
• NM. This unfortunately requires the manual tocline commands to avoid printing the whole toc in both volumes. Probably not acceptable. May 4 '13 at 0:52