# How do I draw an ellipse around a term in an equation?

I have seen how to draw a circle around a term in an equation (here). With the following code:

\makeatletter
\newcommand\mathcircled{%
\mathpalette\@mathcircled{#1}%
}
\newcommand\@mathcircled{%
\tikz[baseline=(math.base)] \node[draw,circle,inner sep=1pt, blue] (math) {$\m@th#1#2$};%
}
\makeatother

Needed assumptions on F, since we know $\lambda_1^*$ must lie within $0,1$ \\
$\frac{b- \frac{F}{[\alpha(1-\gamma) - \gamma]}}{b-a} \leq 1 \iff b- \frac{F}{[\alpha(1-\gamma) - \gamma]} \leq b-a \iff \mathcircled{F \geq a \cdot [\alpha(1-\gamma) - \gamma]}$


However, the result is aesthetically not satisfactory, since the term is quite long. I would like the circle/ellipse to rather adapt to the length of the term (just like the \boxed{} command of amsmath does for instance). E.g something like the following for my example in particular: • Use ellipse instead of circle? You need to \usetikzlibrary{shapes.geometric} Jul 13, 2021 at 14:44
• Tikz also supports ellipse. You might find tex.stackexchange.com/questions/399116/… useful. Jul 13, 2021 at 14:46
• Also look at tex.stackexchange.com/questions/570856/… (search for "tikz latex highlight formula" in google and you'll have plenty of them). Jul 13, 2021 at 14:46
• BTW, Welcome! Next time, please post minimal working example (MWE) to simplify the task of the answerer... Jul 13, 2021 at 14:47
• Do you want the ellipse to affect the spacing around the term, and if not should the ellipse be behind the text? Jul 13, 2021 at 15:12

The circledsteps package (based on TiKZ) defines some rectangle with rounded smal sides for long terms.

However, if you really want an ellipse, pstricks defines a \psovalboxfor that:

\documentclass{article}
\usepackage{tikz}
\usepackage{circledsteps}
\usepackage{pstricks}

\begin{document}

Needed assumptions on F, since we know $\lambda_1^*$ must lie within $0,1$
$\frac{b- \frac{F}{[\alpha(1-\gamma) - \gamma]}}{b-a} \leq 1 \iff b- \frac{F}{[\alpha(1-\gamma) - \gamma]} \leq b-a \iff \Circled[inner color=blue, outer color=blue]{F \geq a \cdot [\rule[-1.5ex]{0pt}{4ex}\alpha(1-\gamma) - \gamma]\:}$

$\frac{b- \frac{F}{[\alpha(1-\gamma) - \gamma]}}{b-a} \leq 1 \iff b- \frac{F}{[\alpha(1-\gamma) - \gamma]} \leq b-a \iff \psovalbox[linecolor=blue, linewidth=0.5pt]{\color{blue} F \geq a \cdot [\rule[-1.5ex]{0pt}{4ex}\alpha(1-\gamma) - \gamma]}$

\end{document} Based on the solution you provide, why don't you use the shape library to draw an ellipse instead of a circle? \documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shapes}

\makeatletter
\newcommand\mathcircled{%
\mathpalette\@mathcircled{#1}%
}
\newcommand\@mathcircled{%
\tikz[baseline=(math.base)] \node[draw,ellipse,inner sep=1pt] (math) {$\m@th#1#2$};%
}
\makeatother
\begin{document}

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

\end{document}