# [texhax] Adding "\section*" entries to TOC

Reinhard Kotucha reinhard.kotucha at web.de
Sun Jun 2 02:51:52 CEST 2013

On 2013-06-01 at 21:58:52 +0200, jfbu wrote:

> If you insert
>
> \setcounter{secnumdepth}{0}
>
> at the beginning of the body of the document, and use \section{FOO}
> without the star, then the TOC will display the (unnumbered) section
> entries.

I assume that with "body of the document" you mean everything between
\begin{document} and \end{document}.

You can do this alraedy in the preamble of the document.  The default
value is set in the document class file.

A basic idea of LaTeX is to separate content and layout.  Thus, no
layout instructions should be inserted after \begin{document}.  In
some cases it cannot be avoided but in these rare cases the macro
\AtBeginDocument can be used.

The ability to keep content and layout separately is an invaluable
feature of LaTeX.

> Subsections will not be numbered too, and you can control with the
> tocdepth counter if they appear or not in the TOC

If you've set up tocdepth to a value which prevents sections to appear
in the TOC, the only way to get subsections into the TOC is to use
\addcontentsline.  "tocdepth" works from top to bottom.

Regards,
Reinhard

--
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------