\documentclass{minimal}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\begin{document}
\tikzstyle{abstract}=[rectangle, draw=black, rounded corners, fill=blue!40, drop shadow,
text centered, anchor=north, text=white, text width=3cm]
\tikzstyle{comment}=[rectangle, draw=black, rounded corners, fill=green, drop shadow,
text centered, anchor=north, text=white, text width=3cm]
\tikzstyle{myarrow}=[->, >=open triangle 90, thick]
\tikzstyle{line}=[-, thick]
\begin{center}
\begin{tikzpicture}[node distance=2cm]
\node (Item) [abstract, rectangle split, rectangle split parts=2]
{
\textbf{ITEM}
\nodepart{second}name
};
\node (AuxNode01) [text width=4cm, below=of Item] {};
\node (Component) [abstract, rectangle split, rectangle split parts=2, left=of AuxNode01]
{
\textbf{COMPONENT}
\nodepart{second}nil
};
\node (System) [abstract, rectangle split, rectangle split parts=2, right=of AuxNode01]
{
\textbf{SYSTEM}
\nodepart{second}parts
};
\draw[myarrow] (Component.north) -- ++(0,0.8) -| (Item.south);
\draw[line] (Component.north) -- ++(0,0.8) -| (System.north);
\end{tikzpicture}
\end{center}
\end{document}
我修改了发布的示例这里。作者在“ITEM”下方放置了一个虚拟节点 \node (AuxNode01) [text width=4cm, below=of Item] {};
,并在其右侧和左侧创建了两个节点。
现在我的问题是如何在项目正下方,即虚拟节点所在的位置创建第三个节点。我凭直觉尝试了at
& over
,但没有成功。
答案1
如果我正确理解了您要做的事情,那么“at”实际上是正确的,但您把它放在了不同的地方:
\node (Blah) at (AuxNode01) [abstract, rectangle split, rectangle split parts=2]
{
\textbf{BLAH}
\nodepart{second}parts
};
anchor=north
为了正确定位,您应该从样式定义中删除abstract
(无论如何,我不太清楚它为什么在那里)。
答案2
这是你想要的吗?
在这种情况下,您可以使用at (<node name>)
,并且您需要使用新节点的选项,因为它在全局选项中anchor=center
设置为。north
\documentclass{minimal}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,arrows}
\begin{document}
\tikzstyle{abstract}=[rectangle, draw=black, rounded corners, fill=blue!40, drop shadow,
text centered, anchor=north, text=white, text width=3cm]
\tikzstyle{comment}=[rectangle, draw=black, rounded corners, fill=green, drop shadow,
text centered, anchor=north, text=white, text width=3cm]
\tikzstyle{myarrow}=[->, >=open triangle 90, thick]
\tikzstyle{line}=[-, thick]
\begin{center}
\begin{tikzpicture}[node distance=2cm]
\node (Item) [abstract, rectangle split, rectangle split parts=2]
{
\textbf{ITEM}
\nodepart{second}name
};
\node (AuxNode01) [text width=4cm, below=of Item] {};
\node (Component) [abstract, rectangle split, rectangle split parts=2, left=of AuxNode01]
{
\textbf{COMPONENT}
\nodepart{second}nil
};
\node (System) [abstract, rectangle split, rectangle split parts=2, right=of AuxNode01]
{
\textbf{SYSTEM}
\nodepart{second}parts
};
\node (New) [abstract, rectangle split, rectangle split parts=2,anchor=center] at (AuxNode01)
{
\textbf{SYSTEM}
\nodepart{second}parts
};
\draw[myarrow] (Component.north) -- ++(0,0.8) -| (Item.south);
\draw[line] (Component.north) -- ++(0,0.8) -| (System.north);
\end{tikzpicture}
\end{center}
\end{document}