# Suppress section numbering in front matter for ToC

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

• Use the starred forms, \section*{...} Jun 6, 2021 at 21:49
• This will cause the sections to not appear on ToC 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. Jun 7, 2021 at 6:58

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}


• Worked like a charm. How about chapters in front matter? 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