I'm currently using this code
\raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {f}}}
to get

I'm trying to index the function f inside the box, with say $f_{n}$ but \textcircled doesn't seem to like this. Any suggestions? Thank you!
I'm currently using this code
\raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {f}}}
to get

I'm trying to index the function f inside the box, with say $f_{n}$ but \textcircled doesn't seem to like this. Any suggestions? Thank you!
I'm not sure what you mean by "\textcircled doesn't seem to like this", because
\documentclass{article}
\begin{document}
\raisebox{.5pt}{\textcircled{\raisebox{-.9pt} {$f_n$}}}
\end{document}
compiles fine for me. That said, it does look a bit rubbish:

You might consider a little TikZ picture for this situation. You could put the $f_n$ inside a circular TikZ node. The node would adjust its size correctly, depending on its contents, and align correctly on the baseline of the surrounding text.
\documentclass{article}
\usepackage{tikz}
\newcommand\encircle[1]{%
\tikz[baseline=(X.base)]
\node (X) [draw, shape=circle, inner sep=0] {\strut #1};}
\begin{document}
Lorem \encircle{$f_n$} ipsum \encircle{q} dolor \encircle{a}
sit \encircle{A} amet \encircle{Hello}.
\end{document}

\newcommand{\circled}[2][6pt]{\raisebox{-#1}{\tikz{\node (F) at (0,0) {#2};\draw[thick](F)\circle(#1);}}}
– Jhor
Jul 13 '13 at 21:19
draw, shape=circle with draw, dashed, shape=circle.
– John Wickerson
Oct 01 '15 at 10:13
\circled? I get an 'undefined control sequence' error.
– John Wickerson
May 07 '16 at 15:22