# subtle issue when changing font style of the toc in connection with the header of the page

I am using the amsbook class and changed the font style of the title of the table of contents (toc) with the command

\renewcommand{\contentsname}{\textbf{\textsf{Contents}}}


So I want it in \sf style and bold face letters. The toc has two pages, and on the second page there appears a header line with CONTENTS written in smallcaps, also in \sf and bold face letters. I however do not want it to be bold face here. Is there a simple solution to change that? If it is complicated I guess I just live with the default amsbook style. Thanks anyway for any suggestions!

-

Redefining the formatting directly changing \contentsname is not a good idea since the changes will also affect the headers and (an eventual) entry in the ToC. Given the way \@starttoc is defined in amsbook, you need to redefine \@starttoc; the following example shows the necessary redefinition that will produce the desired effect (it will also apply the formatting to the titles of the LoF and the LoT):

\documentclass{amsbook}

\makeatletter
\def\@starttoc#1#2{%
\begingroup
\let\secdef\@gobbletwo \chapter
\let\@secnumber\@empty % for \@tocwrite and \chaptermark
\ifx\contentsname#2%
\else \@tocwrite{chapter}{#2}\fi
\typeout{#2}\@xp\chaptermark\@xp{#2}%
\makeatletter
\@input{\jobname.#1}%
\if@filesw
\@xp\newwrite\csname tf@#1\endcsname
\immediate\@xp\openout\csname tf@#1\endcsname \jobname.#1\relax
\fi
\global\@nobreakfalse \endgroup
\newpage
}
\makeatother

\begin{document}

\tableofcontents
\listoftables
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}
\chapter{Test}\section{test}\section{test}

\end{document}


The upper part of the first and second pages of the ToC:

-
Thanks for help! It works perfectly :) –  Britzel Sep 25 '12 at 12:27

You should not subvert the \contentsname for changing the formatting, it is merely meant to hold the actual name of the table of contents, and as you experience it is used more than one place. What you see on the second page is the running head.

The formatting for the heading of tableofcontents, and other such lists, is controlled by an internal command called \@makeschapterhead. You can redefine as follows to get bold sans-serif for the headings of all of these lists:

\documentclass{amsbook}

\makeatletter
\begingroup
\fontsize{\@xivpt}{18}\bfseries\sffamily\centering
#1\par \endgroup
\vskip\skip@ }
\makeatother

\begin{document}
\tableofcontents

\chapter{Test}

\end{document}


Should you just wish to change the formatting for the table of contents then you can use the following which switches to a custom style just for the \tableofcontents command:

\documentclass{amsbook}

\makeatletter
\begingroup
\fontsize{\@xivpt}{18}\bfseries\sffamily\centering
#1\par \endgroup
\vskip\skip@ }
\makeatother

\begin{document}
\tableofcontents
\listoffigures

\chapter{Test}

\end{document}


-
The command \patchcmd{\@makeschapterhead}{\bfseries}{\bfseries\sffamily}{}{} (needs etoolbox and the usual \makeat...) is easier and perhaps more maintainable. For the second method you can \let\@maketochead\@makeschapterhead and patch \@maketochead, then redefine \tableofcontents in the same way as you already do. –  egreg Sep 24 '12 at 20:01
@egreg That certainly an interesting variation. I am little wary of \patchcmd though, as obtaining the correct effect requires some stable knowledge of the definititon of the command being patched. –  Andrew Swann Sep 25 '12 at 9:36
Hi and thanks for your answer! I adopted Gonzalo Medina's approach now. Your's might be useful as well for me in the future! Thanks! –  Britzel Sep 25 '12 at 12:29