3

The page numbers in a table of contents often sit far to the right of the titles. Since we rarely look at a table of contents from top to bottom, and often from left to right, it might be better to have the numbers sit next to the title. What is a simple way to make this happen in the amsart class?

An example of different table of contents styles

\documentclass{amsart}
\usepackage{blindtext}
\usepackage{enumitem}
\title{}
\begin{document}
\maketitle
\tableofcontents
\begin{center}
\textsc{Contents} \\[6pt]
\begin{minipage}{7cm}
\begin{enumerate}[label=\arabic*.]
\item My childhood theorems, 1
\item Theorems from my adolescence, 2
\item Undergraduate theorems, 3 
\item Graduate theorems and my thesis, 4
\end{enumerate}
\end{minipage}
\end{center}
\section{My childhood theorems} \blindtext[5]
\section{Theorems from my adolescence} \blindtext[5]
\section{Undergraduate theorems} \blindtext[5]
\section{Graduate theorems and my thesis} \blindtext[5]
\end{document}

I tried the following:

\begin{center}
\begin{minipage}{8cm}
\begingroup
\def\hfil{,\relax}
\tableofcontents
\endgroup
\end{minipage}
\end{center}

instead of \tableofcontents. Is this a bad idea?

1 Answer 1

3

Not a bad idea at all. Bringhurst says we don't have to add up the page numbers, so why should they be in a column far away from the title?

You can modify the working of \@tocline; for centering the table of contents, assuming it fits in one page, you can use varwidth.

\documentclass{amsart}
\usepackage{varwidth}
\usepackage{blindtext}

\makeatletter
\def\@tocline#1#2#3#4#5#6#7{\relax
  \ifnum #1>\c@tocdepth % then omit
  \else
    \par \addpenalty\@secpenalty\addvspace{#2}%
    \begingroup \hyphenpenalty\@M
    \@ifempty{#4}{%
      \@tempdima\csname r@tocindent\number#1\endcsname\relax
    }{%
      \@tempdima#4\relax
    }%
    \parindent\z@ \leftskip#3\relax \advance\leftskip\@tempdima\relax
%    \rightskip\@pnumwidth plus4em \parfillskip-\@pnumwidth
    #5\leavevmode\hskip-\@tempdima #6\nobreak\relax
    ,~#7\par
%    \hfil\hbox to\@pnumwidth{\@tocpagenum{#7}}\par
%    \nobreak
    \endgroup
  \fi}
\makeatother


\begin{document}
\title{Whatever}
\maketitle

\begin{center}
\begin{varwidth}{\textwidth}
\tableofcontents
\end{varwidth}
\end{center}

\section{My childhood theorems} 
\subsection{Whatever}
\blindtext[5]
\section{Theorems from my adolescence} \blindtext[5]
\section{Undergraduate theorems} \blindtext[5]
\section{Graduate theorems and my thesis} \blindtext[5]
\end{document}

I added a subsection just to show its output.

enter image description here

You must log in to answer this question.

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