我正在使用 TikZ 制作流程图。我想得到一个节点,它位于另一个节点的左下方。请参见以下示例。我想复制节点revealed
和之间的关系。我通过在下面直接创建一个空节点,然后在其左侧创建节点来WTP measurement
实现这一点。有没有更简单的方法?正如您在代码中看到的,我尝试了WTP measurement
revealed
\node [level3, below left=of revealed, node distance=2in] (marketdata) {Market Data};
但这样不行。节点marketdata
没有放置在节点的左下方revealed
。事实上,它出现在节点的上方。
\usemodule[tikz]
\usetikzlibrary[shapes,arrows]
\starttext
% Define block styles
\tikzstyle{level1} = [rectangle, draw, fill=green!40!blue!20,
text width=4in, text centered, inner sep=1pt,
minimum height=4em]
\tikzstyle{level2} = [rectangle, draw, fill=blue!20,
text width=2in, text centered, rounded corners, minimum height=3em]
\tikzstyle{level3} = [rectangle, draw, fill=blue!10,
text width=2in, text centered, rounded corners, minimum height=3em]
\starttikzpicture
% Place nodes
\node [level1] (start) {\color[white]{WTP measurement}};
\node [below of = start, node distance=1in] (blank) { };
\node [level2, right of = blank, node distance=2in] (stated) {Stated Preference};
\node [level2, left of = blank, node distance=2in] (revealed) {Revealed Preference};
\node [level3, below left=of revealed, node distance=2in] (marketdata) {Market Data};
% Draw edges
\path [line] (start) -- (stated);
\path [line] (start) -- (revealed);
\stoptikzpicture
\stoptext
答案1
您需要positioning
加载库才能使用相对定位命令。一旦加载,它below left=of
应该可以正常工作。
\documentclass[border=1in]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (a) {A};
\node [below left=of a] {B};
\end{tikzpicture}
\end{document}
答案2
根据@Seamus 的回答和@Martin Scharrer 的评论,尝试以下操作:
\documentclass[border=1in]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (a) {A};
\node [below left=1cm and 3cm of a] {B}; % Note the way the distances are specified
\end{tikzpicture}
\end{document}