0

I want to make chapters and sub chapters, like so:

Chapter 1

Chapter 1a

Chapter 1b

Chapter 2

Chapter 2a

Chapter 3

I found that this, while the main idea is there, doesn't quite do what I want it to do, and I have no clue how to change the code to match my preference

The difference is that the code from the post i linked to, divides the chapter like this:

Chapter 1

Chapter 2a

Chapter 2b

Chapter 3

Chapter 4a

But i'd like to not have an 'a' on my main chapter.

The code example from the linked post and my documentclass:

\documentclass{memoir}

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
%\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\newcounter{subchapter}\renewcommand{\thesubchapter}{\alph{subchapter}}
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\newcommand{\updatechaptercounter}{}
% \patchcmd{\@chapter}{\@afterheading}{\updatechaptercounter\@afterheading}{}{}% Regular patch of \@chapter
\patchcmd{\Hy@org@chapter}{\@afterheading}{\updatechaptercounter\@afterheading}{}{}% Hyperref patch of \@chapter
\makeatother
\providecommand{\theHchapter}{}%
\newcommand{\startsubchapters}{%
  \setcounter{subchapter}{0}% Reset sub-chapter numbering
  \renewcommand{\thechapter}{\arabic{chapter}\thesubchapter}% Update chapter number display
  \renewcommand{\theHchapter}{\arabic{chapter}\thesubchapter}% Update chapter number display (for hyperref)
  \renewcommand{\updatechaptercounter}{\addtocounter{chapter}{-1}}% Update chapter number
  \let\oldchapter\chapter%
  \renewcommand{\chapter}{\stepcounter{subchapter}\oldchapter}% Increment subchapter
}
\newcommand{\stopsubchapters}{%
  \renewcommand{\thechapter}{\arabic{chapter}}% Reset chapter numbering
  \renewcommand{\theHchapter}{\arabic{chapter}}% Reset chapter numbering (for hyperref)
  \let\chapter\oldchapter% Restore regular \chapter command
  \renewcommand{\updatechaptercounter}{}% Clear chapter counter update
  \stepcounter{chapter}% Update chapter counter
}

\begin{document}

\chapter{Chapter 1}
    \section{section 1.1}
\chapter{Subchapter 1a}
    \section{section 1a.1}
    \section{section 1a.2}

\chapter{Subchapter 1b}
\section{section 1b.1}

\chapter{Subchapter 1c}
\chapter{Chapter 2}
\chapter{Subchapter 2a}
\chapter{Subchapter 2b}
\chapter{Subchapter 2c}

\end{document}

Also: I know about sections, but they don't do justice in my case, as I have lots of different subjects I need to write about, and the best way to do that is by using the sub-chapters.

  • One could replace section with subchapter, redefining \l@section and \thesection. OTOH, adding a new level would push all the others down. – John Kormylo Oct 16 '19 at 11:51
  • I could define new sections and so on, but I don't need new levels that push others down, I need ones on level with chapters, but visually recognisable from the parent chapters – L. Nielsen Oct 16 '19 at 11:59
  • A level 0 subchapter would work. OTOH, I've been looking over memoir's definition of \chapter etc. and it is much more complicated than book class. – John Kormylo Oct 16 '19 at 12:28
  • BTW, \newcounter{subchapter}[chapter] will reset automatically., but you will also need \@addtoreset{section}{subchapter}. – John Kormylo Oct 16 '19 at 12:50

0 Answers0