[Tex/LaTex] Cross referencing between chapters of a thesis

cross-referencinghyperref

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}
\addbibresource{references.bib}
\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 ?

Many thanks in advance.

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.

Best Answer

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.)

Related Question