在 tikz 中使用矩阵定位超链接形状

发布于 2024-08-31 09:56:51 字数 1192 浏览 4 评论 0原文

我可以使用以下代码在 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}

我得到以下结果:

替代文字
(来源:picture.im

我的问题是:如何将上图中的形状3与其他形状对齐,并去掉外圆?

I can draw a hyperlinked shape in tikz using the following code:

\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}

Now I would like to organize my shapes using the matrix, and have one of the shapes hyperlinked. It almost works, but I am not able to align the hyperlinked shape with the rest of the shapes, and it is bigger than the other shapes:

\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}

I get the following result:

alt text
(source: picture.im)

My question is: How could I align shape 3 in the picture above with the other shapes, and get rid of the outer circle?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倦话 2024-09-07 09:56:51

我认为你的目标太高了,你的第二个 {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...

I think you're aiming too high and your second {tikzpicture} is messing up your layout.
What do you think about the code below? Is that what you've been looking for?

\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}

BTW: the \PreviewEnvironment{tikzpicture} is not really needed, but it makes for a nice, cropped pdf...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文