How to add chapter name to number and title line in Appendices

appendiceschaptersnamingtitlesec

Consider test case:

\documentclass{report}
\usepackage[title,titletoc]{appendix}

\usepackage{titlesec}
\titleformat{\chapter}{\normalfont\LARGE\bfseries}{\thechapter}{10pt}{}


\begin{document}
\tableofcontents

\chapter{Test1}
\section{Test1.1}

\begin{appendices}
% I need Appendix added to "chapters" here.
\chapter{Test2}
\end{appendices}
\end{document}

Chapter names were removed using \titleformat. But for all chapters in Appendices need to add chapter name to chapter number and title. Mean need to change A Test2 to Appendix A Test2. How to do this?

Best Answer

You can add another \titleformat change within the appendices environment:

enter image description here

\documentclass{report}

\usepackage[title,titletoc]{appendix}

\usepackage{titlesec}
\titleformat{\chapter}{\normalfont\LARGE\bfseries}{\thechapter}{10pt}{}

\begin{document}

\tableofcontents

\chapter{Test1}
\section{Test1.1}

\begin{appendices}
\titleformat{\chapter}{\normalfont\LARGE\bfseries}{Appendix \thechapter}{10pt}{}
\chapter{Test2}
\end{appendices}

\end{document}

With an up-to-date LaTeX, you can add

\AddToHook{env/appendices/begin}{%
  \titleformat{\chapter}{\normalfont\LARGE\bfseries}{Appendix \thechapter}{10pt}{}%
}

to your preamble so you don't have to add it mid-document. Environment (and other) hook management has formed part of the LaTeX kernel since Oct 2020. Update your distribution if this doesn't work out-of-the-box (as it should).