因为你要指定计数器 `tocdepth` 的值, 如果置空的话, 会显示错误
```latex
l.2 \setcounter{tocdepth}{}
? h
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
```
在刘海洋的 《LaTeX入门》的 P.129 可以看到不同层级的编号

如果你想目录显示到 subsection 层级, 只要设置 `\setcounter{tocdepth}{2}`, 比如
```latex
\documentclass{article}
\setcounter{tocdepth}{2}
\begin{document}
\tableofcontents
\section{1}
\subsection{2}
\subsubsection{3}
\section{4}
\subsection{5}
\subsubsection{6}
\subsection{7}
\end{document}
```
实现效果

一周热门 更多>