# Appendix and cross-referencing

first my code: (I added all packages I'm currently using)

\documentclass[12pt,a4paper,notitlepage]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage[toc,page]{appendix}
\usepackage[onehalfspacing]{setspace}
\usepackage{hyperref}
\usepackage{chngcntr}
\usepackage{tabularx}
\usepackage{array,booktabs}
\usepackage{multirow}
\usepackage{bm}
\usepackage{setspace}
\usepackage{threeparttable}

\begin{document}

\chapter{Text}

Here is a chapter with text where I want to make a reference to Appendix A. Lets try the reference: Here a reference to Appendix \ref{appendix:a} and a reference to Appendix B namely Appendix \ref{appendix:b}.

\appendix
\chapter{Appendix A}
\label{appendix:a}
This is the content of the appendix A.
\chapter*{Appendix B}
\label{appendix:b}
This is the content of the appendix B.

\end{document}


This example has a perfectly fine reference for Appendix A. However, the title for Appendix A is done twice. Once due to \chapter{Appendix A} and once as the \chapter{Appendix A} is the first entry for the appendix. Furthermore, \appendix changes numerical references to alpha references.

Obviously adding the * for the appendix B removes the additional title, hence makes propper referencing impossible.

Anyone got an idea on how to handle this?

I already tried \begin{appendices} ... \end{appendices}, however, for that version the numbering of the appendix chapters were numerical and not "A, B etc "

EDIT: I would prefer the table of content not including the appendix chapters and within the appendices only the Chapter names. However, as mentioned before using \chapter*{chapter_name} makes the reference unusuable.

\documentclass[12pt,a4paper,notitlepage]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage[toc,page]{appendix}
\usepackage[onehalfspacing]{setspace}
\usepackage{hyperref}
\usepackage{chngcntr}
\usepackage{tabularx}
\usepackage{array,booktabs}
\usepackage{multirow}
\usepackage{bm}
\usepackage{setspace}
\usepackage{threeparttable}

\begin{document}
\tableofcontents
\chapter{Text}

Here is a chapter with text where I want to make a reference to Appendix A. Lets try the reference: Here a reference to Appendix \ref{appendix:a} and a reference to Appendix B namely Appendix \ref{appendix:b}.

\begin{appendices}
\chapter*{Appendix A}
\label{appendix:a}
This is the content of the appendix A.
\chapter*{Appendix B}
\label{appendix:b}
This is the content of the appendix B.
\end{appendices}
\end{document}

• The \appendix command does just rename the chapter name to Appendix, so it's no wonder that \Appendix A appears twice, since you used this as the title as well. And it's \begin{appendices}...\end{appendices}
– user31729
Mar 21, 2016 at 13:19
• A chapter name in the appendix should be something like additional charts, or material data sheets, or raw data or sourcecode of program. Describing the content, not what it is. It would be equally silly to call your chapter \chapter{chapter 1}. Mar 21, 2016 at 13:21
• @ChristianHupfer thank you for correcting and replying. And yes you both are right. What I did before could not give me the wished result. Before I used \appendix I had used \begin{appendices}...\end{appendices}, however I was not able to create a propper looking reference as the numbering of the appendix section was numerically. Mar 21, 2016 at 14:43
• @Claude: I still don't understand what's the issue here. By default, both \appendix or \begin{appendices}... switch to alpha 'numbering' of appendix chapters or sections.
– user31729
Mar 21, 2016 at 15:09
• @ChristianHupfer: I added a new example. It shows the output for the table of contents and the look of the appendix as I would prefer it. However, the references are not working anymore due to \chapter*{}. Mar 22, 2016 at 17:50

Doubling Appendix A etc. is due to wrong usage of \chapter{Appendix A} -- but it can be removed (but why naming it this way, if it could be done automatically?) -- anyway, I removed the \chaptername header line of the the chapter title by redefinition of \@makechapterhead.

The removal of appendix chapters from the ToC can be achieved by using \addtocontents{toc}{\protect\setcounter{tocdepth}{-2}} after the appendices environment has started.

\documentclass[12pt,a4paper,notitlepage]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage[toc,page]{appendix}
\usepackage[onehalfspacing]{setspace}
\usepackage{chngcntr}
\usepackage{tabularx}
\usepackage{array,booktabs}
\usepackage{multirow}
\usepackage{bm}
\usepackage{setspace}
\usepackage{threeparttable}

\usepackage{xpatch}
\usepackage{hyperref}

\makeatletter
\AtBeginEnvironment{appendices}{%
% Removing the entries to the toc within appendices environment with \setcounter{tocdepth}{-2}
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
% \ifnum \c@secnumdepth >\m@ne
% \huge\bfseries \@chapapp\space \thechapter
% \par\nobreak
% \vskip 20\p@
% \fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Text}

Here is a chapter with text where I want to make a reference to Appendix A. Lets try the reference: Here a reference to Appendix \ref{appendix:a} and a reference to Appendix B namely Appendix \ref{appendix:b}.

\begin{appendices}
\chapter{Appendix A}
\label{appendix:a}
This is the content of the appendix A.
\chapter{Appendix B}
\label{appendix:b}
This is the content of the appendix B.
\end{appendices}
\end{document}

• Thanks for this solution. It works for me! However, I agree with you that what I asked seems strange. What would be the correct usage of \appendix or \begin{appendices}...\end{appendices} if you only need one name for each chapter (or section) names for the appendix. In other words, if the title name Appendix A and Appendix B is enough as names for the appendix parts. I dont want to have Appendix A with chapter name Part A appendix A , Appendix B with chapter name Part A appendix B. Mar 23, 2016 at 10:37