2

I'm working on a book that has two parts. Each part is, of course, composed of several chapters which are composed of sections. Great, right? Sure!

But....

For logistical reasons we want to organize the chapters into "chunks" within a part. So:

  • Part 1: DESSERTS
  • [intro to Part 1]

  • ICE CREAM

  • [ intro]
  • Chapter 1: Chocolate ice cream
  • Chapter 2: Vanilla ice cream

  • PIE

  • [ intro]

  • Chapter 3: Apple pie
  • Chapter 4: Blueberry pie

But of course, "ice cream" and "pie" aren't chapters in the same way that "vanilla ice cream" and "blueberry pie" are chapters.

How can I organize these two "supra chapters" above the level of the other chapters, but without giving them a chapter number?

2
  • \chapter*{ICE CREAM} perhaps, slightly modified to get rid of the clearpage (if that is an issue?)
    – user31729
    Sep 6, 2016 at 13:57
  • It lacks Gosky patties and Amblongus pies ;o)
    – Bernard
    Sep 6, 2016 at 15:49

1 Answer 1

2

Perhaps this is the simplest method: Using a wrapper command that performs \chapter*{} and adds the line to the ToC automatically.

\frontmatter\chapter{foo}\mainmatter would be possible too, but this changes the pagenumbering as well, which is not desired, most likely.

I provide two variants, both having the same effect. I prefer the 2nd one with no explicit \addcontentsline, however!

The 2nd variant uses a temporary change of the secnumdepth coutner which controls whether a sectioning unit is numbered in display or not. Setting it to -1 will only leave \part countered, restoring after the suprachapter has been used will provide the usual behaviour.

\documentclass{book}

\usepackage{xparse}
\usepackage{hyperref}
\newcounter{oldsecnumdepth}



\NewDocumentCommand{\suprachapter}{som}{%
  \IfBooleanTF{#1}{%
    \chapter*{#1}%
  }{%
    \chapter*{#3}%
    \IfValueTF{#2}{%
      \addcontentsline{toc}{chapter}{#2}%
    }{%
      \addcontentsline{toc}{chapter}{#3}%
    }%
  }%
}

\NewDocumentCommand{\suprachapterother}{som}{%
  \IfBooleanTF{#1}{%
    \chapter*{#1}%
  }{%
    \setcounter{oldsecnumdepth}{\value{secnumdepth}}%
    \setcounter{secnumdepth}{-1}%
    \IfValueTF{#2}{%
      \chapter[#2]{#3}%
    }{%
      \chapter{#3}%
    }%
    \setcounter{secnumdepth}{\value{oldsecnumdepth}}%
  }%
}

\begin{document}

\tableofcontents
\part{Foo}

\suprachapter{Ice scream}

\chapter{Vanilla flavour}

\chapter{Albatross flavour}

\suprachapterother{PIE}

\chapter{Apple Pie}

\chapter{Black Forest Cherry Tarte}


\end{document}

enter image description here

2
  • 1
    you, my friend, are an all-star genius. THANK YOU
    – Teusz
    Sep 8, 2016 at 14:10
  • @Teusz: You're welcome. Happy TeXing!
    – user31729
    Sep 8, 2016 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .