我正在使用具有可重述定理的 ntheorem,并且我希望从重述定理到原始定理(可重述定理)有一个链接回(超链接)。MWE:
\documentclass{memoir}
\usepackage{ntheorem}
\usepackage{thm-restate}
\newtheorem{theorem}{Theorem}
\begin{document}
\chapter{One}
\begin{restatable}{theorem}{th}
Blah
\end{restatable}
\chapter{Two}
%Should link back to restatable in Chapter One
%(without extra \ref, but directly within \th*)
\th*
\end{document}
谢谢您的任何提示,谨致问候
答案1
以下方法可行。如果您想使用其他定理样式,您也必须对其进行调整:
\documentclass{memoir}
\usepackage{ntheorem}
\usepackage{thmtools,xpatch}
\makeatletter
\xpatchcmd \thmt@restatable{\@xa\protected@edef\csname the#2\endcsname}
{\def\thmt@tmp@restatename{#3}\@xa\protected@edef\csname the#2\endcsname}{}{\fail}
\renewtheoremstyle{plain}%
{\item[\hskip\labelsep \theorem@headerfont ##1\
\ifcsname thmt@tmp@restatename\endcsname
\ifthmt@thisistheone ##2\else\ref{thmt@@\thmt@tmp@restatename}\fi
\else ##2\fi
\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\
\ifcsname thmt@tmp@restatename\endcsname
\ifthmt@thisistheone ##2\else\ref{thmt@@\thmt@tmp@restatename}\fi
\else ##2\fi
\ (##3)\theorem@separator]%
}
\makeatother
\newtheorem{theorem}{Theorem}
\usepackage{hyperref}
\begin{document}
\chapter{One}
\begin{theorem}
some theorem
\end{theorem}
\begin{restatable}{theorem}{th}
Blah
\end{restatable}
\chapter{Two}
%Should link back to restatable in Chapter One
%(without extra \ref, but directly within \th*)
\th*
\end{document}
如果链接中应包含单词“定理”(或其他),则可以使用以下定理样式:
\renewtheoremstyle{plain}%
{\item[
\ifcsname
thmt@tmp@restatename\endcsname
\ifthmt@thisistheone
\hskip\labelsep \theorem@headerfont ##1\ ##2
\else
\mbox{\hyperref[thmt@@\thmt@tmp@restatename]{\theorem@headerfont ##1~##2}}
\fi
\else
\hskip\labelsep \theorem@headerfont ##1\ ##2
\fi
\theorem@separator]}%
{\item[
\ifcsname
thmt@tmp@restatename\endcsname
\ifthmt@thisistheone
\hskip\labelsep \theorem@headerfont ##1\ ##2
\else
\mbox{\hyperref[thmt@@\thmt@tmp@restatename]{\theorem@headerfont ##1~##2}}
\fi
\else
\hskip\labelsep \theorem@headerfont ##1\ ##2
\fi
\ (##3)\theorem@separator]%
}