0

So I want to have my chapter to go like this:

Chapter 1
Chapter 2
Chapter 3+4
Chapter 6

Yes I want a way to somehow have two chapters in one and to skip a chapter too

Adrik Ivanov
  • 487
  • 2
  • 10

1 Answers1

3

Skipping a chapter can be done by increasing the chapter counter using \refstepcounter{chapter}.

Combining two chapters is a bit more difficult. For this you can temporarily redefine the macro that is used to print the chapter number, which is called \thechapter. Normally this is defined as \arabic{chapter}, which means "print the chapter counter in arabic numbers". You can redefine this as "print the chapter counter and the chapter counter+1", then add the combined chapter, then reset the counter printing macro to the original definition.

Printing a counter plus one can be done using \numexpr (numeric expression), the built-in LaTeX macro for doing arithmetic. In this case you need the value of the chapter counter (\value{chapter}) and add one. This expression is closed by \relax and printed with \the. The full statement then is:

\the\numexpr\value{chapter}+1\relax

This can be used in a redefinition of \thechapter:

\def\thechapter{\arabic{chapter}+\the\numexpr\value{chapter}+1\relax}

Note that the first + is an actual plus symbol that is printed as part of the title, whereas the second + is part of the arithmetic expression which is evaluated.

To make this redefinition temporary the original definition should first be stored, and later restored, as follows:

% store old definition in helper macro \oldchapter
\let\oldchapter\thechapter
% redefinition
\def\thechapter{\arabic{chapter}\texttt{+}\the\numexpr\value{chapter}+1\relax}
% start a chapter which uses the new definition
\chapter{Two chapters}
% restore old definition by copying \oldchapter back into \thechapter
\let\thechapter\oldchapter

Now there are two more issues. First, the regular + symbol in text mode does not look nice, it is too big and it is not vertically centered. In my opinion the monospace \texttt variant looks nicer, as follows:

\arabic{chapter}\texttt{+}\the\numexpr %etc

Then, the table of contents reserves only a small amount of space for the chapter numbers, so 3+4 is too wide and overlaps with the chapter title. The chapter number width can be changed using the tocloft package:

\usepackage{tocloft}
\setlength{\cftchapnumwidth}{15mm}

Full MWE below. Note that the chapter counter is skipped twice because it goes from 3 to 6 (the counter is never actually 4, the 4 is printed as 3+1).

\documentclass{report}
\usepackage{tocloft}
\setlength{\cftchapnumwidth}{15mm}
\begin{document}
\tableofcontents
\chapter{A chapter}
\chapter{Another chapter}
\label{single}
\let\oldchapter\thechapter
\def\thechapter{\arabic{chapter}\texttt{+}\the\numexpr\value{chapter}+1\relax}
\chapter{Two chapters}
\label{double}
\let\thechapter\oldchapter
\refstepcounter{chapter}
\refstepcounter{chapter}
\chapter{Last chapter}
see also chapters \ref{single} and \ref{double}
\end{document}

Result:

enter image description here

References work as expected:

enter image description here

Marijn
  • 37,699