[Tex/LaTex] Symbol filled with colour using tikz

drawsymbolstikz-pgf

I am trying to reference data presented in figures in my text. In order to identify the data being discussed, I draw the symbol in the text.

I can use tikz to draw the circle that is filled with various color as shown in my MWE. I was wondering is there a way to draw other symbols like diamond, triangleright, square, square, triangledown or triangleleft in similar manner (please see the MWE)?

I was wondering if this is the right way to do this? Or is there an easier way?

\documentclass{article}
% draw circles
\usepackage{tikz,siunitx,gensymb}
\newcommand{\tikzcircle}[2][red,fill=red]{\tikz[baseline=-0.5ex]\draw[#1,radius=#2] (0,0) circle ;}%


\begin{document}

    This is a circle with pink filling and blue border (\tikzcircle[blue, fill=pink]{3pt}) \\
    This is a circle with red filling and black border (\tikzcircle[black, fill=red]{3pt}) \\

    I would like to have command like "tikzcircle" for more symbols such as $ \diamond , \triangleright $ or $\triangleleft$ for example. 
\end{document}

Best Answer

The pgfmanual is full of shapes. Of course you could define symbols as follows:

\documentclass{article}
% draw circles
\usepackage{tikz,siunitx}
\usetikzlibrary{shapes.geometric,shapes.symbols}
\newcommand{\tikzcircle}[2][red,fill=red]{\tikz[baseline=-0.5ex]\draw[#1,radius=#2] (0,0) circle ;}%

\newcommand{\tikzsymbol}[2][circle]{\tikz[baseline=-0.5ex]\node[inner
sep=2pt,shape=#1,draw,#2]{};}%

\begin{document}

\tikzsymbol{fill=blue}

\tikzsymbol[ellipse]{minimum width=8pt}

\tikzsymbol[rectangle]{minimum width=8pt,fill=yellow}

\tikzsymbol[diamond]{fill=purple}

\tikzsymbol[trapezium]{fill=purple}

\tikzsymbol[star]{fill=yellow}

\tikzsymbol[kite]{fill=blue}

\tikzsymbol[cylinder]{minimum width=5mm,minimum height=8mm,
cylinder uses custom fill, cylinder end fill=red!50,cylinder body fill=blue}

\tikzsymbol[cloud]{minimum width=8mm,minimum height=4mm}
\end{document}

enter image description here

I stress that this is only a tiny subset of the full set of possible shapes. However, I also think that on the long run you won't use such commands, but directly work with tikz, yet this is just a guess.

Related Question