可能重复:
使 TikZ 节点可超链接
有一段时间,这个问题困扰了我。我想将超链接归因于一个形状,也就是说,不是文本,而是整个区域。例如,在下面的 MWE 中,我希望整个绿色圆圈在鼠标位于其上方时做出反应。
\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[circle, draw=black, fill=red!20, minimum size=2cm] (c1) {\hyperlink{t1}{long text}};
\node[circle, draw=black, fill=red!20, minimum size=2cm, right= 3cm of c1] (c1) {\hyperlink{t1}{}};
\end{tikzpicture}
\newpage
\begin{tikzpicture}
\node[circle, draw=black, fill=red!20] (t1) {\hypertarget{t1}{target}};
\end{tikzpicture}
\end{document}
有什么想法吗?谢谢
答案1
\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
\begin{document}
\hyperlink{t1}{\tikz\node[circle, draw=black, fill=red!20, minimum size=2cm] (c1) {long text};}
\newpage
\begin{tikzpicture}
\node[circle, draw=black, fill=red!20] (t1) {\hypertarget{t1}{target}};
\end{tikzpicture}
\end{document}
可能嵌套的 tikzpictures
\documentclass{article}
\usepackage{tikz}
\usepackage{hyperref}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (c1) {\hyperlink{t1}{\tikz\node[circle, draw=black, fill=red!20, minimum size=2cm] {long text};}};
\node[right= 3cm of c1] (c2) {\hyperlink{t1}{\tikz\node[circle, draw=black, fill=red!20, minimum size=2cm] {};}};
\end{tikzpicture}
\newpage
\begin{tikzpicture}
\node[circle, draw=black, fill=red!20] (t1) {\hypertarget{t1}{target}};
\end{tikzpicture}
\end{document}