如何使用 Tikz 创建标签层次结构?

如何使用 Tikz 创建标签层次结构?

我该如何创建这样的东西?这是 tikz 吗?

在此处输入图片描述

启动 tikz 最用户友好的教程是什么?

答案1

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{
  % https://github.com/Qrrbrbirlbel/pgf/blob/master/tikzlibrarypositioning-plus.code.tex
  positioning-plus,
  % https://github.com/Qrrbrbirlbel/pgf/blob/master/tikzlibrarynode-families.code.tex
  node-families,
  chains,backgrounds}
\begin{document}
\begin{tikzpicture}[
  >=latex, thick,
  node distance=1cm and 1.8cm,
  my edge/.style={->}, my edge'/.style={<-},
  box/.style={
    shape=rectangle, draw, fill, font=\strut,
    rounded corners},
  wh box/.style={box, fill=white, Minimum Height=all},
  bl box/.style={box, text=white, align=center, text width=1.8cm, Minimum Height=all},
  gr box/.style={box, thick, inner sep=+.5cm, draw=gray, fill=gray!25}
]
\begin{scope}[nodes=wh box]
  \node (c1) {archive-wpsc-product.php};
  \node[Minimum Width=c, west below=   of c1] (c2')
                                                  {taxonomy-wpsc\_product\_category.php};
  \node[Minimum Width=c, west below=.5:of c2'] (c2)
                  {taxonomy-wpsc\_product\_category-\{\$slug\}.php} edge[my edge'] (c2');
  \node[west below=of c2, alias=c3'] (c3) {single-wpsc-product.php};
\end{scope}
\begin{scope}[nodes=bl box, start chain=chB going below]
  \node[left=of c1] (b1) {Main Store} edge[my edge] (c1);
  \foreach \Text[count=\cnt from 2] in {Product Category, Single Product}
    \node at (b1 |- c\cnt') (b\cnt) {\Text} edge[my edge] (c\cnt');
  \chainin (b3);
  \foreach \Text[count=\cnt from 4] in {Shopping Cart,
                                        Checkout,
                                        Customer Account,
                                        Login,
                                        Register,
                                        Password Reminder}
    \node[on chain=chB, alias=b\cnt] {\Text};

  \node[left=+4cm of (b1)(chB-end)] (a) {What page?}
    \foreach \Node in {b1, b2, b3, chB-2, chB-3, chB-..., chB-7}{
      edge[my edge, out=0, in=180, looseness=.5] (\Node)};
  \coordinate (b2) at (b2|-c2); % overwrite b2!
\end{scope}
\begin{scope}[nodes={wh box, Minimum Width=d}]
  \node[right=of (c2.east|-c1)] (d1) {main-store-wrapper.php} edge[my edge'] (c1);
  \foreach \Text[count=\cnt from 2] in {category, single, cart, checkout,
                                    customer-account, login, register, password-reminder}
    \node (d\cnt) at (d1|-b\cnt) {\Text-wrapper.php} edge[my edge']
                                                      (\ifnum\cnt<4 c\cnt\else b\cnt\fi);
\end{scope}
\node[wh box, text width=2.4cm, align=center, right=+4cm of (d1)(d9)] (e)
                                                                  {Your theme's page.php}
  \foreach \cnt in {1,...,9} {edge[my edge', out=180, in=0, looseness=.5] (d\cnt)};

\node [above=.5:of (c1)(c2), align=center] (c0)
                                    {{\large Theme path}\\\small wp-contents/your-theme};
\node [above=.5:of d1,       align=center] (d0)
         {{\large WPEC customization path}\\\small wp-contents/your-theme/wp-e-commerce};
\begin{scope}[on background layer, nodes=gr box]
  \node[fit=(c0)(c1)(c2)(c3)] {};
  \node[fit=(d0.north)(d9)] {};
\end{scope}
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容