2

I have a figure and would like to highlight a particular region of that figure with a circle or an ellipse as shown in figure:

enter image description here

It is important that the line of the circle or ellipse are thick. How do I control the location of the circle, to up, down, right or left?

Thanks a lot!

2 Answers2

10

With TikZ:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning,shapes}
\begin{document}

\begin{center}
\begin{tikzpicture}
\node(a){\includegraphics{circle.png}};
\node at(a.center)[draw, red,line width=3pt,ellipse, minimum width=118pt, minimum height=50pt,rotate=-28,yshift=-48pt]{};
\end{tikzpicture}   
\end{center}

\end{document} 

enter image description here

I used red so that you can see where my ellipse is with respect to the original ellipse. You can fine-tune the positioning via shifts, rotate, etc.

d-cmst
  • 23,095
6

Here is a way by using \tikz for the ellipse, and then \stackinset to overlay it on the image. Arguments #2 and #4 to \stackinset are the offsets from the left, bottom of the image (horizontal offsets can be with respect to l, c, or r and vertical t, c, or b), while the 4 arguments to \solidcirc are the rotation angle, line thickness, and the x and y radii of the ellipse.

\documentclass{article}
\usepackage{stackengine,tikz,graphicx}
\newcommand\solidcirc[4][0]{\rotatebox{#1}{\tikz{\draw[line width=#2] (0,0) 
  arc [x radius=#3,y radius=#4,start angle=0,end angle=360];}}}
\begin{document}
\stackinset{l}{1in}{b}{.8in}{\textcolor{blue}{\solidcirc[-30]{3pt}{2.8}{1.0}}}
  {\includegraphics{example-image}}
\end{document}

enter image description here

  • Is it possible to draw more than one ellipse in the same figure? For example, a blue ellipse and a red ellipse. – Wendell Fialho Mar 20 '20 at 22:57
  • @WendellFialho Yes. You can nest them, wherein the first inset becomes argument #6 of the outer inset. If you do many insets at once, it renders more quickly if you save intermediate results in a box, and use the box as argument #6. The \savestack mechanism utilizes this boxed mechanism. E.g. \savestack\inbox{\stackinset{}{}{}{}{}{}}. Then, \stackinset{}{}{}{}{}{\inbox}. – Steven B. Segletes Mar 21 '20 at 00:14
  • Thank you so much for your answer. But I did not understand the practice of how this command works to insert multiple ellipses. You can kindly demonstrate it through an example image. – Wendell Fialho Mar 21 '20 at 01:27
  • @WendellFialho This, answer, https://tex.stackexchange.com/questions/171483/mathematical-formulas-on-a-graph-not-made-by-tex/171486#171486, shows nested \stackinsets... 5 insets over the base image. – Steven B. Segletes Mar 21 '20 at 02:04
  • @WendellFialho \documentclass{article} \usepackage{stackengine,tikz} \newcommand\solidcirc[4][0]{\rotatebox{#1}{\tikz{\draw[line width=#2] (0,0) arc [x radius=#3,y radius=#4,start angle=0,end angle=360];}}} \begin{document} \stackinset{l}{.5in}{b}{.3in}{\textcolor{red}{\solidcirc[30]{3pt}{2.4}{1.0}}}{\stackinset{l}{1in}{b}{.8in}{\textcolor{blue}{\solidcirc[-30]{3pt}{2.8}{1.0}}}{\includegraphics{example-image}}} \end{document} – Steven B. Segletes Mar 21 '20 at 02:10
  • I am trying to apply this method to make 3 circles and even more occasions (e.g. 3, 4, 5 ...) circles. In an attempt to make the third circle and following your example I did it according to the following code, however, I was not successful: – Wendell Fialho Mar 21 '20 at 02:45
  • \documentclass{beamer} \usepackage{stackengine,tikz} \newcommand\solidcirc[4][0]{\rotatebox{#1}{\tikz{\draw[line width=#2] (0,0) arc [x radius=#3,y radius=#4,start angle=0,end angle=360];}}}

    \begin{document} \stackinset{l}{.5in}{b}{.3in}{\textcolor{red}{\solidcirc[30]{3pt}{2.4}{1.0}}}{\stackinset{l}{1in}{b}{.8in}{\textcolor{blue}{\solidcirc[-30]{3pt}{2.8}{1.0}}}{\stackinset{l}{1in}{b}{.8in}{\textcolor{green}{\solidcirc[-30]{3pt}{2.8}{1.0}}}{\includegraphics{example-image}}} \end{document}

    – Wendell Fialho Mar 21 '20 at 02:45
  • @WendellFialho \documentclass{beamer} \usepackage{stackengine,tikz} \newcommand\solidcirc[4][0]{\rotatebox{#1}{\tikz{\draw[line width=#2] (0,0) arc [x radius=#3,y radius=#4,start angle=0,end angle=360];}}} \begin{document} \stackinset{l}{.5in}{b}{.3in}{\textcolor{red}{\solidcirc[30]{3pt}{2.4}{1.0}}} {\stackinset{l}{1in}{b}{.8in}{\textcolor{blue}{\solidcirc[-30]{3pt}{2.8}{1.0}}} {\stackinset{l}{1.4in}{b}{.8in}{\textcolor{green}{\solidcirc[-30]{3pt}{2.8}{1.0}}} {\includegraphics{example-image}}}} \end{document} – Steven B. Segletes Mar 21 '20 at 03:16