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

I have drawn a rectangle with a fixed position:

\draw[thick] (3,1) rectangle (5,3);  

I would like to make it a node with a name (for instance rec), so that other elements later could be positioned with regards to it, for instance:

\node (elli) [ellipse, below=1cm of rec] {...};

Does anyone know how to make the rectangle above a node?

share|improve this question
up vote 27 down vote accepted

You can specify the minimum height and minimum width for a node. In conjunction with draw, you'll end up with a rectangle with the specified dimensions:

\node (rect) at (4,2) [draw,thick,minimum width=2cm,minimum height=2cm] {};
share|improve this answer
Here, iiuc (rect) is the label, so what indicates the shape ? Is rectangle simply the default for draw ? – Nikana Reklawyks Mar 16 '15 at 6:40
@Nikana: yes, exactly, rectangle is the default shape. – Jake Mar 16 '15 at 7:10
Actually explicitly setting [rectangle] is also possible, to restore the default if it was overriden. – Joost May 27 '15 at 18:12

Another solution with fit library. Following example shows how to use two opposite corner coordinates to define an rectangular node.



    \draw[help lines] (0,0) grid (6,4);
    \fill[red] (3,1) circle (1pt) node[below left] {(3,1)} (5,3) circle (1pt) node[above right] {(5,3)};
    \node[fit={(3,1) (5,3)}, inner sep=0pt, draw=blue, thick] (rect) {};
    \draw[red] (rect.east) to[out=0,in=-90] (rect.south);

enter image description here

share|improve this answer

You can define a node and put the rectagle inside. Then you can add more objets as nodes with relative posititions.



  \tikz {\draw[thick] (3,1) rectangle ++(2,2);}

%Text inside the rectangle
\node[at={($(cuadrado.center)$)},anchor=center] (texto) {asd asd asd};

share|improve this answer
Nesting tikzpicture environments should be avoided whenever possible and can be avoided in very nearly almost all cases. Since it can be easily avoided here, this is really not a good solution. – cfr Apr 7 at 1:41
I would agree that it would be nice if this did work, though. On occasion, it would make life so much simpler! ;) – cfr Apr 7 at 2:06

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.