我想创建某种带有空白框/空格而不是某些选定字符的商品目录编号,并在这些空白处绘制垂直线并“标记”它们。示例图片如下:
编辑:重新表述。我可以做这样的事情:
\documentclass[]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node at (0,-1) [label=left:tag1](t1){};
\node at (1,0) [label=EXAMPLE\slash](){};
\node at (2,0) [label=\fbox{\phantom{X}}](t2){};
\draw
(t1) -| (t2);
\end{tikzpicture}
\end{document}
但我不知道如何使多个节点看起来像一个字符串的一部分。
答案1
该chains
库可以在这里提供帮助,用于自动放置:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}
\begin{scope}[
node distance=1mm,
start chain=place,
every node/.style={
on chain,
font=\strut,
path picture={
\draw (path picture bounding box.south west) -- (path picture bounding box.south east);
}
}
]
\node {foo};
\node {bar};
\node {baz};
\end{scope}
\begin{scope}[
node distance=2mm,
start chain=tag going below,
every node/.style={on chain}
]
\node at (-2,-0.5) {Tag1};
\node {Tag2};
\node {Tag3};
\end{scope}
\foreach \i in {1,...,3}
\draw (tag-\i) -| (place-\i);
\end{tikzpicture}
\end{document}