Unnumbered sections in LaTeX (section*)
Add a star: \section*{Preface} prints the heading without a number. The same works for \chapter*, \subsection* and the other levels. A starred heading does not appear in the table of contents.
One heading without a number
The star leaves the section counter untouched, so the next \section continues the numbering.
\section*{Preface}
Text of the preface.
\section{Introduction}
This section has the number 1.Add it to the table of contents
\addcontentsline{toc}{section}{Preface} after the heading creates the entry. With hyperref, write \phantomsection on the line before \section*, so the link in the table of contents jumps to the heading.
\tableofcontents
\section*{Preface}
\addcontentsline{toc}{section}{Preface}
Text of the preface.
\section{Introduction}
Text of the section.No numbers in the whole document
\setcounter{secnumdepth}{0} switches the numbers of all sections off. The headings are written without a star and keep their entries in the table of contents.
This goes into the preamble.
\setcounter{secnumdepth}{0}KOMA-Script: \addsec and \addchap
In the KOMA-Script classes, \addsec{Preface} prints an unnumbered section and adds it to the table of contents and the page header. \addchap does the same for a chapter in scrreprt and scrbook.
Complete document:
\documentclass{scrartcl}
\begin{document}
\tableofcontents
\addsec{Preface}
Text of the preface.
\section{Introduction}
Text of the section.
\end{document}Pitfalls
- A
\labelafter a starred heading has no number of its own.\refto it prints the number of the last numbered heading before it. - A starred heading does not change the page header.
\markboth{Preface}{Preface}after the heading sets the header text by hand.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- How-to Sections, subsections and chapters in LaTeX
- How-to Create a table of contents in LaTeX
- How-to Headers and footers in LaTeX
- Package
hyperref