Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 15 down vote accepted

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

share|improve this answer
    
That was surprisingly easy... I tried smaller/bigger numbers and negative numbers, but just removing the number I didnt even consider. Also, thanks for the tip about xcolor, that was news to me! –  Mythio Mar 21 '13 at 11:41
    
@Mythio See my edit. –  hpesoj626 Mar 21 '13 at 11:42
    
@Mythio: Setting rounded corners=2mm in your original code will work as well (even without scaling). –  Jake Mar 21 '13 at 11:44
    
@jake Thanks, been playing around a bit with the numbers and I think I got how it works now. Great help both of you –  Mythio Mar 21 '13 at 12:15
2  
About xcolor. Sometimes it's interesting to use xcolor with special options. In this case, you need to load xcolor before Tikz something like \usepackage[usenames,dvipsnames]{xcolor} –  Alain Matthes Mar 21 '13 at 12:26

With PSTricks.

enter image description here

\documentclass[pstricks,border=3pt]{standalone}
\begin{document}
\begin{pspicture}(-1,0)(1,2)
    \pspolygon[linearc=0.1](-1,0)(0,2)(1,0)
\end{pspicture}
\end{document}

Application:

enter image description here

\documentclass[pstricks,border={1pt 3pt 1pt -1pt}]{standalone}
\begin{document}
\begin{pspicture}(-1,0)(1,2)
    \pspolygon[linearc=0.1,fillstyle=solid,fillcolor=orange](-1,0)(0,2)(1,0)
    \rput(0,0.85){\psscalebox{5}{!}}
\end{pspicture}
\end{document}
share|improve this answer
2  
I'm guessing the important part here is the linearc=0.1 which creates the rounded corners? –  Mythio Mar 21 '13 at 14:44
    
@Mythio: You have good intuition! –  In PSTricks we trust Mar 21 '13 at 14:45

Your Answer

 
discard

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.