我可以在 tikz 使用以下代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{hyperref}

\begin{document}
\begin{tikzpicture}
\node {%
\href{http://www.stackoverflow.com}{% 
\begin{tikzpicture} 
\filldraw[blue] circle(1cm) node [white] {Click}; 
\end{tikzpicture}}}; 
\end{tikzpicture}

\end{document}

现在,我想使用矩阵来组织形状,并具有超链接的形状之一。它几乎有效,但是我无法将超链接形状与其他形状保持一致,并且比其他形状更大:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{hyperref}

\begin{tikzpicture}
\matrix [matrix of nodes, row sep = 1cm, column  sep=1cm, nodes={circle, draw}]  
{%    First  row:
1           & 2 \\
%    second row:
\path node {\href{http://www.stackoverflow.com}{% 
\begin{tikzpicture} 
\node {3}; 
\end{tikzpicture}}}; & 4\\
};

\end{tikzpicture}
\end{document}

我得到以下结果:

alt text
(来源: 图片)

我的问题是:我如何将上图中的形状3与其他形状保持一致,并摆脱外圈?

有帮助吗?

解决方案

我认为您的目标太高了,第二个{tikzpicture}正在弄乱您的布局。您如何看待下面的代码?那是您一直在寻找的吗?

\documentclass{article}
\usepackage{tikz}
  \usetikzlibrary{matrix}
\usepackage[pdftex,active,tightpage]{preview}
  \PreviewEnvironment{tikzpicture}
\usepackage{hyperref}
\begin{document}
\begin{tikzpicture}
  \matrix [matrix of nodes, row sep = 1cm, column  sep=1cm, nodes={circle, draw}]  
    {%
    1 & 2\\%
    \href{http://stackoverflow.com}{3} & 4\\%
    };
\end{tikzpicture}
\end{document}

顺便说一句: PreviewEnvironment {tikzpicture}并不需要,但它使得pdf良好的PDF ...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top