# draw border around edge of symbol

Is it possible to draw a (coloured) border around the edge of a LaTeX symbol?
For instance, I would like to draw a black border around the edge of a \bigstar. So, something like this

Below a very short MWE

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[scale = 0.5]
\node [yellow] at (0,0,0) {$\bigstar$};
\end{tikzpicture}
\end{document}


I searched for solutions, but I only get squared frames around basically anything, but not what I'm after. Any idea? Cheers

# Basic

\documentclass[preview,border=12pt,varwidth,dvipsnames]{standalone}
\usepackage{contour}
\usepackage{xcolor,amssymb}

\contourlength{0.5pt} % thickness
\contournumber{10} % number of replication

\begin{document}
\huge
\contour{orange}{$\bigstar$}
\end{document}


# Miscellaneous

The following example is not impossible but it takes much time and energy with PSTricks, let alone TikZ.

\documentclass[preview,border=12pt,varwidth,dvipsnames]{standalone}
\usepackage{contour}
\usepackage{xcolor,amsmath}
\usepackage{CJK}

\contourlength{0.2pt} % thickness
\contournumber{10} % number of replication

\begin{document}
\huge
\begin{CJK}{UTF8}{min}
\begin{center}
\contour{orange}{気持ちは}
\end{center}
$\contour{red}{\sqrt{x^2}}\, \contour{green}{\not=}\, \contour{blue}{x}$
\begin{center}
\contour{cyan}{言い表しにくいです}
\end{center}
\end{CJK}
\end{document}


• \contour{red}{$\sqrt{x^2}$}\, \contour{green}{$\not=$}\, \contour{blue}{$x$} should be \contour{red}{$\mathsurround=0pt\displaystyle\sqrt{x^2}$} \mathrel{\contour{green}{$\mathsurround=0pt\displaystyle\neq$}} \contour{blue}{$\mathsurround=0pt\displaystyle x$} – Henri Menke Dec 12 '18 at 2:01
• these are both great answers, thank you guys. now the dilemma: which one to accept? Is there some criteria? I don't want to be unjust with @marmot – andrea Dec 12 '18 at 9:25

I guess the most simple-minded approach would be to draw the node in black and a bit larger underneath. Notice that you need to add transform shape for the scale=0.5 to affect the node.

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[scale = 0.5,transform shape]
\node [black,scale=1.2] at (0,0,0) {$\bigstar$};
\node [yellow] at (0,0,0) {$\bigstar$};
\end{tikzpicture}
\end{document}


contour, as suggested in this answer does basically the same. However, TikZ also has star symbols built in. Why not use those?

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{tikzpicture}
\node [star,draw,fill=yellow,minimum size=5mm,star point ratio=2]{};
\end{tikzpicture}
\end{document}


The crucial advantage is that you have all sorts of parameters that you can adjust to obtain the star you really want (a so-called super-star ;-), see the pgfmanual on p. 701.

• +1. I also wrote the same code., except that I used red instead of black :) – nidhin Dec 11 '18 at 18:17
• @nidhin You very recently scooped me in another answer, which I (of course) upvoted, thanks! – marmot Dec 11 '18 at 18:21
• hehe. Then let us consider it even. :) – nidhin Dec 11 '18 at 18:22