[Tex/LaTex] Using amsart, make running heads title of the current section

amsartheader-footersectioning

Using the amsart document class, how can I replace all the running heads with the title of the current section? Is there a way to do this natively in the class, or am I looking at needing fancyhdr, or something? What even is the command which fills in the name of the current section, and is it available in amsart?

Thanks so much.

Best Answer

The amsart class is a rather closed one. It disables commands such as \sectionmark and similar ones and also redefines the sectioning commands for not updating the marks necessary for the job.

It's possible to do it, but remember that something might go wrong, as it's complicated to keep up with all the adjustments the class does.

\documentclass{amsart}

\usepackage{regexpatch}

\usepackage{kantlipsum} % just for the example

%%% let's patch the amsart macros
\makeatletter
\renewcommand{\sectionmark}[2]{%
  \ifnum#1<\@m
    \markboth{\thesection. #2}{\thesection. #2}%
  \else
    \markboth{#2}{#2}%
  \fi}
\xpatchcmd*{\@sect}
  {\@tocwrite}
  {\csname #1mark\endcsname{#2}{#7}\@tocwrite}
  {}{}
\makeatother


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

\section{First}
\kant

\section{Second}
\kant

%%% let's provide a mock bibliography
\begin{thebibliography}{99}

\count255=0
\loop\ifnum\count255<60
\advance\count255 1
\expandafter\bibitem\expandafter{\number\count255 } x
\repeat

\end{thebibliography}


\end{document}

enter image description here