4

I would like to obtain an advice regarding the TOC for an article. I wonder if the following serpent-like output caused by numbers of subsections being longer than those of sections is my mistake or is intended like that by amsart? If not, I'd like to know, even manually, how to correct it? I have tried a double title (one in square brackets having more space before the text) but no result.

\documentclass{amsart}
% \usepackage{titletoc}
\usepackage{amsthm}
\usepackage[english]{babel}


\begin{document}


 \tableofcontents

%% -------------------------- 
\section{First Movement}
 \subsection{Allegro con brio} 
  \subsection{Allegro senza brio} 
  \section{Second Movement}
  \subsection{Adagio}
  \subsection{Piu adagio}
  \subsection{Ancora piu adagio}
  \section{Third Movement: ``la sveglia''}
 \section{Finale}
 \subsection{Prestisisimo}


\end{document}

enter image description here

4
  • 1
    Welcome to TeX - LaTeX! As it stands your question is asking for opinion based answers and as such is off topic. If you changed the question to just the "how?" part, then it would be on topic. Incidentally, it is no the width of the numbers that is causing this, it is a design decision from a reputable institution and the indentations are based on some fixed indents that depend on the section level. Commented Aug 15, 2016 at 12:51
  • 1
    @AndrewSwann -- actually, this is not a conscious design decision. it is the unfortunate consequence of a delay in making an appropriate decision -- no changes should be made without written specs. the specs were not forthcoming within the time available to complete and post the class file, and unfortunately, updates have not been made regularly since then. this is definitely on the list for improvement! (but reasonable code does not yet exist.) Commented Aug 15, 2016 at 13:13
  • the question Table-of-Contents items appearing flush against the edge of the left margin is essentially identical, and should be closed as a duplicate if this question gets an upvoted answer. Commented Nov 11, 2017 at 19:26
  • @barbarabeeton now egreg gives a "sledgehammer solution"...
    – Hastur
    Commented Nov 13, 2017 at 9:27

2 Answers 2

2

A sledgehammer solution:

\documentclass{amsart}
\usepackage[english]{babel}

\makeatletter
\renewcommand{\l@section}{\@tocline{1}{0pt}{0pc}{}{}}
\renewcommand{\l@subsection}{\@tocline{2}{0pt}{0pc}{}{}}
\renewcommand{\tocsection}[3]{%
  \indentlabel{\@ifnotempty{#2}{\makebox[3em][l]{\ignorespaces#1 #2.}}}#3%
}
\let\tocsubsection\tocsection
\makeatother

\begin{document}

\tableofcontents

\section{First Movement}
\subsection{Allegro con brio} 
\subsection{Allegro senza brio} 

\section{Second Movement}
\subsection{Adagio}
\subsection{Pi\`u adagio}
\subsection{Ancora pi\`u adagio}

\section{Third Movement: ``la sveglia''}

\section{Finale}
\subsection{Prestissimo}

\end{document}

However, this should be refined when the number of sections is larger than nine; not so simple a task, if one wants it to be as general as possible.

enter image description here

1

another sledgehammer solution, but indenting the subsections as was originally intended for the ams document classes.

\documentclass{amsart}
\usepackage{amsthm}
\usepackage[english]{babel}

\makeatletter
\renewcommand{\l@section}{\@tocline{1}{0pt}{2pc}{}{}}
\renewcommand{\l@subsection}{\@tocline{2}{0pt}{3.5pc}{}{}}
\makeatother

\begin{document}

 \tableofcontents

%% -------------------------- 
\section{First Movement}
 \subsection{Allegro con brio} 
  \subsection{Allegro senza brio} 
  \section{Second Movement}
  \subsection{Adagio}
  \subsection{Piu adagio}
  \subsection{Ancora piu adagio}
  \section{Third Movement: ``la sveglia''}
 \section{Finale}
 \subsection{Prestisisimo}

\end{document}

output of example code

the ams document classes were originally intended to set the indentations automatically (after two runs) by posting to the .aux file the actual widths of the varions "section" numbers, and reading in these values on the next pass. the current version of the classes does write the information into the .aux file, but it never gets assigned to the correct elements. clearly a bug, but one that hasn't yet been deciphered.

2
  • My Italian self cries seeing “piu” without an accent and “Prestisisimo”. ;-)
    – egreg
    Commented Nov 13, 2017 at 18:53
  • just copied from the original, sigh. should have been able to catch the misspelled "prestissimo" though. (my familiarity with italian is only slightly more robust than my familiarity with spanish -- near zero. more comfortable in somewhat more northerly climes.) Commented Nov 13, 2017 at 18:59

You must log in to answer this question.

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