# Formatting Appendix Labels and its TOC Entry in the Report Document Class

I'm using the standard TOC and appendix functionality in a report document class, in PDFLatex. Relevantly, I have

\documentclass{report}

....

\begin{document}

\tableofcontents

...

\chapter{Appendix}
\appendix

\section{Testing the LaTeX Appendix}
\label{app:test1}
hello

\section{Testing Referencing to the Appendix}
\label{app:test2}
goodbye

\end{document}


This creates a TOC which looks like

and an appendix section like

The issue is that the appendix section labels don't have a leading chapter number (e.g. they are .1 instead of 8.1, or better yet, 8.A), but I do like that the appendix sections appear as subsections of Appendix in the TOC.

Clearly this is because I define the appendix sections with \section whilst I'm using the report environment. However, changing my appendix sections to chapters like so...

\chapter{Appendix}
\appendix

\chapter{Testing the LaTeX Appendix}
\label{app:test1}
hello

\chapter{Testing Referencing to the Appendix}
\label{app:test2}
goodbye


makes each of them be treated like independent chapters (save a label change), which muddles up both the TOC...

and the actual appendix sections...

How can I format my TOC and appendix entries like in the former case, though with the correct label numbers? The best outcome would see the appendix labels formatted as 8.A, etc.

Note I have attempted use of the appendix package and the begin{indices} environments with the same results.

Just redefine the \appendix switch in your preamble:

\documentclass{report}
\usepackage[utf8]{inputenc}

\makeatletter
\renewcommand\appendix{\par
\gdef\@chapapp{\appendixname}%
\gdef\thesection{\thechapter.\@Alph\c@section}}
\makeatother

\begin{document}

\tableofcontents
\setcounter{chapter}{7}

\appendix
\chapter{Appendix}

\section{Testing the LaTeX Appendix}
\label{app:test1}
hello

\section{Testing Referencing to the Appendix}
\label{app:test2}
goodbye

\end{document}