
我正在使用該tcolorbox
包,並且由於該功能attach boxed title to top left
,超級目標錨定在主框的頂部而不是標題框的頂部。
也就是說,當我點擊第 2 頁的連結時,下面給出的程式碼 (MWE) 會產生此結果。
正如您所看到的,標題框被“裁剪”了。
問題
如何修補此問題以使
hyperref
目標精確錨定在標題框的頂部? (理想情況下,解決方案也應該與 一起使用cleveref
)。
代碼:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage[colorlinks=true]{hyperref}
\NewTColorBox[auto counter]{thmboxB}{O{} O{}}{%
title = {theorem~(#1)},
enhanced,
attach boxed title to top left = {yshift = -\tcboxedtitleheight/2, xshift = 5mm},
top = 1.2em,
#2
}
\begin{document}
\begin{thmboxB}[Wow][label=thmB]
Let $Y$ be a set.
\end{thmboxB}
\newpage
theorem \ref{thmB}
\end{document}
答案1
您可以放大 hyperref 提升錨點的量:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage[colorlinks=true]{hyperref}
\NewTColorBox[auto counter]{thmboxB}{O{} O{}}{%
code={\renewcommand\HyperRaiseLinkDefault{2\baselineskip}},%<---
title = {theorem~(#1)},
enhanced,
attach boxed title to top left = {yshift = -\tcboxedtitleheight/2, xshift = 5mm},
top = 1.2em,
#2
}
\begin{document}
\begin{thmboxB}[Wow][label=thmB]
Let $Y$ be a set.
\end{thmboxB}
\newpage
theorem \ref{thmB}
\end{document}
這自然會影響框內的所有錨點,因此如果您想再次減少其中的數量,請將類似的程式碼放在內容部分的開頭。