Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.