在 moderncv (v.2) 中将照片添加到 \makelettertitle

在 moderncv (v.2) 中将照片添加到 \makelettertitle

我想将我的照片添加到姓名、地址、电子邮件等的\makelettertitle旁边moderncv(与 中相同的位置\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}

我想要一张\makelettertitle\makecvtitle

答案1

一种快捷方式是重新定义\makelettertitle命令以包含此内容\photo(我假设您想要与您的简历标题相同的照片)。

参照原文moderncvstyleclassic.sty,代码中用箭头标出变化部分:

\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}

简历

相关内容