1

I would like to show the sections of some chapters in the front matter part of the book class document in the table of contents. Problem is all the chapters in the front matter are numbered 0 and so their sections get the numbering like 0.1, 0.2. I want to suppress the numbers but show the section titles in the ToC. How can I achieve that?

Example:

           CONTENTS
% Front Matter
Preface
How to use the book
    Book organization
    Glossary

% Main Matter
Chapter 1 Test Chapter 1
    1.1 Test section 1
    1.2 Test section 2
Chapter 2 Test Chapter 2
    2.1 Test section 1
    2.2 Test section 2
3
  • Use the starred forms, \section*{...}
    – vonbrand
    Jun 6, 2021 at 21:49
  • This will cause the sections to not appear on ToC
    – SolidMark
    Jun 7, 2021 at 5:19
  • Would you please provide an MWE? Maybe something like \renewcommand\thesection{{}{}}% after \frontmatter works, but I do not want to try this in the only book class document I have.
    – C. Peters
    Jun 7, 2021 at 6:58

1 Answer 1

1

You could use \setcounter{secnumdepth}{0} to get unnumbered sections in front matter and \setcounter{secnumdepth}{2} to get numbered parts, chapters, sections und subsections in main matter:

\documentclass{book}
\usepackage{blindtext}% only for dummy text

\usepackage{xpatch}
\xappto{\frontmatter}{\setcounter{secnumdepth}{0}}{}{}% unnumbered sections, subsections, subsubsections etc.
\xappto{\mainmatter}{\setcounter{secnumdepth}{2}}{}{}% numbered parts, chapters, sections, subsections

\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}
\chapter{How to use the book}
\section{Book organization}
\section{Glossary}
\mainmatter
\blinddocument
\blinddocument
\end{document}

enter image description here

2
  • Worked like a charm. How about chapters in front matter?
    – SolidMark
    Jun 7, 2021 at 11:36
  • Chapters in front matter are unnumbered by default, even if counter secnumdepth is 0 or bigger.
    – esdd
    Jun 7, 2021 at 11:40

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.