有没有一个简单的修复方法来在 thmtools 的“restatable”中使用“\hypertarget”?

有没有一个简单的修复方法来在 thmtools 的“restatable”中使用“\hypertarget”?

可以\hypertarget在内部使用吗restatable?该命令\hypertarget来自包hyperrefrestatable来自包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}

输出:

MWE 的输出

答案1

基于乌尔丽克·菲舍尔的有用评论(12)解决方案是

[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

相关内容