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 was wondering if there is a way to define an equilateral triangle in tikz. I am aware that there is a predefined isosceles triangle in tikz. Specifically I'd like to define a \tikzstyle for equilateral triangle and use it in my diagram. The similar situation with isosceles triangle is something like

\tikzstyle{buffer} = [draw,shape border rotate=-90, isosceles triangle,fill=red, node distance=2cm, minimum height=4em]

However, replacing isosceles with equilateral doesn't work. Thanks

share|improve this question

2 Answers 2

up vote 16 down vote accepted

There is also the regular polygon shape.

(I shamelessly stole and modified Jakes code for this.)

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{
    buffer/.style={
        draw,
        shape border rotate=180,
        regular polygon,
        regular polygon sides=3,
        fill=red,
        node distance=2cm,
        minimum height=4em
    }
}

\begin{document}
\begin{tikzpicture}
\node[buffer]{Test};
\end{tikzpicture}
\end{document}
share|improve this answer
1  
Nice! This actually makes more sense in this case, since now the label text is placed better, and the corner nodes are called corner 1, corner 2 and corner 3 instead of apex, right corner and left corner. –  Jake Dec 30 '12 at 17:31
    
This is great! Thank you :) –  N Nik Dec 30 '12 at 17:35

You can just set isosceles triangle apex angle=60 to get an equilateral triangle. The length of the sides is set using minimum width=<length>.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{
    buffer/.style={
        draw,
        shape border rotate=-90,
        isosceles triangle,
        isosceles triangle apex angle=60,
        fill=red,
        node distance=2cm,
        minimum height=4em
    }
}

\begin{document}
\begin{tikzpicture}


\node[buffer]{Test};
\end{tikzpicture}


\end{document}
share|improve this answer
1  
Thank you, this is also the correct answer; however, for the reason you explained , I am gonna go ahead and accept the other one. Hope you don't mind... –  N Nik Dec 30 '12 at 17:36
1  
@NNik: Of course not, it's definitely the right thing to do –  Jake Dec 30 '12 at 18:05

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.