TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

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

share|improve this question
Does tex.stackexchange.com/questions/13401/… what you want? – Martin Scharrer Mar 15 '11 at 18:06
up vote 9 down vote accepted

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


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

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

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


sample code output

share|improve this answer

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.