68

I am using TikZ to make flowchart kind of diagrams. I want to get a node below and to the left of another node. Please see the following example. I want the replicate the sort of relationship between nodes revealed and WTP measurement. I have done that by creating an empty node directly below WTP measurement and then creating node revealed to the left of it. Is there an easier way? As you see in the code, I tried

   \node [level3, below left=of revealed, node distance=2in] (marketdata) {Market Data};

but that does not work. The node marketdata is not placed below and to the left of node revealed. In fact, it appears above it.

\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
  • Welcome to TeX.SX. We prefer not to have any opening or closing text. As long the issue or solution is not ConTeXt specific the question should not be tagged with {context}. – Martin Scharrer Apr 20 '11 at 10:56
77

You need the positioning library loaded to use the relative positioning commands. And once you load it, below left=of should work fine.

\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}

below left works

| improve this answer | |
  • 6
    You can change the distance by added a length just before of, like below left=1cm of. However, I never figured out how to change both directions independently, e.g. 2cm below but only 1cm to the left. – Martin Scharrer Apr 20 '11 at 10:54
  • 41
    @Martin Scharrer: Just do below left=2cm and 1cm of.... – Martin Heller Apr 20 '11 at 16:00
  • @MartinHeller: Thanks! See also Brent Longborough's answer. – Martin Scharrer Apr 20 '11 at 16:04
  • 1
    @MartinHeller do you happen to know a keyword to place it exactly the same position? – masu Oct 16 '13 at 16:43
  • I'm not sure what you mean. There is the at keyword and anchor specifications: \node (a) at (0,0) {A}; \node[anchor=center] (b) at (a.center) {B}; – Martin Heller Oct 17 '13 at 10:34
56

Building on @Seamus' answer and @Martin Scharrer's comment, try this:

\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}
| improve this answer | |
  • Thanks! Have not tried this. But will. – Curious2learn Apr 20 '11 at 12:00
  • 3
    Interestingly, below left works but left below doesn't... – Seamus Apr 20 '11 at 12:09
  • 6
    @Seamus: Sacramental mysteries of the TikZ priesthood (;-») – Brent.Longborough Apr 20 '11 at 12:19
  • 4
    @Seamus: It a matter of definition. Also this would lead to an expression like "right above" instead of "above right", which might be confusing :-) ("A is right above B") – Martin Scharrer Apr 20 '11 at 15:54
  • Thanks. I remember seeing this somewhere before but it didn't work for me somehow. Can't remember the details, but take your word for it. – Martin Scharrer Apr 20 '11 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.