2

I have the following MWE:

\documentclass[tikz,convert={size=640}]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
  block/.style={draw,rectangle,minimum width=1cm,minimum height=1cm},
  sum/.style={draw,circle,minimum width=0.2cm,minimum height=0.2cm}
]
  \node[block] (g) {$G$};
  \node[sum,above=0.25cm of g.center,right=0.5cm of g] (sum1) {};
\end{tikzpicture}
\end{document}

which produces

enter image description here

But the above=0.25cm of g.center command is ignored at all. How can I achieve this relative positioning of the y-coordinate from a different anchor point?

4
  • you've got 2 positioning commands: above=0.25cm of g.center,right=0.5cm of g, so the first is ignored...?
    – cmhughes
    Jan 7, 2016 at 13:18
  • seems like, but why?
    – Reza
    Jan 7, 2016 at 13:19
  • Try above right=0.25cm and 0.5cm of g, mutatis mutandis.
    – Bibi
    Jan 7, 2016 at 13:20
  • The point is that I want to use different anchor points for my x and y coordinate.
    – Reza
    Jan 7, 2016 at 13:58

1 Answer 1

2

A couple of options. The differences in output are because the right=of and above right=of changes the anchor of the node. above sets anchor=south, while above right sets anchor=south west. Indeed you'll see that the bottom of the blue circle and the south west point on the black circle is located in the center of the two other circles. By adding anchor=center after the positioning key all circles end up in the same place.

(As the east and center anchor has the same y-coordinate, this works. if the node was rotated it wouldn't work.)

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
  block/.style={draw,rectangle,minimum width=1cm,minimum height=1cm},
  sum/.style={draw,circle,minimum width=0.2cm,minimum height=0.2cm},
]
  \node[block] (g) {$G$};
  \node[sum,above right=0.25cm and 0.5cm of g.east] (sum1) {};
  \node[blue,dashed,sum,above=0.25cm of g.east,xshift=0.5cm] (sum1) {};
  \node[red,sum] at ([shift={(0.5cm,0.25cm)}]g.east) {};
  \path (g.east) ++(0.5cm,0.25cm) node[yellow,dashed,sum] {};
\end{tikzpicture}
\end{document}
3
  • But I want to position the sum1 node 0.25m above the center of g and 0.5cm right from the right edge of g.
    – Reza
    Jan 7, 2016 at 13:54
  • @Reza Oops, sorry, didn't pay enough attention to your code. Replace center with east in my code and you should get that, will edit later. Jan 7, 2016 at 13:55
  • The system is not very intuitive, but at least a hack is possible
    – Reza
    Jan 7, 2016 at 14:25

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.