Hello,
how can I avoid that a numbered section gets listed in the TOC?
What I already know:
\section{example} leads to a numbered new section which gets listed in the TOC.
\section*{example} leads to a new section which is not listed in the TOC but also gets no number. But I need a number for the section because I want to refer to the section.
Thanks in advance.
Text Formatting ⇒ numbered section not in TOC
NEW: TikZ book now 40% off at Amazon.com for a short time.

numbered section not in TOC
It may depend on your document class and settings, but something like this might work well enough for the standard classes, for example:
might work well enough.
Code: Select all
\section*{\refstepcounter{section}\thesection\quad Section Title}
Re: numbered section not in TOC
If I do it like that, the section gets numbered but not listed in the TOC. This is fine. But as I said I want to refer to the section:
\section*{\refstepcounter{section}\thesection\quad Section Title}\label{Section Title}
But in this case \ref{Section Title} does not refer to the correct section (let´s say A.1 in the appendix) but just to the chapter (i.e. A). How can I manage that the ref command refers to the correct section?
\section*{\refstepcounter{section}\thesection\quad Section Title}\label{Section Title}
But in this case \ref{Section Title} does not refer to the correct section (let´s say A.1 in the appendix) but just to the chapter (i.e. A). How can I manage that the ref command refers to the correct section?
numbered section not in TOC
Sorry. You have two choices. Either put the label inside the section* command:
Or move the \refstepcounter command outside of it (right before it).
If you're using hyperref, you may need to put a \phantomsection command before everything too to get the links working right.
Code: Select all
\section*{\refstepcounter{section}\label{mylabel}\thesection\quad Section Title}
Code: Select all
\refstepcounter{section}\section*{\thesection\quad Section Title}\label{mylabel}
Re: numbered section not in TOC
I adopted the first proposal and it works very well. Thank you very much.
I modified it a bit (probably very dowdy). With your proposal the number of the section looks like 1.1 but because all other section numbers in my text have the form 1.1. I simply wrote
\section*{\refstepcounter{section}\label{mylabel}\thesection.\quad Section Title}
I modified it a bit (probably very dowdy). With your proposal the number of the section looks like 1.1 but because all other section numbers in my text have the form 1.1. I simply wrote
\section*{\refstepcounter{section}\label{mylabel}\thesection.\quad Section Title}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
numbered section not in TOC
Now that the problem is solved, please be so kind and mark the topic (not the last post) accordingly as clearly written in the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10