Here's what my equation looks like; it's in an align* environment:


I want to put a circle around $\varepsilon \frac{dL}{d\varepsilon}$ and everything else unchanged.

Q: How do I draw a circle around a term in an align* equation?

I found that \textcircled doesn't work in math mode and \tikz \node[circle,draw] { $\varepsilon \frac{dL}{d\varepsilon}$}; is not suitable as it shifts the term:

enter image description here

I get fairly close using \boxed{\varepsilon \frac{dL}{d\varepsilon}}, but it's not a circle:

enter image description here

Here's a working example:




L(q+\varepsilon) = L(q) + \varepsilon \frac{dL}{d\varepsilon} + \cdots \\


The TikZ-way you tried works, you just forgot to set the baseline of the tikzpicture to the baseline of the text inside the math node. Here is an adjusted solution which also respects the mathstyle outside of the node.

\usepackage{mathtools}% superior to amsmath
  \tikz[baseline=(math.base)] \node[draw,circle,inner sep=1pt] (math) {$\m@th#1#2$};%

  &= L(q) + \mathcircled{\varepsilon \frac{dL}{d\varepsilon}} + \cdots \\
  &= \textstyle L(q) + \mathcircled{\varepsilon \frac{dL}{d\varepsilon}} + \cdots \\
  &= \scriptstyle L(q) + \mathcircled{\varepsilon \frac{dL}{d\varepsilon}} + \cdots \\
  &= \scriptscriptstyle L(q) + \mathcircled{\varepsilon \frac{dL}{d\varepsilon}} + \cdots


enter image description here

  • Excellent. Thanks, that's exactly what I'm after. – Rebecca J. Stones Jun 11 '15 at 6:22
  • What is the meaning of $\m@th#1#2$. Would you please explain the code. – Fadwa Nov 18 '15 at 19:28
  • 1
    @Misaki The definition is \m@th: macro:->\mathsurround \z@. That is to say, it sets \mathsurround to 0pt. – Henri Menke Nov 18 '15 at 20:00
  • I am trying to add two circles instead of one, i used your code and add one in another \mathcircled{\mathcircled{\varepsilon \frac{dL}{d\varepsilon}}}, but the spacing between them is large besides i can't change the color of the other. would you please help. Thanks – Fadwa Nov 19 '15 at 5:21
  • @Misaki Instead of nesting, use this definition of \dblmathcircled: \newcommand\dblmathcircled[1]{\mathpalette\@dblmathcircled{#1}} \newcommand\@dblmathcircled[2]{\tikz[baseline=(math.base)]\node[draw,circle,double,inner sep=1pt] (math) {$\m@th#1#2$};}. – Henri Menke Nov 19 '15 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.