Graphics, Figures & TablesTOC with unnumbered subsections

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ccoplick
Posts: 3
Joined: Fri May 31, 2024 9:22 pm

TOC with unnumbered subsections

Post by ccoplick »

Hi there -- I am confused about TOC...

I am using LaTeX for the creation of what can be most closely called a technical manual. I am formatting my company's 450 pg + safety manual, using the report class. So far, it's been going well, and I'm getting everything in there.

The problem I am running into, or at least not understanding the documentation/suggestions out there, is that I want my TOC to look like this:

One: Company Rules
corporate health and safety policy .........................1
scope for health and safety ..................................2
responsibilities .................................................3
safety rules .....................................................4
safety rules, discipline, and commendation policy ... 5
non compliance policy and procedure ................6

Where each of those subsections are indented and also NOT numbered.

What I have used is:

\begin{document}
\maketitle
\tableofcontents
\setcounter{tocnumdepth}{3}
\chapter{Company Rules}
\newpage
\addcontentsline{toc}{section}{Corporate Health and Safety Policy}
\section*{Corporate Health \& Safety Policy}

and in the first subsection, I used:

\newpage
\addcontentsline{toc}{subsection}{Safety Rules, Discipline, \& Commendation Policy}
\subsection{Safety Rules, Discipline \& Commendation Policy}

and for some weird reason (well, i'm sure it's not a weird reason, but it feels like it), my table of contents appears like this:

Safety Rules
Safety Rules, Discipline ...etc
1.01 Safety Rules, Discipline .... etc

Why? What am I doing wrong?

recap:
TOC with up to 5 levels
No numbers in the sections, or in the TOC for the sections, just indents

THANK YOU!

Recommended reading 2024:

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

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

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

TOC with unnumbered subsections

Post by rais »

Well, besides that you're trying to set a counter that doesn't exist (tocnumdepth), even if you used the right name for it (tocdepth), you're setting it after you're outputting the TOC, so it would not have any effect on the TOC.

The starred version of \section suppresses the incrementation of its section counter, hence the 0 in the subsection afterwards.
And since you're using \addcontentsline and \subsection (unstarred) both, you get 2 entries in the TOC.

It would be easier, if you just limit secnumdepth, the level for numbering, in combination with the unstarred sectioning commands:

Code: Select all

\documentclass{report}
\setcounter{tocdepth}{3}% part, ..., subsubsection into toc
\setcounter{secnumdepth}{0}% section and below not numbered
\begin{document}
%\maketitle
\tableofcontents
\chapter{Company Rules}
\newpage
\section{Corporate Health \& Safety Policy}

and in the first subsection, I used:

\newpage
\subsection{Safety Rules, Discipline \& Commendation Policy}
\end{document}
KR

Rainer
ccoplick
Posts: 3
Joined: Fri May 31, 2024 9:22 pm

TOC with unnumbered subsections

Post by ccoplick »

Thank you for your assistance! I'm very new to LaTeX, so explaining it to me like I'm 5 is the best way to go. :P

One question -- I understand everything you've explained, but need to know what the next level tag would be...
subsection would just get me the same level, what is the next subsection called?

thanks,
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

TOC with unnumbered subsections

Post by rais »

If you look closely, you'll see I answered your last question before you asked it ;)
(look at my comment after \setcounter{tocdepth}{3})

To recap, the standard classes define these sectioning commands with their, hmm, level values:
  • \part -1 (0 for article class)
  • \chapter 0 (not for article class)
  • \section 1
  • \subsection 2
  • \subsubsection 3
  • \paragraph 4
  • \subparagraph 5
For getting a numbered section, this level value must be secnumdepth or smaller.
For an entry in the TOC, this level value must be tocdepth or smaller.
(The article class does not define a \chapter command)

KR
Rainer
ccoplick
Posts: 3
Joined: Fri May 31, 2024 9:22 pm

TOC with unnumbered subsections

Post by ccoplick »

Thank you -- like I said... I'm VERY new to this and basically need it explained like I'm 5. :/

This is exactly the way I needed to see it tho.

Thanks,
CharlesDesilva
Posts: 1
Joined: Thu Jun 13, 2024 8:26 am

TOC with unnumbered subsections

Post by CharlesDesilva »

Thank you @rais, you made my day.
Post Reply