# Reference (with hyperref) does not work in section heading (shows only question marks)

I have the following strange problem. I think the minimal working example below is self-explanatory. You can find the imsart-style file here.

\documentclass[aop,preprint]{imsart}
\RequirePackage{amsthm,amsmath,amsfonts,amssymb}
\RequirePackage[numbers]{natbib}
\RequirePackage{mathtools}

\startlocaldefs

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]

\endlocaldefs

\begin{document}

\tableofcontents

\section{Introduction}
\begin{theorem} \label{theo} This is the first theorem.
\end{theorem}

\section{Proof of \texorpdfstring{\hyperref[theo]{Theorem \ref*{theo}}}{Theorem 1.1}}

In this section heading the reference does work.

\begin{appendix}

\section{Proof of \texorpdfstring{\hyperref[theo]{Theorem \ref*{theo}}}{Theorem 1.1}}

\end{appendix}

\end{document}

The class does \MakeUppercase, which also transforms the argument to \ref.

Use textcase with the overload option.

Note that I removed the unnecessary \texorpdfstring. Also appendix is not an environment, use \appendix.

Also \RequirePackage should be \usepackage.

\documentclass[aop,preprint]{imsart}
\usepackage{amsthm,amsmath,amsfonts,amssymb}
\usepackage[numbers]{natbib}
\usepackage{mathtools}

\startlocaldefs

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]

\endlocaldefs

\begin{document}

\tableofcontents

\section{Introduction}
\begin{theorem} \label{theo} This is the first theorem.
\end{theorem}

\section{Proof of Theorem \ref{theo}}

In this section heading the reference does work.

\appendix

\section{Proof of Theorem \ref{theo}}

\end{document}

You can make the whole “Theorem 1.1” a link by using \autoref, but you need to supplement textcase list of commands exempt from uppercasing their argument and to change the autoref name.

\documentclass[aop,preprint]{imsart}
\usepackage{amsthm,amsmath,amsfonts,amssymb}
\usepackage[numbers]{natbib}
\usepackage{mathtools}
\usepackage{etoolbox}

\startlocaldefs

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\makeatletter
\patchcmd{\@uclcnotmath}
{\ref}
{\ref\@nonchangecase\autoref}
{}{}
\makeatother

\endlocaldefs

\begin{document}

\tableofcontents

\section{Introduction}
\begin{theorem} \label{theo} This is the first theorem.
\end{theorem}

\section{Proof of \autoref{theo}}

In this section heading the reference does work.

\appendix
\renewcommand{\theoremautorefname}{THEOREM}

\section{Proof of \autoref{theo}}

In this section heading the reference does not work. Surprisingly,