24

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

N Nik
  • 3,669

2 Answers2

28

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}
Torbjørn T.
  • 206,688
  • 2
    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
20

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}
Jake
  • 232,450
  • 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
  • As the isosceles triangle does not have to use an incircle, it has a tighter fit for the node text. – Robert Siemer Sep 02 '19 at 23:11