0

I am trying to get a chapter number that is not an integer. My current code looks like this:

\chapter*{Example\vspace{-75pt}\\\huge Chapter 0.5}\vspace{50pt}
\addcontentsline{toc}{chapter}{0.5 Example}

However, the code is very messy, and every section needs a similar change for it to stay consistent (Thankfully I don't have any sections in the chapter but it is a problem).

What I am looking for is a solution that solves the first (or both) problems noted above.

EDIT: For clarification, 0.5 is just an example. More examples:

\chapter*{Example\vspace{-75pt}\\\huge Chapter Q}\vspace{50pt}
\addcontentsline{toc}{chapter}{Q Example}

\chapter*{Example\vspace{-75pt}\\\huge Chapter Zero point five}\vspace{50pt}
\addcontentsline{toc}{chapter}{Zero point five Example}

\chapter*{Example\vspace{-75pt}\\\huge Chapter Chapter}\vspace{50pt}
\addcontentsline{toc}{chapter}{Chapter Example}

\chapter*{Example\vspace{-75pt}\\\huge Chapter $\frac12$}\vspace{50pt}
\addcontentsline{toc}{chapter}{$\mathbf{\frac12}$ Example}
7
  • 3
    0.5 looks like part 0, chapter 5. (Similar to how subsections are numbered.) How are the non-integer numbers incremented? If it is a fixed step across the document you could just format the output in relation to the integer numbers 1, 2, 3, … Nov 19, 2022 at 2:17
  • @Qrrbrbirlbel You make a good point, what about fractions \frac{1}{2} instead of decimals 0.5? Nov 19, 2022 at 2:43
  • I edited my question to be clearer.
    – nonhuman
    Nov 19, 2022 at 3:59
  • Your examples are quite diverse; it's probably easy to assume a letter numbering would be sequential (A, B, ..., Z). However, what is sequential about "zero point five" or \frac{1}{2}? That is, what follows it?
    – Werner
    Nov 19, 2022 at 6:26
  • I an not sure what exactly do you want, but maybe \renewcommand{\thechapter}{\ensuremath{\frac12}} will do the job? (This should be done right after \chapter{} command) Nov 19, 2022 at 9:21

2 Answers 2

2

Not going to explain too much, but the idea is to define \additionalchapter that does a few things:

  1. the chapter number is stepped down (so when \chapter is called the main number is the same as the previous one)

  2. \thechapter is redefined to include the desired additional part;

  3. \chapter is issued, but in its original form.

Why do we need \standardchapter? Because we have to add to \chapter the code for restoring the standard meaning of \thechapter.

Finally, a code for “textual” fractions is added.

Production notes. I use openany and geometry just to make a smaller picture of the result.

\documentclass[openany]{book}
\usepackage{amsmath} % for \text

\usepackage[a6paper]{geometry} % just to make smaller pictures

\NewDocumentCommand{\additionalchapter}{mO{#3}m}{%
  % #1 = suffix to add
  % #2 = optional argument for toc and header, as usual
  % #3 = title
  \addtocounter{chapter}{-1}%
  \renewcommand{\thechapter}{\standardthechapter#1}%
  \nonstandardchapter[#2]{#3}%
}

\AtBeginDocument{%
  \NewCommandCopy{\standardthechapter}{\thechapter}%
  \NewCommandCopy{\nonstandardchapter}{\chapter}%
  \AddToHook{cmd/chapter/before}{%
    \RenewCommandCopy{\thechapter}{\standardthechapter}%
  }%
}

\NewDocumentCommand{\chapfrac}{mm}{$\frac{\text{#1}}{\text{#2}}$}

\begin{document}

\chapter{First}\label{ch:one}

\ref{ch:one}, \ref{ch:oneandhalf}, \ref{ch:oneplus}, \ref{ch:two}

\additionalchapter{\chapfrac{1}{2}}{First and a half}\label{ch:oneandhalf}

\additionalchapter{\chapfrac{2}{3}}{First and more}\label{ch:oneplus}

\chapter{Second}\label{ch:two}

\end{document}

enter image description here

1
  • It would be interesting if these extra chapters could keep track of their total amount and just enumerate themselves, i.e. 1, 1 1/3, 1 2/3, 2, … but that's just a section in chapter's clothing. Nov 19, 2022 at 15:50
1

This creates an array of chapter "numbers" to be used for \thechapter.

\documentclass{report}

\renewcommand{\thechapter}{\csname chapt\arabic{chapter}\endcsname}

\makeatletter
\@namedef{chapt1}{1}
\@namedef{chapt2}{1.5}
\@namedef{chapt3}{II}
\@namedef{chapt4}{C}
\@namedef{chapt5}{$\pi$}
\makeatother

\begin{document}
\chapter{First}
\chapter{Second}
\chapter{Third}
\chapter{Fourth}
\chapter{Fifth}
\end{document}

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.