请参阅校样打印部分

请参阅校样打印部分

我在一份文档中列出了几条定理,其证明在附录中。在某条定理之后,我想引用其证明,并且使用该hyperref包,我想使引用可点击,以避免滚动。

但是,在证明上添加标签然后引用它(我也使用包cleveref)会引用并链接到包含证明的相应部分,在我的示例中是附录。

梅威瑟:

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{cleveref}
\newtheorem{theorem}{Theorem}

\begin{document}
\section{Theorems}
\begin{theorem}\label{thm:some-theorem}
This is a theorem.
\end{theorem}

For an initution, see the proof.

For an intiution, see \cref{proof:some-theorem}.

\appendix
\section{Proofs}
\begin{proof}[Proof of \Cref{thm:some-theorem}]
\label{proof:some-theorem}
This is a proof.
\end{proof}
\end{document}

在此处输入图片描述

我怎样才能获得打印“证明”(或“定理 1 的证明”)的参考,并且超链接也链接到证明?

答案1

您可以使用相同的标签建立双向链接。

\documentclass{article}
\usepackage{amsthm}
\usepackage[colorlinks]{hyperref}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}
\newenvironment{delayedproof}[1]
 {\begin{proof}[\raisedtarget{#1}Proof of \Cref{#1}]}
 {\end{proof}}
\newcommand{\raisedtarget}[1]{%
  \raisebox{\fontcharht\font`P}[0pt][0pt]{\hypertarget{#1}{}}%
}
\newcommand{\proofref}[1]{\hyperlink{#1}{proof}}

\begin{document}
\section{Theorems}
\begin{theorem}\label{thm:some-theorem}
This is a theorem.
\end{theorem}

For an intuition, see the \proofref{thm:some-theorem}.

\appendix
\section{Proofs}
\begin{delayedproof}{thm:some-theorem}
This is a proof.
\end{delayedproof}
\end{document}

在此处输入图片描述

图片显示“证明”链接指向正确的证明。需要抬起\hypertarget否则链接将指向证明第一行的基线。

答案2

OP 已经指出了这个问题:

proof是一个无计数器环境,即没有计数器连接到它,因此\label内部proof将抓取最后的\@currentlabel,这已被修改\refstepcounter{section}\section{Proofs}因此\cref报告section或`附录。

我的方法添加了一个\prooflabel与所涉及的相关标签的定理计数器的计数器值相连的计数器,这样定理 147 将提供证明 147。

为了简化这一点,\crtcrefcountervalue(包中的新添加crossreftools)被应用并注入到proofcntr计数器中。

我也cleveref为其添加了名称。proofcntr

\documentclass{article}
\usepackage{etoolbox}

\usepackage{xparse}

\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{cleveref}


\usepackage{crossreftools}


%%% The following lines are not necessary with crossreftools v.0.8
\makeatletter
\@ifundefined{crtcrefcountervalue}{%
\newcommand{\crt@crefundefinedcountervalue}{1977}
\newcommand{\crtrefundefinedcountervalue}[1]{\renewcommand{\crt@refundefinedcountervalue}{#1}}


\newcommand{\crtcrefcountervalue}[1]{%
  \crtcrefifundefinedlabel{#1}{%
    \crt@crefundefinedcountervalue%
  }{%
    \crtcrefnumber{#1}%
  }%
}
}{}

\makeatother



\newtheorem{theorem}{Theorem}

\newcounter{proofcntr}
\crefname{proofcntr}{proof}{proofs}
\Crefname{proofcntr}{Proof}{Proofs}

\NewDocumentCommand{\prooflabel}{+m+m}{%
  \setcounter{proofcntr}{\numexpr\crtcrefcountervalue{#1}-1}%
  \refstepcounter{proofcntr}%
  \label{#2}%
}

\begin{document}
\section{Theorems}
\begin{theorem}\label{thm:some-theorem}
This is a theorem.
\end{theorem}

For an intuition, see the proof.

For an intuition, see \cref{proof:some-theorem}, but with respect to \cref{thm:some-really-important-theorem} see the best proof ever: \cref{proof:some-really-important-theorem}


\begin{theorem}\label{thm:some-really-important-theorem}
Brontosaurs are thin at one end, thick in the middle and thin at the other end. 

Source: Anne Elk (Misses). 
\end{theorem}


\appendix
\section{Proofs}
\begin{proof}[Proof of \Cref{thm:some-theorem}]
\prooflabel{thm:some-theorem}{proof:some-theorem}
This is a proof.
\end{proof}


\begin{proof}[Proof of \Cref{thm:some-really-important-theorem}]
\prooflabel{thm:some-really-important-theorem}{proof:some-really-important-theorem}

The source is Anne Elk (Misses), that's enough ;-)
\end{proof}

\end{document}

在此处输入图片描述

答案3

这个怎么样?

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\newtheorem*{theorem}{Theorem}

\begin{document}

\begin{theorem}
  \phantomsection\label{theorem:main}
  This is true.
\end{theorem}

\begin{proof}
  \phantomsection\label{proof:main-theorem}
  Obvious.
\end{proof}

The \hyperref[proof:main-theorem]{proof} of
the \hyperref[theorem:main]{theorem} is obvious.

\end{document}

相关内容