3

at the beginning of one part of my document I've got a tabular with some values and in the chapters afterwards I'll explain them. Some values need to be combined; so the chapters have to be enumerated eg. that way:

1. A
2. B
3. - 5. C
6. - 7. D
8. E

I think of something like defining an alternate chapter-command \chapterA.

For instance:

\chapter{A}
\chapter{B}
\chapterA{3}{C} % combine 3 values
\chapterA{2}{D} % combine 2 values
\chapter{E}

What does this command have to look like?

I found this but couldn't manage to apply it to the \chapter command.

4

One option using titlesec; the command \standardchapter produces a "normal" heading; \combinedchapter produces a heading in each the numbering has the form <number>.-- <number>+#1, where #1 is the integer in the mandatory argument:

\documentclass{book}
\usepackage{titlesec}

\newcommand\standardchapter{%
\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}{\thechapter.}{1em}{}
}
\newcommand\combinedchapter[1]{%
\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}{\thechapter.--\,\number\numexpr\thechapter+#1\relax.\addtocounter{chapter}{#1}}{1em}{}
}

\begin{document}

\let\cleardoublepage\relax% just for the example

\standardchapter
\chapter{A}
\chapter{B}
\combinedchapter{2}
\chapter{C}
\combinedchapter{3}
\chapter{D}
\standardchapter
\chapter{E}

\end{document}

enter image description here

1

The following example defines \chapterA with a range as chapter number. Also chapters inside the appendix are supported. Because of the longer numbers, the table of contents is adjusted accordingly.

\documentclass{scrreprt}

\let\savedthechapter\thechapter
\let\orgchapter\chapter
\renewcommand*{\chapter}{%
  \let\thechapter\savedthechapter
  \orgchapter
}
\newcommand*{\chapterA}[1]{%
  \stepcounter{chapter}%
  \edef\thechapterauxA{\savedthechapter}%
  \addtocounter{chapter}{#1}%
  \addtocounter{chapter}{-1}%
  \edef\thechapterauxB{\savedthechapter}%
  \edef\thechapter{\thechapterauxA.--\thechapterauxB}%
  \addtocounter{chapter}{-1}%
  \orgchapter
}

% \appendix changes \thechapter for uppercase letters
\makeatletter
\g@addto@macro\appendix{%
  \global\let\savedthechapter\thechapter
}
\makeatother

% patch \l@chapter to get room for the chapter number
\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@chapter}{%
  \setlength\@tempdima{1.5em}%
}{%
  \setlength\@tempdima{3em}%
}{}{\errmessage{Patching \string\l@chapter\space failed}}
\patchcmd{\l@section}{{1.5em}}{{3em}}%
  {}{\errmessage{Patching \string\l@section\space failed}}
\patchcmd{\l@subsection}{{3.8em}}{{5.3em}}%
  {}{\errmessage{Patching \string\l@subsection\space failed}}
% analog: subsubsection, paragraph, subparagraph, ...
\makeatother

\begin{document}
  \tableofcontents
  \chapter{A}
  \chapter{B}
  \chapterA{3}{C} % combine 3 values
  \chapterA{2}{D} % combine 2 values
  \chapter{E}
  \section{Section}
  \subsection{Subsection}
  \appendix
  \chapter{Appendix 1}
  \chapterA{3}{Appendix 2-4}
  \chapter{Appendix 5}
\end{document}

Result

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.