2

I have a similar question to (Making a theorem into a link) but I was not able to adjust it accordingly.

I have some proofs in an appendix and I would like to have a theorem environment where the header links to the proof. Something like,

\begin{linkthm}{\ref{proof:ex_thm}} \label{ex_thm}

\end{linkthm}

Thank you!

5
  • 3
    Welcome to TeX.SE! Could you extend your code to make it compile so that people don't have to build a small document themselves please? It helps people help you quicker, it only needs to be basic as in starting with your \documentclass{} and ending with \end{document}. Hope someone can answer!
    – piJT
    Commented Jun 20, 2023 at 12:30
  • 2
    Exactly what do you mean by THeorem header into a link in this context? I would just write The proof is on page \pageref{proof:ex_thm} after the theorem. Then it works with and without hyperlinks.
    – daleif
    Commented Jun 20, 2023 at 12:31
  • 1
    In the pdf it would say Theorem 4.1 and I would like this to be clickable and lead to the proof. I have a few theorems and I do not want to write after everyone the proof can be found in appendix xx. The link would just make it more conveniently findable.
    – bast3456
    Commented Jun 20, 2023 at 12:38
  • 1
    And what if the reader prints your document, then now they cannot find it. PDF is not a website the user can do what they want with it, so don't limit them.
    – daleif
    Commented Jun 20, 2023 at 12:58
  • I appreciate your concern for the reader but I would still like to know how it would work :)
    – bast3456
    Commented Jun 20, 2023 at 15:57

2 Answers 2

3

I suggest you make use of the \hypertarget/\hyperlink mechanism provided by the hyperref package. Both commands take two arguments; the first argument of a linked pair of such commands should be the same.

In the following example, clicking on the word "Pythagoras" in the theorem's header while in the pdf file will take the reader to the associated proof.

enter image description here


enter image description here

\documentclass{article}

\usepackage{amsthm} % or '\usepackage{ntheorem}'
\usepackage[colorlinks,allcolors=blue]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref} % optional
\newtheorem{theorem}{Theorem}

\begin{document}

\section{Main results}

\begin{theorem}[\hyperlink{proof:pyth}{Pythagoras}] \label{thm:pyth}
Let $a$, $b$, and $c$ denote the lengths of the sides 
of a \emph{right triangle}, i.e., of a triangle with 
one angle equal to $90^\circ$. Without loss of generality 
assume that $a\le b<c$. Then $a^2+b^2=c^2$.
\end{theorem}

\clearpage

\appendix

\section{Proofs of all theorems}

\begin{proof}[\hypertarget{proof:pyth}{Proof of \Cref{thm:pyth}}]
\dots
\end{proof}

\end{document}
2
  • Thanks for the suggestion I was thinking about doing it this way but not all my theorems are named and I also do not want to name them so I am afraid it won't work!
    – bast3456
    Commented Jun 20, 2023 at 15:59
  • 1
    @bast3456 - Is something stopping you from writing \hyperlink{proof:pyth}{[Click here to jump to proof]} after \begin{theorem}?
    – Mico
    Commented Jun 20, 2023 at 17:44
3

You can try and fix the position of the anchor, because raiselinks (which should work) doesn't seem to suffice.

\documentclass{article}

\usepackage{amsthm} % or '\usepackage{ntheorem}'
\usepackage[raiselinks,colorlinks,allcolors=blue]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref} % optional

\usepackage{lipsum}


\newtheorem{linkthminner}{\hyperlink{\linkthmlabel}{Theorem}}
\crefname{linkthminner}{theorem}{theorems}
\Crefname{linkthminner}{Theorem}{Theorems}

\NewDocumentEnvironment{linkthm}{mo}{%
  % #1 is the label, #2 the possible attribution
  \renewcommand{\linkthmlabel}{#1}%
  \IfNoValueTF{#2}{\linkthminner}{\linkthminner[#2]}\label{#1}%
}{\endlinkthminner}
\newcommand{\linkthmlabel}{}% initialize
\newenvironment{linkproof}[1]{%
  \proof[\hypertarget{#1}{\strut\proofname\ of \cref{#1}}.]%
}{\endproof}

\begin{document}

\section{Main results}

\begin{linkthm}{thm:a}
This is a theorem statement. \lipsum[2][1-5]
\end{linkthm}

\begin{linkthm}{thm:b}[Someone]
This is a theorem statement. \lipsum[2][1-5]
\end{linkthm}

\lipsum[1-10]

\appendix

\section{Proofs of all theorems}

\begin{linkproof}{thm:a}
\lipsum[1-2]
\end{linkproof}

\begin{linkproof}{thm:b}
\lipsum[1-2]
\end{linkproof}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .