如何在垂直列中正确间隔 tikz 按钮

如何在垂直列中正确间隔 tikz 按钮

我正在尝试将按钮垂直排列在一列中,并且每个按钮之间的距离相等。我不明白我在这个 MWE 中做错了什么。任何指导都非常感谢!

注意:我已经更新了下面的 MWE,以便它现在可以实现我想要的目标。

\documentclass{article}

\usepackage{tikz, pgfplots}
\usepackage{pstricks}
\pgfplotsset{compat=1.18}
\usetikzlibrary{
  fit, shapes, automata, backgrounds, positioning, shadows, patterns, calc,
  arrows.meta,
  shapes.geometric
}

\usepackage[hidelinks]{hyperref}
\hypersetup{pdfhighlight=/N}

\pagestyle{empty}

\begin{document}

\tikzset{%
hyperlink node/.style={
        alias=sourcenode,
        append after command={
            let \n0={\pgfkeysvalueof{/pgf/outer xsep}},
                \n1={\pgfkeysvalueof{/pgf/outer ysep}},
                \p1=([shift={(\n0, -\n1)}] sourcenode.north west),
                \p2=([shift={(-\n0, \n1)}] sourcenode.south east),
                \n2={\x2-\x1},
                \n3={\y1-\y2} in
            node [inner sep=0pt, outer sep=0pt, anchor=north west, at=(\p1)] {\href{#1}{\XeTeXLinkBox{\phantom{\rule{\n2}{\n3}}}}}
        }
    },
}

\def\testurl{https://google.com}

\vspace{2cm}

\foreach \j\k in {Button 1/\testurl, Button 2/\testurl, Button 3/\testurl, Button 4/\testurl}
{
\noindent\begin{tikzpicture}[button/.style={fit={(0cm,0cm) (4.3cm,1cm)}, fill=blue, draw=none, drop shadow, text=white, rounded corners=0.5cm, inner sep=0pt, outer sep=0pt, label=center:\textcolor{white}{\large\textsc{\j}}}]
  \node[button, hyperlink node=\k] at (0cm, 0cm) {};
\end{tikzpicture}\par
\vspace{1cm}
}

\end{document}


相关内容