[Tex/LaTex] Generate table of contents when \section* (sections without numbering) has been used

sectioningstarred-versiontable of contents

Is it possible just to generate a table of contents based on sections in asterisk mode, i.e., \section*? I basically just want the table of contents without section numbers. Like a list of headings and their associated pages.

The following doesn't generate a ToC:




\subsection*{Section 1}

\subsection*{Section 2}


Best Answer

You don't have numbered sections, do you? In this case the simplest arrangement is

\setcounter{secnumdepth}{0} % sections are level 1




No sectional unit below \section will be numbered, but sections and subsections will go anyway in the table of contents (as this depends on the value of the tocdepth counter, default 2).