My current document is processed like this:
1. Some chapter
1.1. Some section
1.1.1. Some subsection
Appendix A.
Some appendix
What I want to have:
1 Some chapter
1.1 Some section
1.1.1 Some subsection
Appendix A: Some appendix
So I want the last dots of the numbering removed for the main part. For the appendix, I want a colon instead of the dot and the title in the same line.
A small example, including all packages used:
\documentclass[appendixprefix=true,11pt,a4paper]{scrreprt}
%The packages used in my document
\usepackage{listings}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{chngcntr}
\usepackage[usenames,dvipsnames]{color}
%Appendix definition (Write "Appendix A")
\makeatletter
\newcommand\appendix@numberline[1]{\appendixname\ #1: }
\g@addto@macro\appendix{%
\addtocontents{toc}{
\let\protect\numberline\protect\appendix@numberline}%
}
\makeatother
\begin{document}
\chapter{First chapter}
\section{First section}
\subsection{First subsection}
\appendix
\chapter{Last chapter}
\end{document}
How can I make the colon and the title in the same line. And how do I remove the last dots of the titles?
Symbol1's answer doesn't work. Error message:
Undefined control sequence. \@makechapterhead ...mdepth >\m@ne \if@mainmatter
\huge \bfseries \@chapapp ... l.108 \chapter{Definition of the Problem}
Best Answer
Here's how you can obtain the output you're after in the KOMA-script classes:
The dots are removed through a redefinition of
\autodot
, while the Appendix formatting is done via a\patchcmd
of\@@makechapterhead
when you call\appendix
. The final patch adjusts the width of the\numberline
box from1.5em
to6.5em
. This adjustment is specific to the chapter-related entry in the ToC as it deals with\l@chapter
.etoolbox
provides the patching capability.