[Tex/LaTex] Drawing a triangle with rounded corners in TikZ

tikz-pgf

I'm trying to draw a simple equilateral triangle with rounded corners in Tikz.
However, I can't get the rounded corners correct.

I have the following MWE which draws the triangle:

\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}

\begin{document}
\begin{tikzpicture}
    \draw [fill=gray!20] (0,0)--(1,0)--(0.5,1)--cycle;
\end{tikzpicture}
\end{document}

I've tried this to get rounded corners, but it has a very strange result:

\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}

\begin{document}
\begin{tikzpicture}
    \draw [rounded corners=10mm,fill=gray!20] (0,0)--(1,0)--(0.5,1)--cycle;
\end{tikzpicture}
\end{document}

Any idea how to get simple rounded corners for the three corners of the triangle?

P.S. I'm not sure which libraries are needed, so I've left them all for now but I know this is probably not needed.

Best Answer

Make the radius of the rounded corners smaller. Remove =10mm and you will see the instant effect. Also, in your case, I find no need to load the xcolor package since it is used internally by tikz, unless, as noted by Alain Matthes, you use some of its options for naming your colors. You can uncomment it if you like. The libraries are not needed here, too, so I commented them out.

Here is your figure when the 10mm is dropped.

enter image description here

And here is one with scaling (not really necessary, just for demonstration purposes).

%\documentclass{article}

\documentclass[border=5]{standalone}

\usepackage{tikz}
%\usepackage{xcolor}
%\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}

\begin{document}
\begin{tikzpicture}[scale=3]
    \draw [rounded corners,fill=gray!20] (0,0)--(1,0)--(0.5,1)--cycle;
\end{tikzpicture}
\end{document}

enter image description here

Here I have scaled the figure up to 3 since your figure is too small.

To make a point, see what happens when I scale the figure up by 5 and set rounded corners=10mm.

enter image description here