2

I need to number my appendix chapters with letters and show the word "appendix" before the letter both at the beginning of each appendix chapter and in the TOC. Also I need the appendix letter formatted as the chapter numbers

I have been trying several solution both from the KOMA-script manual and from the forum, but nothing works.

I put the appendixprefix=true switch in the \documentclass (as indicated in the manual) but it does not change anything.

I have also tried the solutions suggested here:

Prepend 'Appendix' before 'A' using scrbook

both with and without the appendixprefix=true but they do not work in my case.

Here is my code:

    \documentclass[chapterprefix=true,appendixprefix=true]{scrbook}
\setcounter{secnumdepth}{0}
    \usepackage{xcolor, graphicx}
    \usepackage{geometry}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage[italian]{babel}
    \usepackage{textcomp}
    \usepackage{indentfirst}
    \usepackage{times}
    \usepackage{mathptmx}
    \usepackage{setspace}
    \doublespacing
    
    
    \definecolor{chaptergrey}{rgb}{0.7,0.7,0.7}
    
    \let\raggedchapter\raggedleft
    \addtokomafont{disposition}{\normalfont}
    %\setkomafont{element}{commands}
    \setkomafont{title}{\color{cyan}\LARGE}
    \setkomafont{chapter}{\color{cyan}\LARGE}
    \setkomafont{subtitle}{\color{black}}
    
    \renewcommand*{\chapterformat}{%
        \scalebox{3}{\color{cyan}\thechapter}%
    }
    
    
    \begin{document}
    \author{}
    
    \subject{Linea Guida}
    \title{\textbf{Il trattamento laparoscopico di laparocele e ernie ventrali}}
    \subtitle{}
    \titlehead{}
    
    
    \date{Gennaio 2022}
    
    \frontmatter
    \maketitle
    \tableofcontents
    \chapter{Intro}
    
    
    
    \mainmatter
    \part{Sviluppo della linea guida}
    \chapter{one}
    \chapter{two}
    \part{Quesiti}
    \chapter{three}
    \chapter{four}
    \backmatter
    % bibliography, glossary and index would go here.
\appendix
\chapter{AppendixA}
\chapter{AppendixB}
    
    \end{document}

With:

\renewcommand*{\chaptermarkformat}{%
    {\chapapp\nobreakspace\thechapter\autodot\enskip}%

I was able to have the word "appendix" shown in the TOC (without any space between it and the title, BTW) but not at the beginning of the chapter.

2 Answers 2

3

You have to remove \backmatter. The command is similar to \frontmatter regarding the headings: no numbers!

So it's just \appendix.

3
  • Great, thank you! Jan 1, 2022 at 7:51
  • 1
    Actually, I had just figured out by myself. Now it works after having inserted \makeatletter \g@addto@macro\appendix{% \renewcommand*{\chapterformat}{% {\chapapp\nobreakspace\thechapter\autodot\enskip}% } } \makeatother for adding the word "appendix" in the chapter title. Why the letter in the appendix is smaller than the numbers in the chapters? Jan 1, 2022 at 8:02
  • 1
    @FabioCampanile If the letter in appendix should have the same size as the chapter numbers you have to replace \thechapter by \scalebox{3}{\thechapter}.
    – esdd
    Jan 9, 2022 at 21:29
0

The following suggestion adds the prefix to the appendix chapters in document and in TOC:

\documentclass[chapterprefix=true,numbers=noenddot]{scrbook}
\setcounter{secnumdepth}{\chapternumdepth}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage{indentfirst}

%\usepackage{times}
%\usepackage{mathptmx}
\usepackage{newtxtext}
\usepackage{newtxmath}

\usepackage{textcomp}
\usepackage{setspace}
\doublespacing

\definecolor{chaptergrey}{rgb}{0.7,0.7,0.7}

\let\raggedchapter\raggedleft
\addtokomafont{disposition}{\normalfont}
\setkomafont{title}{\color{cyan}}
\setkomafont{chapter}{\color{cyan}\LARGE}
\setkomafont{subtitle}{\color{black}}
\addtokomafont{partnumber}{\color{cyan}}

\renewcommand*{\chapterformat}{\scalebox{3}{\thechapter}}

\AddToHook{cmd/appendix/after}{%
  \AddToHook{cmd/chapterformat/before}{\chapapp\nobreakspace}%
  \addtocontents{toc}{\appendixtocentry}%
}

\NewDocumentCommand{\appendixtocentry}{}{%
  \DeclareTOCStyleEntry[
    entrynumberformat=\tocappendixnumber,
    dynnumwidth
  ]{tocline}{chapter}%
}
\NewDocumentCommand{\tocappendixnumber}{m}{%
  \appendixname~#1%
}


\begin{document}
\author{}
\subject{Linea Guida}
\title{\textbf{Il trattamento laparoscopico di laparocele e ernie ventrali}}
\date{Gennaio 2022}
\frontmatter
\maketitle
\tableofcontents
\chapter{Intro}
\mainmatter
\part{Sviluppo della linea guida}
\chapter{one}
\chapter{two}
\part{Quesiti}
\chapter{three}
\chapter{four}
%\backmatter% <- remove this!
% bibliography, glossary and index would go here.
\appendix
\chapter{AppendixA}
\chapter{AppendixB}
\end{document}

enter image description here

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .