0

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.

I already tried some things, I think it should be possible with a \renewcommand at the begin of the attachment part, or maybe a \newcommand named for instance \attachment based on the \chapter command, but I don't understand how it works.

Could someone please help me?

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 '17 at 21:47
  • You will find answers to your other questions in this question – Sveinung Feb 22 '17 at 21:55
1

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

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

After \part{Attachment} use \startattachment

| improve this answer | |
  • 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 '17 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 '17 at 23:06

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.