12

Possible Duplicate:
hide an entry from Toc in latex

Appendix
 A Section 1
     A.1 Subsection 1
     A.2 Subsection 2
 B Section 2

Is there a way to get rid of Subsection n, but still have the subsection numbered in the document (i.e. not using \subsection*)?

I thought about limiting the TOC depth, but that does not seem to be possible for just the Appendix?

Community
  • 1
  • 1
HTTPeter
  • 247
  • 1
  • 4
  • 13

1 Answers1

20

Here's one (sort of hackish but not too bad) way to work this:

All wrapped up, you just add a new command hiddensubsection, given by

\newcommand{\hiddensubsection}[1]{
    \stepcounter{subsection}
    \subsection*{\arabic{chapter}.\arabic{section}.\arabic{subsection}\hspace{1em}{#1}}
}

Then you create your notoc subsection using this instead of \subsection:

\hiddensubsection{sectionname}

The way it works is by manually incrementing the subsection counter and then creating an unnumbered subsection with the subsection counter as part of the title. You may need to tweak the spacing between number and title, but i couldn't see any difference.

Obviously you could do the same thing for sections and subsubsections if needed

pheraph
  • 3
  • 5
second
  • 28,029
  • 7
  • 75
  • 76
  • 2
    What do you do if the * operator doesn't work. For me, its using "*" as the actual title and treating the actual heading like regular text in a new paragraph. – Safayet Ahmed Apr 13 '14 at 21:18
  • I personally found using `1ex` instead of `1em` for the `\hspace` to be correct. – Saul Apr 14 '16 at 10:40
  • 1
    This works. However, it changes the subsection counter. Is it possible to use this solution and still use `\ref` properly? – tiago Mar 07 '20 at 04:56
  • 2
    @tiago Yes, just use ```\refstepcounter``` instead of ```\stepcounter``` in the code above and ```\ref```` will be updated! – Manuel Popp May 03 '21 at 11:29