2

I have a document with a single appendix chapter. Latex is numbering this as "Appendix-Chapter A". But because it is my only appendx chapter, I want only to show "Appendix-Chapter".

Current source:

\documentclass[chapterprefix=true]{scrbook}

\begin{document}
\tableofcontents
\chapter{Test}
\appendix
\chapter{Algorithm}

\end{document}

Results in:

Contents
 1. Test      3
 A. Algorithm 5

Chapter 1.
Test

Appendix A.
Algorithm

Wished result

Contents    
 1. Test     3    
 Algorithm   5

Chapter 1
Test

Appendix
Algorithm
0
4

The simplest way would be to use

\addchap{Algorithm}

instead of

\chapter{Algorithm}

In this way, you have an unnumbered chapter with a ToC entry. However, it does not exactly what you want.

If you want to obtain this, add the following lines in your preamble:

\usepackage{etoolbox}

\makeatletter
\appto\appendix{%
  \renewcommand*{\chapterformat}{%
    {\chapapp\autodot\enskip}%
  }
  \renewcommand*{\chaptermarkformat}{%
    {\chapapp\autodot\enskip}%
  }
  \patchcmd{\@chapter}%
    {\addchaptertocentry{\thechapter}{\scr@ds@tocentry}}%
    {\addchaptertocentry{}{\scr@ds@tocentry}}%
    {}
    {}
}
\makeatother

MWE (I've added the option numbers=noenddot since it seems that you want to use it):

\documentclass[chapterprefix=true,numbers=noenddot]{scrbook}

\usepackage{etoolbox}

\makeatletter
\appto\appendix{%
  \renewcommand*{\chapterformat}{%
    {\chapapp\autodot\enskip}%
  }
  \renewcommand*{\chaptermarkformat}{%
    {\chapapp\autodot\enskip}%
  }
  \patchcmd{\@chapter}%
    {\addchaptertocentry{\thechapter}{\scr@ds@tocentry}}%
    {\addchaptertocentry{}{\scr@ds@tocentry}}%
    {}
    {}
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Test}
\appendix
\chapter{Algorithm}

\end{document} 

Output (ToC):

enter image description here

Output (Appendix):

enter image description here


EDIT

If you are using hyperref this is the stuff to be added in the preamble:

\usepackage{etoolbox}

\makeatletter
\appto\appendix{%
  \renewcommand*{\chapterformat}{%
    {\chapapp\autodot\enskip}%
  }
  \renewcommand*{\chaptermarkformat}{%
    {\chapapp\autodot\enskip}%
  }
  \patchcmd{\Hy@org@chapter}%
    {\addchaptertocentry{\thechapter}{\scr@ds@tocentry}}%
    {\addchaptertocentry{}{\scr@ds@tocentry}}%
    {}
    {}
}
\makeatother

MWE

\documentclass[chapterprefix=true,numbers=noenddot]{scrbook}

\usepackage{hyperref}

\usepackage{etoolbox}

\makeatletter
\appto\appendix{%
  \renewcommand*{\chapterformat}{%
    {\chapapp\autodot\enskip}%
  }
  \renewcommand*{\chaptermarkformat}{%
    {\chapapp\autodot\enskip}%
  }
  \patchcmd{\Hy@org@chapter}%
    {\addchaptertocentry{\thechapter}{\scr@ds@tocentry}}%
    {\addchaptertocentry{}{\scr@ds@tocentry}}%
    {}
    {}
}
\makeatother

\begin{document}
\tableofcontents
\chapter{Test}
\appendix
\chapter{Algorithm}

\end{document} 

Output (ToC):

enter image description here

2
  • This solution don't work in combination with hyperref :( – SunBlack Mar 9 '15 at 16:59
  • @SunBlack See the edit. – karlkoeller Mar 9 '15 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.