Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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}%
  \@makeschapterhead{\sffamily#2}\@afterheading
  \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:

enter image description here

enter image description here

share|improve this answer
    
Thanks for help! It works perfectly :) –  Britzel Sep 25 '12 at 12:27
add comment

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
\def\@makeschapterhead#1{\global\topskip 7.5pc\relax
  \begingroup
  \fontsize{\@xivpt}{18}\bfseries\sffamily\centering
  #1\par \endgroup
  \skip@34\p@ \advance\skip@-\normalbaselineskip
  \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
\def\@maketochead#1{\global\topskip 7.5pc\relax
  \begingroup
  \fontsize{\@xivpt}{18}\bfseries\sffamily\centering
  #1\par \endgroup
  \skip@34\p@ \advance\skip@-\normalbaselineskip
  \vskip\skip@ }
\def\tableofcontents{{\let\@makeschapterhead\@maketochead\@starttoc{toc}\contentsname}}
\makeatother

\begin{document}
\tableofcontents
\listoffigures

\chapter{Test}

\end{document}

Sample contents page

Sample list of figures

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.