[Tex/LaTex] Cross-referencing between chapters

cross-referencing

I am writing a thesis. In the main file of the thesis, I have included \usepackage{xr}. Then in Chapter2, I have included \externaldocument{./Chapters/Chapter1} to get access of equations of Chapter1. But I cant. Can anyone help me in this regard?

Best Answer

The xr package is not meant to get references from external files that are included anyway -- it works, but it will complain about the multiply defined labels (unless the optional argument of \externaldocument is used.

Rather use \include or \input. This way the content of files are included and the references are correct anyway!

\documentclass{book}


\begin{document}

In \ref{eq:first} and \ref{eq:second} we will see that

\include{chapterone}


\include{chaptertwo}
\end{document}

chapterone.tex:

\chapter{First chapter}

\begin{equation}
  E=mc^2 \label{eq:first}
\end{equation}

chaptertwo.tex

\chapter{Second chapter}

\begin{equation}
  c^2 = a^2 + b^2 \label{eq:second}
\end{equation}

Other way (but not really useful!):

\documentclass{book}

\usepackage{xr}

\externaldocument[Aext]{chapterone}

\externaldocument[Bext]{chaptertwo}

\begin{document}

In \ref{eq:first} and \ref{eq:second} we will see that

\include{chapterone}


\include{chaptertwo}
\end{document}