3

The new book I translate is composed by two volumes A and B. Each volume must have its own index and table of contents and page numbering starting from 1 but of course the cross references between the two volumes must be valid. Lets say that the whole book has (as an example) 8 chapters and each volume includes 4 chapters (Volume A includes Chapters 1, 2, 3 and 4, and Volume B includes Chapters 5, 6, 7 and 8). I have two files VolumeA.tex and VolumeB.tex with the following (minimal) contents:

VolumeA.tex

\includeonly {Chapter01,Chapter02,Chapter03,Chapter04} \begin{document} \include{Chapter01} \include{Chapter02} \include{Chapter03} \include{Chapter04} \include{Chapter05} \include{Chapter06} \include{Chapter07} \include{Chapter08} \end{document}

VolumeB.tex

\includeonly {Chapter05,Chapter06,Chapter07,Chapter08}
\begin{document}
\include{Chapter01}
\include{Chapter02}
\include{Chapter03}
\include{Chapter04}
\include{Chapter05}
\include{Chapter06}
\include{Chapter07}
\include{Chapter08}
\end{document}

In order to get valid cross references I compile each volume with the corresponding \includeonly in comments, for example

%\includeonly {Chapter01,Chapter02,Chapter03,Chapter04}

in order to create the associated aux files and then with this line enabled (namely without the comment) in order to create the pdf with the appropriate four files (I use xelatex under MikTEX / Windows 10). Even though i get the correct result, I noticed that:

  1. The table of contents in each volume contains all eight chapters and not only the appropriate four chapters of this volume.
  2. The produced subject index is the index of the whole book and not of the associated volume.
  3. The page numbering in the two volumes is continuing. I can solve this problem by using the command \setcounter{page}{1} in the first file of VolumeB but this affects the TOC (of course if I solve the first problem there is no problem, after all, the numbering in Volume B from the beginning is a desired feature) and furthermore, the index uses the continuous numbering.

Is it possible to eliminate the above problems and get the situation described in the beginning of the question, or this is just the way LaTEX works and I have to adopt this with the appropriate corrections?

  • 1
    \include and \includeonly is probably the wrong tool here that is really just for temporary draft versions that quickly process one chapter in a larger work. I would process as two separate documents, and use xr or similar package to cross refrence between them. – David Carlisle May 21 '22 at 18:48

1 Answers1

4

You need to stop almost everything \include is designed to do. So here I would not use \includeonly to make the volumes (you can still use it to make quick drafts of one chapter while you are editing)

Use two separate documents using xr package to manage \label and \ref

volumea.tex

\documentclass{book}
\usepackage{xr}
\externaldocument{volumeb}

\begin{document} \include{Chapter01} \include{Chapter02} \include{Chapter03} \include{Chapter04}

\end{document}

volumeb.tex

\documentclass{book}
\usepackage{xr}
\externaldocument{volumea}

\begin{document}

\include{Chapter05} \include{Chapter06} \include{Chapter07} \include{Chapter08} \end{document}

You will still be able to\ref in one volume to a \label in the other.

David Carlisle
  • 757,742
  • I suppose that VolumeA.tex and VolumeB.tex should be in the same directory since as far as I understand they use the same AUX files. – Athanasios Margaris May 21 '22 at 19:42
  • 1
    @AthanasiosMargaris if they are not you have to adjust the \externaldocument path, but simplest if they are, which is how I assumed you have it now as you were sharing aux files already. – David Carlisle May 21 '22 at 20:07