TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A rectangle label does not appear inside the rectangle but on the corner of it.

  \tikzstyle{every node} = [align=center]
    \draw (0, 0) rectangle (2, 2) node [center] {label}; 
     %center is unknown but was my best guess

How do I move the labelling node to have a common center with the rectangle?

The result should look like this

  \tikzstyle{every node} = [align=center]
    \draw (0, 0) rectangle (2, 2);
    \node at (1,1) {label};

but without having to specify the center manually.

share|improve this question
Why not \node[draw,rectangle, minimum size=2cm] at (1,1){label};? – Claudio Fiandrino Feb 1 '13 at 15:10
I had that approach before and i am now refactoring. I have trouble realigning my boxe´s if i dont explicitly state start and endpoints. – Johannes Feb 1 '13 at 15:14
@Johannes: give a name to the node (e.g. \node[draw,rectangle, minimum size=2cm] (name) at (1,1){label};) then you will have name.south west for the lower left corner and name.north east for the upper right corner. – Claudio Fiandrino Feb 1 '13 at 15:35
up vote 20 down vote accepted

You should write instead:

\draw (0,0) rectangle (2,2) node[pos=.5] {Test};

By using node in a path without option, it will position the node to the last point.

enter image description here

share|improve this answer
You can also use [midway] option instead of [pos=.5]. It is equivalent and the syntax sounds perhaps a bit more natural. – JLDiaz Feb 1 '13 at 16:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.