5

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

\makeatletter
\newcommand\mathcircled[1]{%
  \mathpalette\@mathcircled{#1}%
}
\newcommand\@mathcircled[2]{%
  \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]}$

I get this: aesthetically not satisfactory

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: Wanted result

SebGlav
  • 19,186
  • Use ellipse instead of circle? You need to \usetikzlibrary{shapes.geometric} – Rmano Jul 13 '21 at 14:44
  • Tikz also supports ellipse. You might find https://tex.stackexchange.com/questions/399116/ideal-shape-of-elliptical-nodes useful. – John Kormylo Jul 13 '21 at 14:46
  • Also look at https://tex.stackexchange.com/questions/570856/how-can-i-highlight-part-of-an-equation-with-tikz-but-without-extra-space-around (search for "tikz latex highlight formula" in google and you'll have plenty of them). – Rmano Jul 13 '21 at 14:46
  • 1
    BTW, Welcome! Next time, please post minimal working example (MWE) to simplify the task of the answerer... – Rmano Jul 13 '21 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? – Andrew Stacey Jul 13 '21 at 15:12

2 Answers2

3

Based on the solution you provide, why don't you use the shape library to draw an ellipse instead of a circle?

ellipse around part of equation

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shapes}

\makeatletter \newcommand\mathcircled[1]{% \mathpalette@mathcircled{#1}% } \newcommand@mathcircled[2]{% \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}

SebGlav
  • 19,186
3

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}

enter image description here

Bernard
  • 271,350