114

So we have something like:

\documentclass{article}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{amsmath}

\begin{document}

\tableofcontents

\section{Brushless Motor Fundamentals}
\subsection{Brushless Motor Operation}
\subsubsection{DC Motor Operation}
Torque is generated in DC motors from the magnetic force,
also known as the Lorentz force, which is produced when an
electric current is passed through a coil in a magnetic field.
This force is given by $F=q[E+(v\times B)]$,
where $F$ is the force perpendicular to the coil,
$E$ is the electric field in the coil, $B$ is the magnetic field,
and $v$ is the velocity of the charged particles in the coil.
From mechanics, torque is $\tau=F\times r$.

\section{Brushless Motor Fundamentals 2}
\subsection{Brushless Motor Operation}
\subsubsection{DC Motor Operation 2}
If the electrical force is ignored and the remaining magnetic force is used,
with the assumption that $v$ is perpendicular to $B$,
we find that $\tau=qvBrsin\theta$.

\end{document}

How to show subsubsections and paragraphs in TOC?

3
  • 3
    What exactly do you mean ? Could you give us an example ? From what I understood you want to remove \setcounter{secnumdepth}{2} \setcounter{tocdepth}{2} from your preamble ?
    – MP0
    May 10, 2011 at 14:47
  • 2
    I like your question, but the code is really cluttered with a lot of stuff that has nothing to do with your problem. Could you please reduce your code to a minimal working example (MWE) by removing everything that doesn't change your problem? As an example, you can leave out all the equations and the related stuff, and for text, a single word like foo or bar suffices entirely.
    – doncherry
    Oct 17, 2011 at 18:27
  • Related Question: Hide subsubsections in toc, but show in PDF. Feb 28, 2016 at 11:13

1 Answer 1

169

Increase the value of tocdepth and secnumdepth. The tocdepth value determines to which level the sectioning commands are printed in the ToC (they are always included in the .toc file but ignored otherwise). The secnumdepth value determines up to what level the sectioning titles are numbered. They are LaTeX counters and you can set them using \setcounter.

The sectioning levels have the following numbers:

-1 part
0 chapter     
1 section       
2 subsection  
3 subsubsection
4 paragraph
5 subparagraph

In the document class article, \chapter doesn't exist and 0 stands for \part instead.

Example:

\documentclass{article}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\begin{document}
\tableofcontents

\section{section}
\subsection{subsection}
\subsubsection{subsubsection}
\paragraph{paragraph}
\end{document}
5
  • 2
    Oddly enough, in scrreprt this doesn't seem to work properly unless you set secnumdepth first.
    – Egor Hans
    Jan 24, 2020 at 10:22
  • For anyone interested to locate the definition on levels of headings, for builtin document classes, it is introduced in section "7.2.7 Lower level headings" in classes.pdf (accessible by command line texdoc classes or on CTAN), defined with the 2nd argument of the environment command @startsection .
    – Quar
    Mar 3, 2021 at 16:51
  • @EgorHans This seems not to be correct. tocdepth (= showing an entry in the ToC) and secnumdepth (= numbering the heading and therefore also ToC entry) are independent in scrreprt like they are in report. BTW: With scrreprt you even don't need to know the absolute levels numbers (and maybe should not use them, because they are configurable). You can just use \setcounter{tocdepth}{\paragraphtocdepth} and \setcounter{secnumdepth}{\paragraphnumdepth}.
    – cabohah
    Aug 31, 2023 at 7:43
  • Be careful, you are mixing secnumdepth and tocdepth. 0 stands for \part only in secnumdepth. \l@part uses \ifnum \c@tocdepth >-2\relax and therefore setting tocdepth to -1 still shows the parts in the the ToC. So the tocdepth of part is -1.
    – cabohah
    Aug 31, 2023 at 7:47
  • @cabohah Maybe the issue you're pointing out (with the depth for a specific level being different between the counters) was the cause of having to set secnumdepth for me. If I ever go back to using that snippet for anything (I'm no longer in a situation where I need to write such documents any time soon), I'll definitely rewrite it to use the respective macros and see if I still need both.
    – Egor Hans
    Oct 12, 2023 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .