将定理变成链接

将定理变成链接

可以使用代码创建到另一个文件的链接

\href{run:/path/to/my/file.ext}{text displayed}

现在我使用 amsthm 包。我希望短语“定理 X”成为指向另一个文件(写有证明的位置)的链接。这可以实现吗?

答案1

是的。只需定义一个合适的定理样式:

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

\newtheoremstyle{linked}
  {}%      Space above, empty = `usual value'
  {}%      Space below
  {\itshape}% Body font
  {}%         Indent amount (empty = no indent, \parindent = para indent)
  {\bfseries}% Thm head font
  {.}%        Punctuation after thm head
  { }%     Space after thm head: " " = normal interword space;
     %     \newline = linebreak
  {\href{run:\thislink}{\thmname{#1} \thmnumber{#2}}\thmnote{ (#3)}}% Thm head spec

\newtheorem{thm}{Theorem}[section] % normal theorems

\theoremstyle{linked}
\newtheorem{innlinkthm}[thm]{Theorem} % theorems with link
\newenvironment{linkthm}[1]
 {\def\thislink{#1}\innlinkthm}
 {\endinnlinkthm}

\begin{document}
\section{Theorems}

\begin{thm}
This is a normal theorem.
\end{thm}

\begin{linkthm}{./somefile.pdf}
This has a link.
\end{linkthm}

\begin{linkthm}{./somefile.pdf}[Attribution]
This has the same link.
\end{linkthm}

\end{document}

在此处输入图片描述

相关内容