[Tex/LaTex] Checkmark with specific color

symbols

I am trying to include a checkmark in my table that has for example blue color.
I have managed to do it using a solution i have found here by using:
\def\bluecheck{\tikz\fill[scale=0.4, color=blue](0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;}

end then calling \bluecheck

The problem is when i insert \bluecheck in the caption of my table i get a number of errors (even though it compiles and renders the expected pdf)

Is there a library that creates a checkmark that allows to set its color?

Best Answer

The original problem is that \bluecheck is not a robust command and breaks inside moving arguments like \caption. The caption title moves via the .aux file to the .lot file for the list of contents. The solution is to define the command with \DeclareRobustCommand or with \protected\def:

\documentclass{article}
\usepackage{tikz}

\newcommand{\bluecheck}{}%
\DeclareRobustCommand{\bluecheck}{%
  \tikz\fill[scale=0.4, color=blue]
  (0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;%
}

\begin{document}
\listoftables
\begin{table}
\caption{Blue check mark \bluecheck}
\end{table}
\end{document}

Result

Related Question