If you’ve ever worked with LaTeX, you know the value of structuring your document with sections and subsections. But sometimes, you might not want these sections to be numbered. Here’s how you can achieve that and even decide whether or not to include them in the Table of Contents.
In LaTeX, to create a non-numbered chapter or section, you use the *
character. Specifically:
\chapter*{Your Chapter Name}
\section*{Your Section Name}
However, by default, these non-numbered sections or chapters won’t appear in your Table of Contents.
If you want to include your non-numbered sections or chapters in the Table of Contents, you can use the \addcontentsline
command. Here’s how:
\addcontentsline{toc}{chapter}{Your Chapter Name}
\addcontentsline{toc}{section}{Your Section Name}
\addcontentsline{toc}{subsection}{Your Subsection Name}
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\tableofcontents
\section*{Non-numbered Section}
\addcontentsline{toc}{section}{Non-numbered Section}
This is a non-numbered section.
\section{Numbered Section}
This is a numbered section.
\subsection{Numbered Subsection}
This is a numbered subsection.
\subsection*{Non-numbered Subsection}
\addcontentsline{toc}{subsection}{Non-numbered Subsection}
This is a non-numbered subsection.
\end{document}
LaTeX is an incredibly powerful tool for document preparation. By understanding commands like the ones above, you can gain greater control over your document’s structure and presentation. Happy TeXing!