[Tex/LaTex] Referencing wrong appendix in chapter. Should reference A.1 instead references A

appendicescross-referencing

My problem is when I reference a piece of document which is in my appendix it states the wrong one in my chapter content. I.e blah blah in 'A'. When it should be 'A.1'. Every document in the appendix is behind by 1 in relation to the main content of my piece of work. However its weird, addtocontents in the main.tex file it shows in order. A.1, A.2, A.3 etc. But like I said it should start from A.1 and not A like it shows in my contents page.

%----------------------------------------------------------------------------------------
%   DISSERTATION CONTENT - CHAPTERS
%----------------------------------------------------------------------------------------

\mainmatter % Begin numeric (1,2,3...) page numbering

\pagestyle{fancy} % Return the page headers back to the "fancy" style

% Include the chapters of the dissertation as separate files from the Chapters folder
% Uncomment the lines as you write the chapters

\input{Chapters/Chapter1}

%---------------------------------------------------------------------
%   DISSERTATION CONTENT - APPENDICES
%----------------------------------------------------------------------------------------

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices

% Include the appendices of the dissertation as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices

\input{Appendices/AppendixA}
%\input{Appendices/AppendixB}
%\input{Appendices/AppendixC}

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\backmatter

I also have a separate .cls file which holds certain commands. In relation to the appendix this is shown below:

\newcommand{\aref}[1]{Appendix~\ref{#1}}

Example in my main.tex:

\documentclass[11pt, a4paper, oneside]{Thesis}
%All my packages included here

\begin{document}
%All the contents and fancy thesis layout set here. Such as setting the title page, contents page, figures page, table page, chapter, appendices etc. Which will automatically appear.
\end{document}   

My Chapter1.tex starts like this:

\chapter{Analysis}
\label{Analysis}
\lhead{Chapter 2. \emph{Analysis}}

\section{Overview}
The purpose of the Analysis chapter is to analyse different \ref{Web}...

That command \ref{} automatically looks at my AppendixA.tex file to reference the relevant appendice.

My AppendixA.tex starts like this:

% Appendix A
\vspace{2.0em}
\chapter{Appendix} % Main appendix title


\lhead{\emph{Terms of Reference}} % This is for the header on each page perhaps a shortened title

\label{TermsofReference} % Change X to a consecutive letter; for referencing this appendix elsewhere, use \ref{AppendixX}

\section{Terms of Reference}

Therefore I use the \ref{} command and stick the relevant content thats within the parenthesis of the \label{} command.

Can anyone help me please, as this is really annoying. When anyone was to read my piece of work they will always be looking at the wrong document in my appendix. Sorry I am quite new to LaTeX and used a Thesis template to help me.

Best Answer

If you want to refer to section Terms of Reference, place the label after \section{Terms of Reference}.

Related Question