Latex - Blank table of contents with unnumbered section
Asked Answered
A

1

5

When trying to create a table of contents with an unnumbered section, I get an empty table of contents, even after multiple repeated compilations.

When I use a numbered section, the table of contents works fine.

An example (complete Latex document) is shown below (I was trying to keep it as simple as possible):

\documentclass[12pt,a4paper,english]{article}

\begin{document}
\tableofcontents
\section*{Testsection} %Works when section* is replaced with section
 Test
\end{document}
Augustinaaugustine answered 9/9, 2014 at 19:50 Comment(0)
T
7

Entries of starred versions of sectional units can be inserted in the ToC using

\addcontentsline{toc}{<type>}{<content>}

where <type> is section, or subsection, or... Here is a minimal example:

enter image description here

\documentclass{article}
\begin{document}
\tableofcontents
\section{A numbered section}
\section*{An unnumbered section}
\addcontentsline{toc}{section}{Testsection}
\section{Another numbered section}
\section*{Another unnumbered section}
\addcontentsline{toc}{section}{\protect\numberline{}Another unnumbered section}
\end{document}

For alignment purposes, you may be interested in adding a \protected \numberline to the ToC entry.

Threepiece answered 28/6, 2015 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.