4

I was trying to place a node relative to another node with the following code:

\documentclass[margin=2pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
  facility/.style={rectangle,draw=blue!50,fill=blue!20,
                   minimum width=20mm,align=center,
                   text width=20mm,font=\footnotesize},
}

\begin{document}
\begin{tikzpicture}
  \node[facility] (sup)                 {Supplier Facility};
  \node[facility] (cust) [right of=sup] {Customer Facility};
\end{tikzpicture}
\end{document}

The output is shown below. Unfortunately the two nodes are overlapping, which is not what was desired.

enter image description here

I realized that my mistake was that I needed to replace right of=sup with right=of sup.

\documentclass[margin=2pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
  facility/.style={rectangle,draw=blue!50,fill=blue!20,
                   minimum width=20mm,align=center,
                   text width=20mm,font=\footnotesize},
}

\begin{document}
\begin{tikzpicture}
  \node[facility] (sup)                 {Supplier Facility};
  \node[facility] (cust) [right=of sup] {Customer Facility};
\end{tikzpicture}
\end{document}

The code above gives the desired output:

enter image description here

Question

  1. Why is right of=sup different from right=of sup?
  2. If right of= is wrong, why doesn't it give a compile error or warning?
  3. Is it possible to make right of= give a compile error or warning? This seems like a particularly easy mistake to make.

0 Answers0