5

Currently I use a manually declared version of the chapter title. But the idea is to extend it to use specific and manually chosen number of the chapters.

I try to obtain numbers like this 1, 1b, 2, 2b, 3, 4. But for obtaining b, I want to specify it manually with for example an option in the \chapter command (something like this \chapter{...} for obtaining 1 then \chapter[b]{...} for obtaining 1b.

Do you have any ideas for obtaining this result?

  • You could specify all of the manually. Just add \renewcommand{\thechapter}{<whatever>} before \chapter{<title>}... – Werner Jan 22 '15 at 18:16
7

You could add a + specifier for the “repeat chapters”; the proposed code doesn't interfere with usages of \chapter*.

\documentclass{book}

\makeatletter
\newcounter{repchapter}
\let\latex@chapter\chapter
\renewcommand{\chapter}{\@ifstar{\latex@chapter*}{\guuk@chapter}}
\newcommand{\guuk@chapter}{\@ifnextchar+{\repeat@chapter}{\restore@chapter\latex@chapter}}
\newcommand{\repeat@chapter}[1]{% #1 is +
  \addtocounter{chapter}{-1}%
  \addtocounter{repchapter}{1}%
  \gdef\thechapter{\arabic{chapter}\alph{repchapter}}%
  \latex@chapter
}
\newcommand{\restore@chapter}{%
  \setcounter{repchapter}{1}%
  \gdef\thechapter{\arabic{chapter}}%
}
\makeatother

\begin{document}

\tableofcontents

\chapter{Title}
x
\chapter+{Repeat}
x
\chapter{Title}
x
\chapter+{Repeat}
x
\chapter+{Again}
x
\end{document}

enter image description here

If you load hyperref, then add

\renewcommand{\theHchapter}{\thechapter}

just after \makeatletter. Make sure \usepackage{hyperref} is before the shown code.

  • Great solution! – karlkoeller Jan 22 '15 at 18:42
  • Great! You always have a solution :-) I will try this. – Guuk Jan 22 '15 at 18:44

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.