GeneralTOC Oddness

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
triplep
Posts: 2
Joined: Sat Mar 15, 2008 7:39 am

TOC Oddness

Post by triplep »

I'm still very new to LaTeX, so I'm still quite prone to doing silly things, which I don't always understand, so please bear with me.

When building the tex file, if have all of my entries as

Code: Select all

\section*{some section}
I can't get a proper TOC, it seems that if I don't have the section numbers enabled, it does not want to include them in the TOC.

Is there a setting that can include non-enumerated sections in the TOC?

The following code gives me an empty TOC:

Code: Select all

\documentclass{article}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}


\begin{document}
\tableofcontents

%\thispagestyle{empty}
%\addtocounter{page}{-1}
\newpage

\section*{section 1}
\subsection*{subsection A}
content goes here
\newpage

\section*{section 2}
content goes here

\section*{section 3}
content goes here
\end{document}


I'm using kile to edit, and my versions look like this:

Code: Select all

~/tex$ latex -v
pdfTeX using libpoppler 3.141592-1.40.3-2.2 (Web2C 7.5.6)
kpathsea version 3.5.6
Copyright 2007 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea is copyright 2007 Karl Berry and Olaf Weber.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX using libpoppler copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX using libpoppler source.
Primary author of pdfTeX using libpoppler: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Kpathsea written by Karl Berry, Olaf Weber, and others.

Compiled with libpng 1.2.15beta5; using libpng 1.2.15beta5
Compiled with zlib 1.2.3.3; using zlib 1.2.3.3
Compiled with libpoppler version 3.00
Any suggestions are appreciated!

thanks,
triplep

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

TOC Oddness

Post by Stefan Kottwitz »

Hi triplep,

after writing \section* you still can add the section to the toc using \addcontentsline, example:

Code: Select all

\section*{section 1}
\addcontentsline{toc}{section}{section 1}
\subsection*{subsection A}
\addcontentsline{toc}{subsection}{subsection A}
But if you want to suppress all numbers of sections, subsections, etc. but still want them to be listed in the toc, you can use \section and decrease the secnumdepth-counter. In your second line you set it to 5. Just set it to 0, and no section will be numbered. With other document classes you may even set it to -2, to suppress also chapter and part numbering.

Stefan
triplep
Posts: 2
Joined: Sat Mar 15, 2008 7:39 am

Re: TOC Oddness

Post by triplep »

Thanks Stefan!

This worked perfectly. Thinking about it, it makes much more sense this way, since you can make global changes with one line rather than hunting to remove asterisks all over a TeX file.

I'm really enjoying the flexibility that TeX offers. Thanks again for the support.
Post Reply