How do you add dimension labels to TikZ pictures? Ideally, it would look something like this:

|<----- dimension ----->|

I would like to do this to show the measurement of both straight lines (i.e. sides of a polygon) and curved lines (i.e. circumference/arc length on a circle). Thanks in advance for your help!


For educational and show-off purposes only!


\tikzset{measure length/.style={
              mark connection node=a,
              mark =at position 0.5 with {
                 \node[transform shape,fill=white,scale=0.5,#1] (a) 
                        \pgfmathprintnumber[fixed,precision=1]\pgfmathresult mm};},

\draw[measure length] (-2,-2cm) -- (2cm,-2cm);
\draw[measure length={rotate=180}] (0,0) arc (0:270:1cm) ;
\draw[measure length={rotate=180}] (0,3) arc (0:270:1cm) -- ++(10mm,0);

\foreach \x in {0,...,5}{
\draw[measure length] (2,2) +(\x*60:1cm) -- +({(\x+1)*60)}:1cm);



enter image description here

  • This is really nice, if this continues further we will replace 2D CAD with TikZ. – Alexander Jul 13 '13 at 20:05
  • @Alexander I wish :-) But this is just showing off, under some pressure, it will disappoint you rather quickly. – percusse Jul 13 '13 at 20:09
  • Thanks for the detailed response! One more thing though: is it possible to add arrows to the end of the lines? – Randy Randerson Jul 13 '13 at 20:23
  • 1
    @fctaylor25 Add <-> in the \draw options. – percusse Jul 13 '13 at 20:38
  • Is there any way to make the measurement a variable (e.g. C for circumference, h for height, etc.)? – Randy Randerson Jul 14 '13 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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