我有一个类似的问题(将定理变成链接),但我无法进行相应的调整。
我在附录中有一些证明,我想有一个定理环境,其中标题链接到证明。例如,
\begin{linkthm}{\ref{proof:ex_thm}} \label{ex_thm}
\end{linkthm}
谢谢你!
答案1
我建议您使用软件包提供的\hypertarget
/机制。这两个命令都接受两个参数;链接的此类命令对的第一个参数应该相同。\hyperlink
hyperref
在下面的例子中,在 pdf 文件中单击定理标题中的单词“Pythagoras”将使读者看到相关的证明。
\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
您可以尝试修复锚点的位置,因为raiselinks
(这应该有效)似乎还不够。
\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}