You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
\tcbhypernode{<macro>}{<node>} is expected to use <marco> to create a hyperlink having the same size of tikz node <node>. Currently in XeTeX such hyperlink is not created due to a XeTeX issue (actually I think the real culprit is xdvipdfmx).
As a workaround hyperref provides \XeTeXLinkBox{<link text>}, see texdoc hyperref, sec. 7.7 \XeTeXLinkBox and this answer by Heiko Oberdiek.
One possible patch:
% !TeX TS-program = xelatex\documentclass{article}
\usepackage[skins]{tcolorbox}
\usepackage{hyperref}
\makeatletter\renewcommand{\tcbhypernode}[2]{\ifdefined\hypersetup\@ifundefined{pgf@sh@ns@#2}{}{%\node[inner sep=0pt,outer sep=0pt] at (#2.center){%\tcbsetmacrotowidthofnode\tcb@w@hn{#2}%\tcbsetmacrotoheightofnode\tcb@h@hn{#2}%% debug: show size of hyperlink hence the need of altering \XeTeXLinkMargin% \hypersetup{pdfborder=0 0 0}%% change: wrap hyperlink text in \tcb@XeTeXLinkBox
#1{\tcb@XeTeXLinkBox{\vtop to \dimexpr\tcb@h@hn-2bp\relax{\hbox to \dimexpr\tcb@w@hn-2bp\relax{}\vfil}}}%
};%
}\fi}
\ifdefined\XeTeXversion\long\def\tcb@XeTeXLinkBox{%\setlength{\XeTeXLinkMargin}{0pt}%\XeTeXLinkBox}
\else\let\tcb@XeTeXLinkBox=\@firstofone\fi\makeatother\begin{document}
%\tcbset{mybox/.style={enhanced, colback=#1!10, colframe=#1!50!black}}\begin{tcolorbox}[enhanced,
colback=red!10,colframe=red!50!black,
hypertarget=hypertwinA,
hyperlink=hypertwinB,
title=Box A
]
Click me to jump to Box B.
\end{tcolorbox}
\begin{tcolorbox}[enhanced,
colback=blue!10,colframe=blue!50!black,
hypertarget=hypertwinB,
hyperlink=hypertwinA,
title=Box B (with \texttt{\string\XeTeXLinkBox})
]
Click me to jump to Box A.
\end{tcolorbox}
\makeatletter\let\tcb@XeTeXLinkBox=\@firstofone\makeatother\begin{tcolorbox}[enhanced,
colback=blue!10,colframe=blue!50!black,
hypertarget=hypertwinB2,
hyperlink=hypertwinA,
title=Box B2 (without \texttt{\string\XeTeXLinkBox})
]
Click me to jump to Box A.
\end{tcolorbox}
\newpage% make enough room for hyperlink scrolling/jumping\null\end{document}
Notes:
Although hyperref provides \XeTeXLinkBox for all engines, I choose to only use it in XeTeX, to gain maximum backward compatibility for other engines.
\XeTeXversion is used to test if it's in XeTeX. This is the same tester used by l3kernel in defining \c_sys_engine_str. Or if written in latex3 \sys_if_engine_xetex:TF can be used.
The text was updated successfully, but these errors were encountered:
(originally reported and answered in https://www.zhihu.com/question/586573750/answer/2913873055, in Chinese)
\tcbhypernode{<macro>}{<node>}
is expected to use<marco>
to create a hyperlink having the same size of tikz node<node>
. Currently in XeTeX such hyperlink is not created due to a XeTeX issue (actually I think the real culprit is xdvipdfmx).As a workaround
hyperref
provides\XeTeXLinkBox{<link text>}
, seetexdoc hyperref
, sec. 7.7\XeTeXLinkBox
and this answer by Heiko Oberdiek.One possible patch:
Notes:
hyperref
provides\XeTeXLinkBox
for all engines, I choose to only use it in XeTeX, to gain maximum backward compatibility for other engines.\XeTeXversion
is used to test if it's in XeTeX. This is the same tester used byl3kernel
in defining\c_sys_engine_str
. Or if written in latex3\sys_if_engine_xetex:TF
can be used.The text was updated successfully, but these errors were encountered: