即使没有标签,链条似乎也能正确对齐;但添加标签似乎会破坏它:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[start chain = going right, node distance=0, every node/.style={on chain,minimum width=10ex,draw}]
\node [label=above:{a}] {1};
\node [label=above:{b}] {2};
\node [label=above:{c}] {3};
\node [label=above:{d}] {4};
\node {5};
\node {6};
\node {7};
\node {8};
\end{tikzpicture}
\end{document}
答案1
正如 @percusse 所说,标签也是节点,因此every node
样式也适用于这些节点。要对齐“普通”节点,请定义新样式。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[start chain = going right, node distance=0, chain/.style={on chain,minimum width=10ex,draw}]
\node [label=above:{a},chain] {1};
\node [label=above:{b},chain] {2};
\node [label=above:{c},chain] {3};
\node [label=above:{d},chain] {4};
\node [chain] {5};
\node [chain] {6};
\node [chain] {7};
\node [chain] {8};
\end{tikzpicture}
\end{document}