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?

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


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
\begingroup \hyphenpenalty\@M
\@ifempty{#4}{%
\@tempdima\csname [email protected]\number#1\endcsname\relax
}{%
\@tempdima#4\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{Graduate theorems and my thesis} \blindtext[5]
\end{document}



I added a subsection just to show its output.

## Related post

I am trying to create table of contents for starred version of chapter. My goal is to align all first letters of the titles to the same position. I was able to achieve that separately for single digit numbers and for double digit numbers, but I am no

• Report document class with upper right page numbers and modifying chapter title format 2013-07-18

I'm writing a lengthy masters thesis paper and am requiring some annoying editing of my TeX document. I need to have all of my main headers (table of contents, list of figures, list of tables, bibliography, and chapter headers) to be centered and at

• How to add page numbers and rotated chapter title to the outer margin? 2015-11-27

I'd like to have page numbers on the outer page border slightly bellow the center, and the current chapter title at the bottom but rotated 90 degrees counter-clockwise (i.e. to the left) such that it also sticks to the page outer border, i.e. +------

Problem The following code is used to prevent pagination from being applied to the index: \setuphead[chapter,section][ number=no, page=yes, continue=no, ] \definehead[StyleIndex][chapter] \setuphead[StyleIndex][ page=no, ] The index is typeset as fol

If I use code such as: \chapter{Introduction} \subfile{intro/Introduction} \chapter{Remaining Work} \subfile{remaining/Remaining} The result is: Chapter 1 Introduction Chapter 2 Remaining Work I'd like to remove the "Chapter 1" etc title, prefer

I am writing a book that I will publish in two separate volumes. In volume 1, I want the table of contents to show the full list of chapters for volume 1 and volume 2, however I do not want volume 2 chapters to be included in published version of vol

• Giant number next to chapter title 2015-05-08

I want to make chapter titles that look something like this: I'll be using a different font, but the idea is the same. If possible, I'd like it to work like this: Pick the size of the number (one should be able to make it arbitrarily large). The top

I'm using the book style, and I've got a title and ToC, they generate a lot of blank spaces after them that is completely unnecessary; how do I stop this behaviour? Here is my example code \documentclass[12pt]{book} \usepackage[width=4.375in, height=

When I tried \lstlistoflistings to print the list of all my listing, the title says "Table of contents", and then it says chapter. Like if it was part of the TOC. I'm trying to get a list, like the one you get in algorithms or in figure list. I

I have a master table of contents that works like a charm, and each section is broken out appropriately with page breaks v sections. For each section, I would like to have another table of contents for only that section. Is that possible? I'm in Page

I am finishing up my dissertation and have a small issue. The dissertation format asks for single spacing the chapter heading in table of contents if it is too long and can't fit in one line. The same goes for list of figures and captions. I followed

I know that I'm supposed to search for data in a Wiki but I would like to structure the data in some kind of tree. Is this possible? Right now I just have pages that do not really belong to anything so to get there I need to search and when doing tha

I am currently trying to make a Table of Contents for each site page for my team. I have tried the default SP table of contents web part but it doesn't work and gives me an error such as this: "Cannot save all of the property settings for this Web Pa

• Is the user experience of a long, multi-page article improved by having a fixed table of contents? 2016-07-18

Let's say you have a gigantic article (up to 30 pages) with lots of chapters and you want to display on your website and let's say you have created a page just for this particular article. Should you have a fixed Table of Contents on it's side? Does

• How do I remove numbering from the chapter titles? 2013-04-26

It seems I have a two day trying to find out the solution of my problem. I have just finished typing my M.Sc thesis using LATEX (MIKTEX 2.9). Unfortunately, all my chapters begin with the chapter number at the top left corner of a page. My supervisor

• How can I add a page break after a chapter title? 2012-12-12

I'd like to have a page that is mostly blank, but just shows the chapter number and the title, and maybe a small summary of the chapter, followed by white space... The actual sections will start on the following page. How can I accomplish this? Every

• How to show a full page width image above chapter title, and different image for each chapter? 2015-04-26

I'm trying to make the chapter header follow the style: - Chapter tittle is on its own page. - There is an image with full page width above the title, and different image for each chapter. - Optional: the image have caption, and can be link to list o

• make footnote number appear next to chapter title 2016-07-18

I would like a footnote number to appear right next to a chapter title (instead of below it) to cite a co-author of this particular chapter. \documentclass{report} \begin{document} \chapter{hello}\footnote{another author} \end{document} This puts the