1

While drawing a program flowchart I encountered a problem regarding the "below = of"/ "below of =" behavior. I Would like to place two nodes beneath each other with a fix distance from edge to edge.

I'm using the tikzlibrary "positioning" to do so, the result however changes if I use my own style.

minimal example:

\documentclass[border=1in]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,shapes,positioning}
\begin{document}

     \tikzset{
         pap/.style={
             draw,
            minimum height=7mm,
            font=\ttfamily\footnotesize,
            align=flush center,
            on grid
        },
    }
\begin{tikzpicture}
  \node (a) {A};
  \node [pap,below = of a] {C};
  \node [pap,below of = a] {D};
  \node [right of = a] (a2) {A2};
  \node [below = of a2] {C2};
  \node [below of = a2] {D2};
\end{tikzpicture}
\end{document}

results in: enter image description here

where I would expect the left side to be as the right side.

Sorry for my poor English, I would appreciate any help. Best Regards, Jannis

  • Welcome! What happens if you remove on grid? – cfr Jul 17 '18 at 2:43
  • 1
    Thats it! That was easy, i was searching more than an hour before :( – Jannis.D Jul 17 '18 at 2:44
  • on grid forces positioning onto a grid .... :-) – cfr Jul 17 '18 at 2:48
  • makes totally sense, I guess I'm just to tired :( Thanks a lot! – Jannis.D Jul 17 '18 at 2:49
  • you can see all the result details for positioning in this document 7.11 Positioing relative to nodes – J Leon V. Jul 17 '18 at 2:57
1

on grid forces positioning onto a grid. If you want to specify the position of nodes exactly, that's not what you want.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\tikzset{
  pap/.style={
    draw,
    minimum height=7mm,
    font=\ttfamily\footnotesize,
    align=flush center,
  },
}
\begin{tikzpicture}
  \node (a) {A};
  \node [pap,below = of a] {C};
  \node [pap,below of = a] {D};
  \node [right of = a] (a2) {A2};
  \node [below = of a2] {C2};
  \node [below of = a2] {D2};
\end{tikzpicture}
\end{document}

not on a grid

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.