# Fix for amsart.cls tableofcontents bug regarding starred sections?

The command \section* is meant to produce a section that is not listed in the table of contents. However, when using amsart.cls, such sections are still listed. I believe this is a known bug.

How can I get around it, that is, produce an unnumbered section that is not listed in the table of contents, while still using amsart.cls?

Thanks!

For example, compiling the following twice produces the erroneous entry in the TOC:

\documentclass{amsart}
\begin{document}
\setcounter{tocdepth}{2}
\tableofcontents
\section{Numbered}
\section*{Still here}
\end{document}

-
Welcome to TeX.SX! A tip: to format inline code, surround it with backticks (...code...); and to format code blocks, prepend four spaces to each line. Alternatively, the 101010 button will do what you want. –  Antal S-Z Jan 3 '11 at 4:24
According to section 2.14 of the amsclass manual this is desired behavior and not a bug. After all the class is for producing articles for publication in AMS journals. The code listed in the manual might give a hint on how to hack it though. –  Carsten Thiel Jan 3 '11 at 6:32

## 2 Answers

carsten's answer -- that this is ams style -- is correct.

in the next update of the ams-latex collection, the amsclass manual will contain an appendix laying out the differences between the ams classes and the basic latex equivalents. but the inclusion of starred headings in the toc will not change.

to get rid of unwanted entries from the table of contents, see this entry in the ams author faq: http://www.ams.org/faq?faq_id=238 . kindly take note that the way \SkipTocEntry is defined depends on whether or not the hyperref package is being used. (we will consider including such a command -- with a safeguard to handle presence or absence of hyperref -- in the upgrade, which, if all goes well, is expected to be scheduled for later this year.)

-
Thanks for this, that's good to know. –  Chris Jan 4 '11 at 19:36
I didn't quite manage to fix it from the ams faq page. When I follow (I think) the code given, the new toc entry is before the old one, so the new one is skipped. (Moving the \add command after the 1st par works, but then the p.num can be wrong.) For example: \documentclass{amsart} \DeclareRobustCommand{\SkipTocEntry}[4]{} \begin{document} \setcounter{tocdepth}{2} \tableofcontents \subsection{Heading} Text. \addtocontents{toc}{\SkipTocEntry} \subsection*{Old heading} \addtocontents{toc}{\protect\contentsline{subsection}{\protect\tocsubsection{}{} {New heading}}{\thepage}} Text. \end{document} –  Chris Jan 4 '11 at 19:44
@chris: but you really didn't need to add anything, just suppress the one that you didn't want. the \addtocontents code after the \subsection*{...} should be removed from your file. (maybe i was trying too hard when i wrote the faq entry to avoid putting in two examples. if you found it confusing, say so, and i'll revise it.) –  barbara beeton Jan 4 '11 at 22:39
Actually, I was trying to do exactly what you addressed in the faq, namely replace one heading with another. I just already knew about \addtocontents, so didn't ask about that part. Here's my present issue: the code listed in the faq works perfectly with documentclass amsbook; moreover it works perfectly with documentclass amsart, provided you substitute every instance of "chapter" with "section", but I'm finding that it doesn't work when I use "subsection", which is the level of heading I wanted to change. Hmmmm. –  Chris Jan 6 '11 at 18:50
Here's the code that I'd expect to work, but doesn't (and I have the same issue with the starred version): \documentclass{amsart} \DeclareRobustCommand{\SkipTocEntry}[4]{} \begin{document} \tableofcontents \addtocontents{toc}{\SkipTocEntry} \subsection{Heading that should be replaced} \addtocontents{toc}{\protect\contentsline{subsection} {\protect\tocsubsection{}{} {Substitute toc text}} {\thepage}} Some text. \end{document} –  Chris Jan 6 '11 at 18:51

i promised another answer, and here's an outline.

create two new commands, \noTOC and \TOConly that can be applied to text within a heading argument. for the table of contents, \def\noTOC#1{} to ignore its argument and \def\TOConly#1{#1} to set this material; when setting the heading itself, \def\TOConly#1{} to ignore, and \def\noTOC#1{#1} to output.

at the ams, we are using this technique in production, and the definitions are buried in a config file. some of these definitions are embedded in other definitions that are rather complicated, and i haven't yet managed to tease out a minimal set of definitions that can be added to the preamble of a document without fouling up anything else. part of the problem is that running heads have to be handled correctly at the same time. there have been requests from authors for this facility, and it is on our list of things to be considered, and probably implemented, in the next upgrade of the ams document classes. but i do hope to have a standalone patch before then, which i will post here.

this method works very well for two versions of a heading that differ only slightly, such as adding a linebreak in either the toc or in-text heading (but not both, or in separate locations) or omitting or changing a few words. but it should probably work equally well to give totally different texts for the two locations.

-
Okay, thanks for the additional information, and I look forward to any further patch you come up with in time. Cheers. –  Chris Jan 19 '11 at 6:18