# How do I change 'A' to 'Appendix A' in both TOC and title?

I wanna display A as Appendix A in TOC, as shown below.

I tried to add \backmatter before \appendix as shown in this post, but cref{label} will display as Section 1. I also used \renewcommand as suggested in the most posts on this site, but it doesn't make any changes. Here is the source code.

\documentclass[twoside,12pt]{article}

\usepackage{cleveref}

\usepackage[english]{babel}
\usepackage[toc, title]{appendix}
\renewcommand\appendixname{Anexo}
%\renewcommand\appendixpagename{Anexos}
\renewcommand\appendixtocname{Appendix}

\begin{document}

\tableofcontents

\section{The main body of the text}

\appendix
\section{A complete table.} \label{appendix}
Some text.

\end{document}

• Are you sure your readers need that extra word to know the appendix just started? You don't have the word Chapter for all the chapters, right? It is an article document, you don't have Section in front of every section entry, right? Mar 6 '17 at 17:32
• If you want to show "Appendix A" instead of just "A" in the ToC, do you want to show the longer string in the actual section-level header as well?
– Mico
Mar 6 '17 at 17:34
• @Johannes_B, I just wanna show Appendix A in my TOC and left the tile blank, like \section{}. Mar 6 '17 at 17:36
• @Mico An idea comes to my mind. I remove A and put Appendix A into \section{}. Mar 6 '17 at 17:38
• \appendix\section*{Appendix}\addcontentsline{toc}{section}{Appendix} But that isn't a very good thing to do. Mar 6 '17 at 17:39

\newcommand{\appendixnumberline}[1]{Appendix\space}

\let\oldappendix\appendix
\makeatletter
\renewcommand{\appendix}{%
\oldappendix
}
\makeatother


The above replaces the \numberline macro with a new \appendixnumberline while also updating the way sectional unit counter are formatted when setting the section title. All is included at the start of the \appendix as a form of automation.

If you also use \subsection (and lower) within the appendix, some more work needs to be done to exclude their sectional units from also being prepended with Appendix.

I would like to suggest you take a different approach: Instead of overloading any given line in the table of contents, consider inserting a line saying something like "Appendix material" in the ToC right before the first appendix section.

\documentclass[twoside,12pt]{article}
\usepackage[nameinlink]{cleveref} % make \cref look like \autoref

%% Set up some preparatory code -- activated below
%% (see 'The LaTeX Companion,' 2nd. ed., pp. 26f.)
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
{\csname #1@cntformat\endcsname}% enable individual control
}
\makeatother

\begin{document}

\tableofcontents

\bigskip\hrule % just for this example

\section{Uno}
\section{Due}
More text.
\section{Tre}
Still more text.

\appendix
\textbf{Appendix Material}\par}
% Activate preparatory code for section-level headers
\makeatletter