Sit page numbers next to chapter titles in table of contents for amsart

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?

Sit page numbers next to chapter titles in table of contents for amsart

\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?

Replay

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>\[email protected] % then omit
  \else
    \par \addpenalty\@secpenalty\addvspace{#2}%
    \begingroup \hyphenpenalty\@M
    \@ifempty{#4}{%
      \@tempdima\csname [email protected]\number#1\endcsname\relax
    }{%
      \@tempdima#4\relax
    }%
    \parindent\[email protected] \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.

Sit page numbers next to chapter titles in table of contents for amsart

Category: table of contents Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.124 (s). 12 q(s)