2

I would like to add my photo to the \makelettertitle in moderncv next to name, address, email etc. (same place as in \makecvtitle).

\documentclass[12pt,a4paper,sans]{moderncv}        

\moderncvstyle{classic}                            
\moderncvcolor{red}                              
\usepackage[utf8]{inputenc}                      
\usepackage[scale=0.75]{geometry}


\name{Firstname}{Lastname}
\title{Title}                 
\address{address}{adress}{country}
\phone[mobil]{mobile number}      
\email{myemail}                   
\photo[64pt][0.4pt]{photo64.png}


\begin{document}
\recipient{Recipient}{Recipient}
\date{Date}
\opening{Opening}
\closing{Closing}

\makecvtitle
\makelettertitle

\end{document}

I would like a picture in \makelettertitle just like in \makecvtitle

1
  • 1
    Welcome to TeX.SE! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – Troy
    Dec 11, 2017 at 14:35

1 Answer 1

2

A quick way would be to redefine the \makelettertitle command to include this \photo (I'm assuming you want the same photo as your CV title).

With reference to the original moderncvstyleclassic.sty, changes are marked out with arrows in code:

\documentclass[12pt,a4paper,sans,%
draft,% <--------- Remove in actual document
]{moderncv}        

\moderncvstyle{classic}                            
\moderncvcolor{red}                              
\usepackage[utf8]{inputenc}                      
\usepackage[scale=0.75]{geometry}

%% Redefine the \makelettertitle command to include photo <-----------
\makeatletter
\renewcommand*{\makelettertitle}{%
    % recompute lengths (in case we are switching from letter to resume, or vice versa)
    \recomputeletterlengths%
    % optional photo (pre-rendering)% <--------------
    \newbox{\makecvtitlepicturebox}%
    \savebox{\makecvtitlepicturebox}{%
        \hspace*{\separatorcolumnwidth}%
        \ifthenelse{\isundefined{\@photo}}%
        {}%
        {%
            \color{color1}%
            \setlength{\fboxrule}{\@photoframewidth}%
            \ifdim\@photoframewidth=0pt%
            \setlength{\fboxsep}{0pt}\fi%
            \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
    \hfill%
    % sender contact info
    \begin{minipage}{.5\textwidth}%
        \raggedleft%
        \addressfont\textcolor{color2}{%
            {\bfseries\upshape\@firstname~\@lastname}\@firstdetailselementfalse%
            \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
                \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
                \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
            \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                \makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}%
            \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
            \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
            \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}%
    \end{minipage}
    \begin{minipage}{\the\wd\makecvtitlepicturebox}% <-----------
        \usebox{\makecvtitlepicturebox}
    \end{minipage}\\[1em]
    % recipient block
    \begin{minipage}[t]{.5\textwidth}
        \raggedright%
        \addressfont%
        {\bfseries\upshape\@recipientname}\\%
        \@recipientaddress%
    \end{minipage}
    % date
    \hfill% US style
    %  \\[1em]% UK style
    \@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
    % opening
    \raggedright%
    \@opening\\[1.5em]%
    % ensure no extra spacing after \makelettertitle due to a possible blank line
    %  \ignorespacesafterend% not working
    \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
\makeatother

\name{Firstname}{Lastname}
\title{Title}                 
\address{address}{adress}{country}
\phone[mobil]{mobile number}      
\email{myemail}                   
\photo[64pt][0.4pt]{photo64.png}

\begin{document}
    \recipient{Recipient}{Recipient}
    \date{Date}
    \opening{Opening}
    \closing{Closing}

    \makecvtitle
    \makelettertitle

\end{document}

cv

3
  • Thank you! But I get an undefined control sequence: <argument> \makecvtitlepicturebox l.58 \makelettertitle
    – user416235
    Dec 11, 2017 at 16:54
  • @user416235 Sorry, attached an older code. It should work now.
    – Troy
    Dec 11, 2017 at 17:08
  • Thank you very much! It works. But it would have been perfect if I could have the picture on the right and just next of the sender information.
    – user416235
    Dec 12, 2017 at 18:51

You must log in to answer this question.

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