# New chapter command for attachment

I am searching a solution to change the definition of the chapter command before putting the attachment in my document, which is a scrreprt.

With the scrreprt class, my normal chapters have only a number and then the title. My goal would be to let that as it is for the normal chapters, then, when I begin the attachment part, that my chapters have an other layout: simply the words "attachment" before the numbering, like "Attachment 1. Title of this attachment".

It should have the same behaviour in the table of contents: normal chapters should just be numeroted as usual and then the ones in the attachment part should have the word attachment before.


If I write a minimal exemple I have something like:

\documentclass[11pt,a4paper]{scrreprt}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[T1]{fontenc}

\begin{document}
\tableofcontents
\part{First Part}
\chapter{Title of chapter 1}
\chapter{Title of chapter 2}
\part{Attachment}
\chapter{Title of attachment 1}
\chapter{Title of attachment 2}
\end{document}


Thank you forward for your help, sorry for my bad english and have a nice day/evening/something ;-)

• Why not using \appendix and its features, redefining \appendixname to contain Attachment instead of Appendix
– user31729
Feb 22, 2017 at 21:47
• You will find answers to your other questions in this question Feb 22, 2017 at 21:55

Based on the great answer of esdd you can use the following code in your preamble:

\newcommand\tocappendixnumber[1]{\chapapp~#1}
\newcommand\startattachment{%
\RedeclareSectionCommand[
tocdynnumwidth,
tocentrynumberformat=\tocappendixnumber
]{chapter}}
\renewcommand*{\chapterformat}{%
\mbox{\chapappifchapterprefix{\nobreakspace}\chapapp~\thechapter\autodot
\IfUsePrefixLine{}{\enskip}}%
}
}


After \part{Attachment} use \startattachment

• Thank you very much for your answer, it was really helpful, it took some time for me to answer because I had to update my whole library (I think an old package, probably the kom-script, crashed with your formule), and had some trouble doing this (had some right problem on the computer), but I finally did it ;-) There is just one problem: your formule work fine, but instead of writing "attachment" before the number after the /startattachment, it writes "chapter". Any idea how to fix it? Except that all work fine, before the start attachment I have no text before the number, so thank you :)
– Gary
Feb 27, 2017 at 23:01
• Maybe I should precise that: I use my document in a german mode (ngerman, babel), so instead of "chapter" it is written "kapitel", I don't think it changes anything, but in doubt...
– Gary
Feb 27, 2017 at 23:06