我想建立 TikZ 節點的下行鏈。有些節點是旋轉的,並且它們的高度可能不同。
考慮下面 MWE 的輸出:
水平鏈適應節點的不同寬度,而向下鏈則不適應。這可能與旋轉有關係嗎?你知道我怎麼能得到向下的鏈來防止像水平方向那樣的節點相交嗎?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,shapes}
\tikzstyle{arrow}
= [ shape=single arrow
, single arrow head extend=.75em
, single arrow head indent=.25em
, minimum width=3em
, draw
]
\tikzstyle{rarrow}
= [ shape=single arrow
, single arrow head extend=.75em
, single arrow head indent=.25em
, minimum width=3em
, draw
, rotate=-90
]
\begin{document}
\begin{tikzpicture}[start chain,every node/.style={on chain,join}]
\node[arrow] {foo};
\node[arrow] {foo};
\node[arrow] {foooooooooo};
\node[arrow] {foo};
\end{tikzpicture}\\
\begin{tikzpicture}[start chain=going below,every node/.style={on chain,join}]
\node[rarrow] {foo};
\node[rarrow] {foo};
\node[rarrow] {foooooooooo};
\node[rarrow] {foo};
\end{tikzpicture}
\end{document}
答案1
這是非常快速的解決方法,因為tikzpicture
環境彼此獨立:
\documentclass{article}
\parindent=0pt
\usepackage{tikz}
\usetikzlibrary{chains,shapes}
\tikzstyle{arrow}
= [ shape=single arrow
, single arrow head extend=.75em
, single arrow head indent=.25em
, minimum width=3em
, draw
]
\tikzstyle{rarrow}
= [ shape=single arrow
, single arrow head extend=.75em
, single arrow head indent=.25em
, minimum width=3em
, draw
]
\begin{document}
\begin{tikzpicture}[start chain,every node/.style={on chain,join}]
\node[arrow] {foo};
\node[arrow] {foo};
\node[arrow] {foooooooooo};
\node[arrow] {foo};
\end{tikzpicture}\\
\rotatebox{-90}{%
\begin{tikzpicture}[start chain,
every node/.style={on chain,join}]
\node[rarrow] {foo};
\node[rarrow] {foo};
\node[rarrow] {foooooooooo};
\node[rarrow] {foo};
\end{tikzpicture}}
\end{document}