
私は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}
これは当然、ボックス内のすべてのアンカーに影響するため、ここでもアンカーの量を減らしたい場合は、コンテンツ部分の先頭に同様のコードを入れます。