11

How can I shift the system node right of control1 but vertically centered between control1 and control2?

\tikzstyle{controller} = [draw, fill=blue!20, rectangle, 
    minimum height=3em, minimum width=6em]
\tikzstyle{block} = [draw, fill=yellow!20, rectangle, 
    minimum height=3em, minimum width=6em]    
\tikzstyle{sum} = [draw, circle, node distance=1.5cm]
\tikzstyle{disturbance} = [draw=none, node distance=1.5cm, line width=0pt] 
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]

\node [input, name=input] {};
\node [sum, right of=input] (sum) {};    
\node [controller, right of=sum] (control1){Control1}; 
\node [controller, above of=control1] (control2) {Control2};
\node [block, right of= control1, node distance=5cm, yshift=-1.4cm] (system) {System};
14

You can use positioning library instead of the deprecated input syntax <direction> of =. See this answer Difference between "right of=" and "right=of" in PGF/TikZ and also Should \tikzset or \tikzstyle be used to define TikZ styles?

Then, you can use the calc syntax to get the middle point of the two nodes.

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}[sum/.style={draw, circle, node distance=1.5cm},
               controller/.style={draw, fill=blue!20, rectangle, 
    minimum height=3em, minimum width=6em},
               block/.style={draw, fill=yellow!20, rectangle, 
    minimum height=3em, minimum width=6em}]
  \coordinate (input);
  \node [sum, right= of input] (sum) {};    
  \node [controller, right = of sum] (control1) {Control1}; 
  \node [controller, above = of control1] (control2) {Control2};
  \node [block, right= 5cm of {$(control1)!0.5!(control2)$}] (system) {System};
\end{tikzpicture}
\end{document}

enter image description here

And please post full compilable code.

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.