[Tex/LaTex] Appendix reference numbers and titles


My issue is related to adding the Appendix using \chapter. I am defining Appendix as follows:

\chapter{My Appendix Title} % Main appendix title
% My Appendix content here. 

Calling it in the main.tex using


Referring it in any other chapter like

the system is further detailed in Appendix~\ref{app:AppendixTemplate}

Now Questions:

  1. the TOC only shows, "My Appendix Title" without Appendix A. I want it to be like "Appendix A. My Appendix Title".

  2. In another chapter, where it is cited it output is "the system I further detailed in Appendix 1." It should be "the system I further detailed in Appendix A."

Best Answer

The following MWE works for a book.

\usepackage{lipsum} % to generate filler text
\setlength\cftsecnumwidth{72pt} % adds space for the word Appendix
 \renewcommand{\cftsecaftersnum}{.} % if you want a period (or whatever punctuation after the appendix letter


% \mainmatter % removed to shorten the example image
\section{Section Title} 

\gdef\thesection{Appendix \Alph{section}}

\gdef\thesection{Appendix \Alph{section}}