# Label sides of rectangles and triangles

What is the easiest way to label the sides of rectangles and triangles in TikZ?

-
Does tex.stackexchange.com/questions/13401/… what you want? –  Martin Scharrer Mar 15 '11 at 18:06

I usually use nodes placed along the path that draws the polygon.

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
% Rectangle with labeled edges
\draw (0,0)  -| (5,3)
node[pos=0.25,below] {$\ell$}
node[pos=0.75,right] {$w$}
-| (0,0);
\end{tikzpicture}

\begin{tikzpicture}
\draw[rotate=30] (0,0)  -| (5,3)
node[pos=0.25,below] {$\ell$}
node[pos=0.75,right] {$w$}
-| (0,0);
\end{tikzpicture}

\begin{tikzpicture}
\draw (0,0) -- (4,0) node[midway,below] {$a$}
-- (2,4) node[midway,right] {$b$}
-- (0,0) node[midway,left] {$c$};
\end{tikzpicture}

\end{document}


-