0

How can I replace the rectangular photo / picture in moderncv, classic style, with a round one?

MWE:

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
\photo[100pt][0pt]{pictures/picture.jpg}

\begin{document}
\makecvtitle
\end{document}

Output:

enter image description here

@Ingmar: Thanks a lot for your reply! I tried your solution in your answer, but the photo is not in the right position. In addition, this solution works only with \documentclass[...]{moderncv} and not \documentclass[...]{standalone}. Do you know how to fix this and put the photo in the correct position as in the default moderncv style?

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

%% Ingmar solution
\usepackage{tikz,graphicx}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
%% Ingmar solution
% \photo[100pt][0pt]{pictures/picture.jpg}

\begin{document}
\makecvtitle
%% Ingmar solution
\begin{tikzpicture}
  \clip (0,0) circle (1);
  \node[inner sep=0pt]  at (0,0) 
{\includegraphics{pictures/picture.jpg}};
\end{tikzpicture}
\end{document}

enter image description here

1
  • 4
    Edit the photo, adding a transparent background?
    – Ingmar
    Commented Mar 24, 2022 at 19:12

2 Answers 2

2

Try this code. No additional packages are required.

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
\photo[200pt][0pt]{example-image} % <<<<<<<<<<<<< set width 

%************************************** added <<<<<<<<<<<<<<<   
\makeatletter
\usepackage{xpatch}
\xpatchcmd{\makecvhead}
{\includegraphics[width=\@photowidth]{\@photo}}
{\begin{tikzpicture}\clip (0,0) circle (2cm);\node at (0,0) {\includegraphics[width=\@photowidth]{\@photo}};\end{tikzpicture}}
{}{}
\makeatother
%************************************** 

\begin{document}    
    \makecvtitle
\end{document}

The circle has a radius of 2 cm. You need to set the width of the photo (200pt in this example) so that no border falls inside the circle.

Usage: \photo[<picture width>][0pt]{<picture filename>}

b

UPDATE after follow-up question: move the picture

Use:

\newcommand{\yshift}{<length>}  % down if negative

\newcommand{\xshift}{<length>}  % right if positive

z

This is the updated code.

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{classic}

\name{John}{Doe}
\address{Don Knuth Street, 42}{Tex City}
\photo[200pt][0pt]{example-image} % <<<<<<<<<<<<< set width 

\newcommand{\yshift}{-10ex} % vertical photo shift <<<<<<<<
\newcommand{\xshift}{2ex}  % horizontal  photo shift <<<<<<<<   

%************************************** added <<<<<<<<<<<<<<<
\makeatletter
\usepackage{xpatch}
\xpatchcmd{\makecvhead}
{\includegraphics[width=\@photowidth]{\@photo}}
{\begin{tikzpicture}\clip (0,0) circle (2cm);\node at (0,0){\includegraphics[width=\@photowidth]{\@photo}};\end{tikzpicture}}
{}{}
\xpatchcmd{\makecvhead}
{\usebox{\makecvheadpicturebox}}
{}
{}{}
\xpatchcmd{\makecvhead}
{\usebox{\makecvheadpicturebox}}
{\hspace*{\xshift}\raisebox{\yshift}{\usebox{\makecvheadpicturebox}}}
{}{}    
\makeatother
%************************************** 

\begin{document}    
    \makecvtitle    
\end{document}
3
  • Great solution @Simon Dispa! Many thanks! ....just a question... is there the possibility of change the position of the photo/circle? Maybe, by changing the center coordinates such that the entire photo/circle moves up, down, left or right?
    – Ommo
    Commented Apr 1, 2022 at 14:56
  • 1
    @limone Please see the updated answer. Commented Apr 1, 2022 at 21:22
  • Perfect!! Thanks a lot !!! Very kind!!!
    – Ommo
    Commented Apr 3, 2022 at 10:10
3

I spoke too fast in my comment above. Obviously there are built-in ways to achieve that, if you're willing to use TikZ:

\documentclass{standalone}
\usepackage{tikz,graphicx}
\begin{document}
\begin{tikzpicture}
  \clip (0,0) circle (1);
  \node[inner sep=0pt]  at (0,0) {\includegraphics{example-image}};
\end{tikzpicture}
\end{document}
2
  • thanks for your answer, but it is not working for me.. I showed an attempt to use your solution in my MWE directly in my question..check it out :)
    – Ommo
    Commented Mar 25, 2022 at 10:14
  • TikZ is ok, many thanks, but I would need (i) to use \documentclass[...]{moderncv} and (ii) put the picture in the same area as in the default moderncv
    – Ommo
    Commented Mar 25, 2022 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .