# Cross referencing between chapters of a thesis

Hi I am new to the forum and fairly new to Tex, if I miss anything out please let me know and I will be glad to post it. I am writing up my PhD thesis using Texmaker on a windows system. I have my document organised with a main file and a sub-directory containing chapter 1 to 5. I want to be able to use the labels I created in chapter two for example in the appendix and vice versa. Is there an easy way to do this?

I have tried following the advice of various posts of including the commands \usepackage{xr} and \externaldocument{Chapters/Chapter_2} in the individual chapters but this leads to an error when compiling.

My Preamble is as follows:

\documentclass[12pt,hidelinks,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[greek,spanish,english]{babel}
\usepackage{textgreek}
\usepackage[version=3]{mhchem}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}
\usepackage{amsmath, amsfonts, pifont, float, color, url}
\usepackage[pdftex]{graphicx}
\usepackage[style=numeric,backend=biber,sorting=none]{biblatex}
\usepackage[pdftex, plainpages=false, pdfpagelabels, bookmarks=true]{hyperref}
\usepackage{fancyhdr}
\usepackage[center,font={it,small}]{caption}


I then have a section such as this in the main document:

\begin{document}
%%... Title page ...
\chapter{Theory and Methods}
\label{chap:Theory and Methods}
\include{Chapters/chapter_2}
%%... Other chapters ....
\end{document}


In Chapter 2 I have for example a label for a diagram which I may want to reference in other chapters:

\begin{figure}[H]
\centering
\includegraphics[height=10cm,width=\textwidth]{RF_colour_hi_res.pdf}
\caption{Random Forest}
\label{fig:2.1 Random Forest}
\end{figure}


How can I have this label show up in other chapters after I type \ref ?

If any other information is required please let me know.

This has been answered in the comments although the references do not appear in the auto complete if they are copied and pasted in they still work.

• Hi, welcome to TeX.SX. Using \ref{fig:2.1 Random forest} should work fine in other chapters, even if the autocompletion doesn't show up. – Torbjørn T. Apr 8 '14 at 17:10
• If you have just one main file, which includes various other files that contain the individual chapters, there's no need to do anything special to get cross-referencing going. Just be sure to use not to use duplicate labels. – Mico Apr 8 '14 at 17:14
• You don't want \chapter{Title}\include{file}, because \include always inserts a page break. The break is not inserted if you use \input instead of \include. – egreg Apr 8 '14 at 17:36
• Thanks for your comments Torbjørn T and Mico I thought the references would appear in the auto complete if they were available, but you are correct if I just paste them in then they work. Thanks for your answers. @egreg thank you for the tip that is very helpful. – James Apr 9 '14 at 15:01
• You might not want to hard code the 2.1 in \label{fig:2.1 Random Forest} since the figure number can change if you move things around. Use your label to describe the figure, not its placement. – Ethan Bolker Apr 21 '14 at 14:48

Even if Texmaker doesn't pick up the labels from other \included files, using the label will still work, so \ref{fig:2.1 Random forest} should give the correct figure number, regardless of what subfile you're in.

(By the way, xr is not what you want. That is for adding references to completely separate documents, you are adding a reference within the same document.)