[Tex/LaTex] Draw a rectangle with rounded ends in TikZ

arctikz-pgf

I want to draw some round-ended rectangles to use as labels, so I thought a filled arc either end would work (silly me 🙂

\draw [fill](0,0) arc[radius=5pt,start angle= 90,end angle=270];
\draw [fill](0,0) rectangle (40,-20);
\draw [fill](40,0) arc[radius=5pt,start angle=270,end angle=90];

But this places the right-hand end-cap above the rectangle, and facing the wrong way. I have obviously misunderstood the implications of the direction angles.

How do I draw a filled arc that points right, not left? (that is, D-shaped, the mirror of the first one).

Best Answer

If people come to this question via Google (like me) and want to get only a rectangle with rounded corners:

\draw[rounded corners] (0, 0) rectangle (4, 1) {};

This is an empty rectangle with rounded corners. The rectangle is from (0, 0) - the lower left corner - to (4, 1) - the upper right corner.