# indexed letters inside circles

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}

• If you prefer to externally control the size of the node, use : \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
• how do you do the same with dashed lines? – Luis Felipe Sep 24 '15 at 21:23
• @LuisFelipeVillavicencioLopez Replace draw, shape=circle with draw, dashed, shape=circle. – John Wickerson Oct 1 '15 at 10:13
• @MCMastery Could you provide an example? – John Wickerson May 6 '16 at 9:04
• @JohnWickerson I attempted to use it inside a caption and it did not work. It worked well outside the caption, though. Do you know where the problem can be? – Stefano Nov 8 '18 at 15:05

## protected by Community♦Feb 2 '15 at 16:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).