可以\hypertarget
在内部使用吗restatable
?该命令\hypertarget
来自包hyperref
,restatable
来自包thmtools
问题是,如果调用可重置函数,它似乎会尝试重新创建早期超目标的目的地,并使用相同的标识符:
pdfTeX warning (ext4): destination with the same identifier (name{thm:\040made-up-theorem-subpart}) has been already used, duplicate ignored
<to be read again>
\relax
l.30 \MadeUpTheorem*
[3] (./output.aux)
- 似乎有不不利影响哎呀,因为“忽略重复”正是所需的行为。但我想知道,是否有更好的方法可以避免该问题但保留相同的功能?
梅威瑟:
\documentclass{book}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{hyperref}
\declaretheorem[numberwithin=chapter, style=plain,name=Theorem,refname={theorem,theorems},Refname={Theorem,Theorems}]{theorem}
\begin{document}
\chapter{Test chapter 1}
\section{Test section 1}
In the next section, we we'll state a made-up theorem. Notice, in particular, the subpart \hyperlink{thm: made-up-theorem-subpart}{there}. Here...
\section{Test section 2}
We are ready to state the made-up theorem:
\begin{restatable}[Made-Up theorem]{theorem}{MadeUpTheorem} %%%% creating an instance of restatable
Made-up assumptions are listed here.
{\hypertarget{thm: made-up-theorem-subpart}{}} %%%% referencing a sub-part of madeuptheorem.
\[ X = 3AB \tag{*}\]
This is a made-up theorem.
\end{restatable}
\chapter{Test chapter two}
Recall the following made-up theorem:
\MadeUpTheorem* %%%%madeuptheorem is recalled, creating the duplicate destination
\end{document}
输出:
答案1
[S]
\hypertarget
用包装纸包\ifthmt@thisistheone
起来\fi
。
由于它包含字符@
,因此必须依次添加包装器\makeatletter
和\makeatother
来包围整个环境,在本例中为restatable
。
因此相关的改变是:
\makeatletter %%% <--- added
\begin{restatable}[Made-Up theorem]{theorem}{MadeUpTheorem}
Made-up assumptions are listed here.
\ifthmt@thisistheone{\hypertarget{thm: made-up-theorem-subpart}{}}\fi %%% <--- changed
\[ X = 3AB \tag{*}\]
This is a made-up theorem.
\end{restatable}
\makeatother %%% <--- added