6

Can somebody help me figure out how to include a jpg in my CV that is then cropped to a circle? I already found this question that closely resembles what I am trying to do - however I also would like to reposition the image inside the circle (in case for example the image is larger than the circle and the section I want to show is placed not in the center of the image).

A MWE of what I have right now:

\documentclass{article}

\usepackage{tikz}
\usepackage{mwe}

\begin{document}

\begin{tikzpicture}
    \clip (0,0) circle (2cm) node {\includegraphics[width=10cm]{example-image}};
\end{tikzpicture}

\end{document}

How can one reposition the graphic inside the node?

  • 1
    As always on this site, you are much much more likely to get help if you provide code others can copy and use as is. As your question sits here, it falls in to the category of "please do this for me" which gennerally gets downvoted. – daleif Oct 11 '19 at 9:01
  • My entire question would be better suited as a comment in the other thread as it is probably just a slight variation. Unfortunately I have too little reputation to comment there however. I just can't figure out how to reposition the graphics inside the circular node - is a full MWE really necessary in that case? – Daniel M Oct 11 '19 at 9:04
  • 1
    And make the example complete, not sniplets. – daleif Oct 11 '19 at 9:07
  • 1
    Thanks for the tips - added a MWE with the default frog image. – Daniel M Oct 11 '19 at 9:17
  • 1
    Because of the global positioning the placement of the image in relation to the clipped path can get tricky, see my comment to BMs answer. – daleif Oct 11 '19 at 9:36
5

You can do something like this:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\clip (0,0)  circle (2cm) ;
\node[anchor=center] at (2,1) {\includegraphics[width=10cm]{example-image}}; 
%adjust this coordinate to move image
\end{tikzpicture}

\end{document}

and then shift the image by adjusting the coordinate and anchor of the node. See sample outputs for different coordinates.

enter image description here enter image description here enter image description here

  • that's exactly what I was looking for - thanks a lot! – Daniel M Oct 11 '19 at 9:43
  • It is not convenient to stick picture with absolute coordinate such as current page text area.north east – Black Mild Oct 11 '19 at 10:03
  • @BlackMild took the coordinates directly from OP – nidhin Oct 11 '19 at 10:19
  • @nidhin Yeah, I know. I think when OPs ask, they are somehow unclear (that is why they ask). It's more helpful to community if simple/clean answers are provided. I myself benefit a lot from clean answers and discussion from this site. – Black Mild Oct 11 '19 at 10:25
  • 1
    @BlackMild I have edited to make it clean. – nidhin Oct 11 '19 at 11:04
7

Something like this? Position of entire tikzpicture can be set using flushleft, flushright, and/or in suitable minipage.

enter image description here

% picture from https://www.lgbotanicals.com/Jasmine-Grandiflorum-Absolute_p_242.html
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\clip (0,0) circle (2cm) node {\includegraphics[width=4cm]{jasmine}};
\end{tikzpicture}
\end{center}    
\end{document}

Update: from daleif's suggestion. Suppose we want to show the flower buds on the left. Just manually control the coordinate in clip command. In this case, we move to the point (160:1.5) and showing the part of the picture inside the circle of radius 1.6cm. The red is just for showing the position of the origin, and should be removed.

enter image description here

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\clip (160:1.5) circle (1.6cm); 
\path (0,0) node{\includegraphics[width=6cm]{jasmine}};
\fill[red] (0,0) circle(2mm);
% picture from https://www.lgbotanicals.com/Jasmine-Grandiflorum-Absolute_p_242.html
\end{tikzpicture}
\end{center}    
\end{document} 
  • This does not look like what I tried to have answered. The question is how to move the graphic inside the circular node so that a different section is shown than just the centre. Isn't your post just an even more minimal version of my MWE? – Daniel M Oct 11 '19 at 9:27
  • 1
    @DanielM BMs example is equivalent to \clip (0,0) circle (2cm); node at (0,0) {\includegraphics[width=4cm]{jasmine}}; If you split it like this then it is easy to mode the image independently of the clip circle. Tip give \clip the option [draw] and it will draw the outline. Here clip just means that until the end op scope everything you draw is clipped to that path, so it does not need to be a part of that path. – daleif Oct 11 '19 at 9:36
  • 1
    I've just updated as @daleif's suggestion. – Black Mild Oct 11 '19 at 9:52
  • Too bad you chose a beautiful flower instead of corn. Then you could truly have depicted a "crop circle"! ;^0 – Steven B. Segletes Oct 11 '19 at 11:28
  • @StevenB.Segletes why isn't corn beautiful? It's matter of taste! the bud - the youngest flower - the cleanest - is the best part in a blossom – Black Mild Oct 11 '19 at 15:09
4

Put the node in a separate command, and change either the position of the clip or the one of the circle:

\documentclass{article}

\usepackage{tikz}
\usepackage{mwe}

\begin{document}

Clip and circle have the same center: \hfill
\begin{tikzpicture}
    \clip (0,0) circle (2cm);
    \node at (0,0) {\includegraphics[width=10cm]{example-image}};
\end{tikzpicture}
\smallskip

Here the node is shifted toward horizontal axis: \hfill
\begin{tikzpicture}
    \clip (0,0) circle (2cm);
    \node at (1,0) {\includegraphics[width=10cm]{example-image}};
\end{tikzpicture}
\medskip

And you can alternatively move the clip circle or the image node:\\
\begin{tikzpicture}
    \clip (0,0) circle (2cm);
    \node at (1,1) {\includegraphics[width=10cm]{example-image}};
\end{tikzpicture}
is equivalent to :
\begin{tikzpicture}
    \clip (-1,-1) circle (2cm);
    \node at (0,0) {\includegraphics[width=10cm]{example-image}};
\end{tikzpicture}

\end{document}

Example

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.