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.

Chris
  • 1,183

1 Answers1

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.

  • 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 '21 at 15:54
  • You are right. Applying the above suggestion results in huge spacing. I need to look into this. – Jasper Habicht Nov 29 '21 at 08: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. – Jasper Habicht Nov 29 '21 at 16:21
  • This worked perfectly, thanks! – Chris Nov 30 '21 at 01:55