Add the following to your preamble:
\makeatletter
\@ifpackageloaded{moderncvstylebanking}{%
\let\oldmakecvtitle\makecvtitle
\renewcommand*{\makecvtitle}{%
{\centering\framebox{\includegraphics[width=\@photowidth]{\@photo}}\par\vspace{10pt}}%
\oldmakecvtitle%
}%
}{%
}
\makeatother
This checks whether you are using the banking
style or not. If this is true, the photo is added at the top of the page, as you requested. If this is false, nothing changes, so you can use different styles even after have added this code to your document.
All you have to do is to use the command \makecvtitle
as before. The photo is printed when you issue that command.
This is the result with the modified sample file templates.tex
that accompanies the moderncv
class after having set the style to banking
:
MWE
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{picture}
\quote{Some quote}
\makeatletter
\@ifpackageloaded{moderncvstylebanking}{%
\let\oldmakecvtitle\makecvtitle
\renewcommand*{\makecvtitle}{%
{\centering\framebox{\includegraphics[width=\@photowidth]{\@photo}}\par\vspace{10pt}}%
\oldmakecvtitle%
}%
}{%
}
\makeatother
\begin{document}
\makecvtitle
% recipient data
\recipient{Company Recruitment team}{Company, Inc.\\123 somestreet\\some city}
\date{January 01, 1984}
\opening{Dear Sir or Madam,}
\closing{Yours faithfully,}
\enclosure[Attached]{curriculum vit\ae{}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis ullamcorper neque sit amet lectus facilisis sed luctus nisl iaculis. Vivamus at neque arcu, sed tempor quam. Curabitur pharetra tincidunt tincidunt. Morbi volutpat feugiat mauris, quis tempor neque vehicula volutpat. Duis tristique justo vel massa fermentum accumsan. Mauris ante elit, feugiat vestibulum tempor eget, eleifend ac ipsum. Donec scelerisque lobortis ipsum eu vestibulum. Pellentesque vel massa at felis accumsan rhoncus.
Suspendisse commodo, massa eu congue tincidunt, elit mauris pellentesque orci, cursus tempor odio nisl euismod augue. Aliquam adipiscing nibh ut odio sodales et pulvinar tortor laoreet. Mauris a accumsan ligula. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse vulputate sem vehicula ipsum varius nec tempus dui dapibus. Phasellus et est urna, ut auctor erat. Sed tincidunt odio id odio aliquam mattis. Donec sapien nulla, feugiat eget adipiscing sit amet, lacinia ut dolor. Phasellus tincidunt, leo a fringilla consectetur, felis diam aliquam urna, vitae aliquet lectus orci nec velit. Vivamus dapibus varius blandit.
Duis sit amet magna ante, at sodales diam. Aenean consectetur porta risus et sagittis. Ut interdum, enim varius pellentesque tincidunt, magna libero sodales tortor, ut fermentum nunc metus a ante. Vivamus odio leo, tincidunt eu luctus ut, sollicitudin sit amet metus. Nunc sed orci lectus. Ut sodales magna sed velit volutpat sit amet pulvinar diam venenatis.
Albert Einstein discovered that $e=mc^2$ in 1905.
\[ e=\lim_{n \to \infty} \left(1+\frac{1}{n}\right)^n \]
\makeletterclosing
\end{document}
Update (moderncv
v2.0)
With moderncv
v2.0, the command to be patched is no more \maketitle
but \makehead
and the length to be changed is now \makeheaddetailswidth
, so the correct patches for this version are
\patchcmd{\makehead}
{\hfil}
{\hspace*{0.15\textwidth}}
{}
{}
\patchcmd{\makehead}
{\setlength{\makeheaddetailswidth}{0.8\textwidth}}
{\setlength{\makeheaddetailswidth}{0.67\textwidth}}
{}
{}
\patchcmd{\makehead}
{\\[2.5em]}
{\hfil\raisebox{-.7cm}{\framebox{\includegraphics[width=\@photowidth]{\@photo}}}\\[2.5em]}
{}
{}
Original answer (works with older versions of moderncv
)
Add the following lines in your preamble
\patchcmd{\maketitle}
{\hfil}
{\hspace*{0.15\textwidth}}
{}
{}
\patchcmd{\maketitle}
{\setlength{\maketitlewidth}{0.8\textwidth}}
{\setlength{\maketitlewidth}{0.67\textwidth}}
{}
{}
\patchcmd{\maketitle}
{\\[2.5em]}
{\hfil\raisebox{-.7cm}{\framebox{\includegraphics[width=\@photowidth]{\@photo}}}\\[2.5em]}
{}
{}
and, to insert the picture, use
\photo[64pt][0.4pt]{picture}
MWE:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}
\patchcmd{\maketitle}
{\hfil}
{\hspace*{0.15\textwidth}}
{}
{}
\patchcmd{\maketitle}
{\setlength{\maketitlewidth}{0.8\textwidth}}
{\setlength{\maketitlewidth}{0.67\textwidth}}
{}
{}
\patchcmd{\maketitle}
{\\[2.5em]}
{\hfil\raisebox{-.7cm}{\framebox{\includegraphics[width=\@photowidth]{\@photo}}}\\[2.5em]}
{}
{}
% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{picture}
\begin{document}
\makecvtitle
\end{document}
Output:
Best Answer
Suppose you used the following solution to add the logo (taken from the answer of @karlkoeller):
Then you see line
\let\oldmakecvtitle\makecvtitle
. That means that the original macro is backuped in the new macrooldmakecvtitle
. So the original macro can be changed to include the photo.If you want to use the original macro just call the old macro:
See the following MWE to get a CV with photo, a letter without photo as you need:
with the results:
and
If you want to use macro
\makecvtitle
instead of\oldmakecvtitle
you can use the following line (before calling\makecvtitle
):If you cange the inserted code for the photo to:
You get the photo right in line with the title.