How to draw an inversed triangle?

This is another answer with a different approach --- I use the \rotatebox command to rotate the triangle.

\documentclass{article}
\usepackage{tikz}
\newcommand{\mybettertriangle}[1]{\tikz\filldraw[#1] (0,0) -- (0.2cm,0) -- (0.1cm,0.2cm) -- cycle;}
\newcommand{\mytriangle}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0) --
(0.2cm,0) -- (0.1cm,0.2cm);}}

\begin{document}

This is my triangle: \mybettertriangle{} \mytriangle{blue} here

Upside down: \rotatebox[origin=c]{180}{\mybettertriangle{}}

\end{document}

enter image description here

Notice some thing:

  1. \filldraw will fill and draw by default; so you can just pass #1 as option (and let you do things like passing {blue, opacity=0.5})

    enter image description here

  2. Close with --cycle closed path, it avoids possible artifacts (this is small basically because linewidth is small):

    enter image description here


You could use the rotate key:

\documentclass{article}
\usepackage{etoolbox}
\usepackage{tikz}
\newrobustcmd*{\mytriangle}[2][0]{\tikz[rotate=#1]{\filldraw[draw=#2,fill=#2] (0,0) --
(0.2cm,0) -- (0.1cm,0.2cm)--cycle;}}
\begin{document}
xxx\mytriangle{blue} \mytriangle[180]{red} \mytriangle[45]{yellow}
\end{document}

enter image description here


You can change the coordinates that define the triangle.

\documentclass{article}
\usepackage{etoolbox}
\usepackage{tikz}
\newrobustcmd*{\mytriangle}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0) --
(0.2cm,0) -- (0.1cm,0.2cm);}}
\newrobustcmd*{\downtriangle}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0.2cm) --
(0.2cm,0.2cm) -- (0.1cm,0);}}
\begin{document}
\mytriangle{blue}
\downtriangle{blue}
\end{document}

Tags:

Tikz Pgf