It's my first question here. Sorry if it doesn't follow the rules.
I have:
I'm writing a manual in the book class with pdflatex (TeX Live under Linux). Each chapter is stored in a separate tex-file (chapter1.tex, chapter2.tex).
Also I'm using minitoc package for creating the table of contents for each part. The commands for generating the main table of contents and the table of contents for each part are stored in separate tex-files too (maintoc.tex, parttoc.tex).
I need:
After compiling the whole document I am using \includeonly for obtaining separate pdf-files (thanks to post). Using hyperref and zref-xr packages I get correct hyperlinks between different pdf's corresponding to different chapters, but links in the main table of contents and in the table of contents for each part are broken.
Minimal working example:
main.tex:
\documentclass[12pt,oneside]{book}
\usepackage{minitoc}
\usepackage{hyperref}
\ifdefined\tosplit
\usepackage{zref-xr}
\zxrsetup{toltxlabel}
\fi
\begin{document}
\include{maintoc}
\include{parttoc}
\include{chapter1}
\include{chapter2}
\end{document}
maintoc.tex:
\doparttoc
\tableofcontents
parttoc.tex:
\part{The first and last part}
\parttoc
chapter1.tex:
\ifdefined\tosplit
\zexternaldocument*{chapter2}
\fi
\chapter{The first chapter}
\label{chap:first}
See chapter~\ref{chap:second}.
chapter2.tex:
\ifdefined\tosplit
\zexternaldocument*{chapter1}
\fi
\chapter{The second chapter}
\label{chap:second}
See chapter~\ref{chap:first}.
The sequence of commands I use:
- pdflatex -jobname=tmp main && mv tmp.pdf main.pdf (x2)
- pdflatex -jobname=tmp "\def\tosplit{1}\includeonly{maintoc}\input{main}" && mv tmp.pdf maintoc.pdf
- pdflatex -jobname=tmp "\def\tosplit{1}\includeonly{parttoc}\input{main}" && mv tmp.pdf parttoc.pdf
- pdflatex -jobname=tmp "\def\tosplit{1}\includeonly{chapter1}\input{main}" && mv tmp.pdf chapter1.pdf
- pdflatex -jobname=tmp "\def\tosplit{1}\includeonly{chapter2}\input{main}" && mv tmp.pdf chapter2.pdf
I tried advice from the author Heiko Oberdiek of hyperref and zref packages. Honestly, it is not clear for me, but it works unless you have just two pdf's (TOC and the rest), otherwise it doesn't. It always tries to open just one pdf, but I have many of them.