With tikz library calc, it is possible to center a node between two points:

\node (node3) at ($(node1)!0.5!(node2)$) {centered};

Whatever is the direction of the line passing through node1 and node2, this makes node3 horizontally centered along this direction.

Is is possible to center instead a node between 4 nodes, when they form a regular shape such as a square, or rectangle, or rhombus? So that the node is both horizontally and vertically centered.

  • 2
    Keep adding : ($($(node1)!0.5!(node2)$)!0.5!($(node3)!0.5!(node4)$)$)
    – percusse
    Nov 23, 2017 at 15:39

1 Answer 1


You can perhaps use barycentric cs:

output of code

\node (a) at (-2,2) {1};
\node (b) at (2,2) {2};
\node (c) at (-2,-2) {3};
\node (d) at (2,-2) {4};

\node (e) at (barycentric cs:a=1,b=1,c=1,d=1) {5};
  • Can you explain the code cs:a=1,b=1,c=1,d=1? Nov 23, 2017 at 15:57
  • 3
    @toandhsp Section 13.2.2 Barycentric systems in the manual. Essentially, the coordinate is defined by a linear combination of the vectors a, b, c and d (these are the named coordinates), when all the vectors are weighted equally, you get the center point. Nov 23, 2017 at 16:01

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.