[Tex/LaTex] Split a book into multiple volumes

book-designtable of contents

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.

Best Answer

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.

enter image description here

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]{%
\addcontentsline{toc}{chapter}{#1}
}

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

\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}

enter image description here

toggle the toggle

enter image description here

Related Question