3

I would like unnumbered sections (more specifically unnumbered subsubsections) to appear in the table of contents, indented to their appropriate depth (i.e. as if they were numbered). I am using the amsbook document class.

Note: this issue is solved for non-ams document classes in the question how to make unnumbered sections aligned in table of contents? and for koma-script classes elsewhere, but as far as I can tell has not been addressed for ams classes.

1 Answer 1

2

A combination of this and this answer seems to work:

\documentclass{amsbook}

\begin{document}

\tableofcontents

\section{section A}

\section*{%
    \for{toc}{\protect\hphantom{\numberline{\thesection}}section B}%
    \except{toc}{section B}%
}

\section{section C}

\end{document}

enter image description here


Update

After checking the documentation for amsclass I found that \tocsection (which is also used for sub- and subsubsections) is defined as \indentlabel{\@ifnotempty{#2}{\ignorespaces#1 #2.\quad}}#3}. Therefore, the following quite easy set up should actually work:

\documentclass{amsbook}

\begin{document}

\setcounter{tocdepth}{3}
\tableofcontents

\section{section A}

\section*{%
    \for{toc}{\protect\hphantom{\thesection.\quad}section B}%
    \except{toc}{section B}%
}

\subsection{subsection 1}

\subsection*{%
    \for{toc}{\protect\hphantom{\thesubsection.\quad}subsection 2}%
    \except{toc}{subsection 2}%
}

\subsubsection{subsubsection a}

\subsubsection*{%
    \for{toc}{\protect\hphantom{\thesubsubsection.\quad}subsubsection b}%
    \except{toc}{subsubsection b}%
}

\subsubsection{subsubsection c}

\end{document}

enter image description here

The counters \thesection, \thesubsection and \thesubsubsection hold the value of the section, subsection or subsubsection before, in case of being the first entry, it is just zero. Thus, it should work even if there the very first entry is numberless.

4
  • Thanks! Do you know how to modify this so it works with unnumbered subsubsections (which is what I need in practice) rather than unnumbered sections? I tried some naive adjustments, but they exhibited odd behavior.
    – Chris
    Nov 27, 2021 at 15:54
  • You are right. Applying the above suggestion results in huge spacing. I need to look into this. Nov 29, 2021 at 8:20
  • @Chris I guess I got it. But you may want to check with your concrete set up. Might be different there, depending on whether or not you edited the styling of the TOC. Nov 29, 2021 at 16:21
  • This worked perfectly, thanks!
    – Chris
    Nov 30, 2021 at 1:55

You must log in to answer this question.

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