I am writing my thesis and need to put 'Appendix' before the numbering (A, B, C, …) in the table of contents (TOC), the chapter title and in the header. I'd also like for \autoref{}
to output 'Appendix A'.
I am using the scrbook class and have tried several different ways to achieve this but nothing gives me the desired output.
I want the title to appear as below so that it reads 'Appendix A (Title)'. This is also how I want it to appear in the TOC and in my header.
I've tried using the KOMA option appendixprefix=true
but this splits Appendix A and More Information onto separate lines and doesn't put 'Appendix' before A in the TOC.
I've tried redefining \thechapter
with \renewcommand{\thechapter}{Appendix \Alph{chapter}
which gives me the desired output in the title and header of my document but the table of contents output is below and \autoref{}
's output is 'Appendix Appendix A'.
I've tried the appendix package too but this won't add Appendix to the title in the main body, only to the TOC.
I've also tried some other hacks which work in both the TOC and the title but then show the previous chapter in the header.
I set my headers using the following
\usepackage{fancyhdr}
\setlength{\headheight}{15pt}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{ \markboth{\thechapter~#1}{} } % Adds chapter number name to right header
\renewcommand{\sectionmark}[1]{ \markright{\thesection~#1}{} } % Adds section name to left header
I'd really appreciate some help with this as I can't find a solution which works for my 3 main cases of title, TOC and header using the scrbook class.
MWE:
\documentclass[12pt,a4paper,oneside,pointlessnumbers]{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{fancyhdr}
\usepackage[colorlinks]{hyperref}
\setlength{\headheight}{15pt}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{ \markboth{\thechapter~#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{\thesection~#1}{} }
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\blinddocument
\appendix
\chapter{More Information} \label{app:first}
\section{Another Section}
\autoref{app:first}
\Blindtext
\end{document}
Best Answer
Add the following lines to your preamble:
With
\g@addto@macro
we add to the command\appendix
the following modifications:\chapterformat
so to add the word "Appendix" before the chapter number.\chaptermarkformat
so to add the word "Appendix" before the chapter number in the header.\addcontentsline
only for the\chapter
command, so to add the word "Appendix" in the ToC also.The command
\autoref
works as expected.MWE:
Output (ToC)
Output (An appendix)