[Tex/LaTex] How should I put a command in \circled

circles

I want to write a command, for example \pi or \rightarrow, inside a circle. I tried \circled{\pi} but this doesn't work.

How do I do it?

Best Answer

Define \circled in your preamble:

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=1](char) {#1};}}

Use math environment:

\circled{$\pi$}