Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to generate a simple organigram with reasonable-looking distances in x and y direction. How can I get equidistant distances between the nodes?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
[topline/.style={rectangle,rounded corners,fill=red,xshift=3cm, yshift=2.5cm, minimum width=15mm,minimum height=10mm},
botline/.style={rectangle,rounded corners,fill=orange,xshift=3cm, yshift=2cm, minimum width=15mm,minimum height=10mm},
]
\node at (0,0) [topline] {A};
\node at (1,0) [topline] {B};
\node at (2,0) [topline] {C};
\node at (0,-1) [botline] {D};
\node at (0,-2) [botline] {E};
\end{tikzpicture}

\end{document}

tikz node positioning

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You're using different minimum width and minimum height. Set them both to the same value and you should get the distances correct.

If you add the line

\tikzset{x=15mm,y=15mm}

before beginning the picture, you'll get a nicer result. Also make sure that your xshift and yshift are the same and you'll get something like

enter image description here

Finally, since a lot of your styles are duplicated, I separate out the duplication.

Here is the code for the last image

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
[
    x=15mm,y=15mm,
    mybox/.style={rectangle,rounded corners,xshift=1cm,yshift=1cm,minimum width=15mm, minimum height=15mm},
    topline/.style={mybox,fill=red},
    botline/.style={mybox,fill=orange},
]
\node at (0,0) [topline] {A};
\node at (1,0) [topline] {B};
\node at (2,0) [topline] {C};
\node at (0,-1) [botline] {D};
\node at (0,-2) [botline] {E};
\end{tikzpicture}

\end{document}
share|improve this answer
    
x=15mm,y=15mm should be included in option of tikzpicture environment. –  Paul Gaborit Jan 28 '13 at 22:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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