我如何绘制水平列出的彼此相邻的节点,但有两个节点垂直列出,如图所示。
梅威瑟:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=4.5em, text centered, rounded corners, minimum height=2.5em, font=\footnotesize, fill opacity=0.3, text opacity=1]
\begin{tikzpicture}[node distance=0.5cm]
\node [block] (a1) {A1};
\node [block, right=of a1] (a2) {A2};
\node [block, right=of a2] (a3) {A3};
\node [block, right=of a3] (a4) {A4};
\end{tikzpicture}
\end{document}
答案1
您可以使用above right
或below right
作为 的可能参数node
。
例如:
\node [block, above right=of a1] (a2) {A2};
您还可以对上方或右侧使用单独的距离:
\node [block, above right=2cm and 1cm of a1] (a2) {A2};
要重新创建图像示例,您可以使用:
\node [block, right=of a1] (a2) {A2};
\node [block, above right=of a2] (a3) {A3};
\node [block, below right=of a2] (a3b) {A3b};
\node [block, below right=of a3] (a4) {A4};