I would like to encircle one character inside a LaTeX formula. An example is

$f_1 = ...$ or $f_k = ...$,

where I want to encircle the characters 1 and k. I've found some questions (question 1, question 2) about how to encircle one character or an entire (small) formula. But how should I encircle only one character of a LaTeX formula? Is there an easy solution such as

$f_\encircled{1} = ...$

(my preference), should I use symbols such as from the \ding library, or use TikZ?

2 Answers 2


Slight improvement of ThV's answer, in order to preserve the proper math style.



  \tikz[baseline,anchor=base]{\node[draw,circle,outer sep=0pt,inner sep=.2ex] {#1};}}


\encircled{Text} outside math. $\encircled{n=1}$ formula.
f_{\encircled{n}} = \encircled{f_n}


enter image description here


I would use TikZ to achieve this. Here's some rough sample code that is similar to what is used in the answers to question 1 and question 2 that you mentioned:


  \node[draw,circle,outer sep=0pt,inner sep=.2ex]


\encircled{Text} outside math. \encircled{$n=1$} formula.
Or $\encircled{n}$ like this.
\[ f_{\encircled{n}} = \encircled{f_n} \]


For convenience, I've added code to automatically switch to math mode if needed. This is based on question 3.

enter image description here

  • @campa : what do you mean with "wrong style for the subscript"?
    – pzorba75
    Commented Feb 2, 2018 at 12:10
  • 3
    @pzorba75 Look at the size of the encircled subscript n: it's larger than on the right-hand side. The latter uses (correctly) \scriptstyle, while the former employs \textstyle.
    – campa
    Commented Feb 2, 2018 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .