Search code examples
latextikzpgf

pgf tikz for LaTeX how can I use x and y coordinates with node


I have the following rectangle:

\begin{tikzpicture}
\draw[thin] (0,0) -- (7,0) -- (7,5) -- (7,5) -- (0,5) -- (0,0);
\end{tikzpicture}

and I want to put a text label for the width and height of the rectangle using node. But don't know how to specify the x, y coordinates for the text label.

Can I use x,y coordinates with node?


Solution

  • You can do that using the at (x, y) syntax:

    \begin{tikzpicture}
      \draw[thin] (0,0) -- (7,0) -- (7,5) -- (7,5) -- (0,5) -- (0,0);
      \node at (3.5, -0.5) {7cm};
      \node at (-0.5, 2.5) {5cm};
    \end{tikzpicture}
    

    enter image description here