# How does one reference theorem names in a section title in the amsbook class? [duplicate]

I would like to reference the name of a theorem in a section title. Everything about this works fine, but on the page headers, one sees (??) instead of the Theorem number in the displayed section title.

I realize that this question has been asked before, but the answers did not enable me to solve my particular problem. The consensus on the other questions seems to be that one should "use protect" to fix this, but that is not working.

(1) Most likely, this is because I misunderstood the other answers -- this seems to be a rather complicated issue with TeX, and, even after reading other posts, I still really don't understand the underlying difficulty, or, for that matter, why there should even be an problem. It doesn't seem like this should be hard for TeX to implement: scan for uses of \label to generate a list of labels. Then, any time \ref is used, substitute the appropriate label -- I don't see why it should matter that \ref is being called in some subroutine, e.g. the one that generates page headers.

(2) Possibly because one needs to modify things somewhat in the amsbook document class, which is the class in which I am working.

Here is a MWE which illustrates the problem:

\documentclass{amsbook}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}

\begin{document}

\section{Section One}

\begin{theorem}\label{t:foo}
\end{theorem}

\section{Proof of Theorem \protect\ref{t:foo}}

\end{document}


EDIT: One should insert some text into the above example in order to see the failed page headers in the compiled document.

Thank you!