[Tex/LaTex] ModernCV cover letter – switch sides

moderncv

I want to slightly edit Cover letter in ModernCV Latex template. I want to have my personal data on the left side of the page and the recipient and my signature (under the letter) on the right. How can I do this?

Thanks!

Best Answer

\documentclass{moderncv}

\moderncvstyle{classic}
\moderncvcolor{orange}

\makeatletter
\renewcommand*{\recomputeletterlengths}{%
  \recomputecvlengths%
  \setlength{\parskip}{6\p@}}

\renewcommand*{\makelettertitle}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputeletterlengths%
  % sender contact info
  \begin{minipage}[t]{.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}
    % date
  \hfill% US style
  %\\[1em]% UK style
  \@date%\\[1em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  % recipient block
  \par\mbox{}\hfill%
  \begin{minipage}[t]{.5\textwidth}
    \raggedleft%
    \addressfont%
    {\bfseries\upshape\@recipientname}\\%
    \@recipientaddress%
    \par
  \end{minipage}
  \\[2em]
  % opening
  \raggedright%
  \@opening\\[1.5em]%
  \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}

\renewcommand*{\makeletterclosing}{%
  \raggedleft
  \@closing\\[3em]%
  \raggedright
  {\bfseries \@firstname~\@lastname}%
  \ifthenelse{\isundefined{\@enclosure}}{}{%
    \\%
    \vfill%
    {\color{color2}\itshape\enclname: \@enclosure}}}
    \makeatother

\usepackage{lipsum}
\title{Curriculum Vitae}
\address{Some street}{City}
\mobile{123456}
\phone{3654789}
\fax{85698745}

\begin{document}

\recipient{HR Departmnet}{Corporation\\123 Pleasant Lane\\12345 City, State} % Letter recipient
\date{\today} % Letter date
\opening{Dear Sir or Madam,} % Opening greeting
\closing{Sincerely yours,} % Closing phrase
\enclosure[Attached]{curriculum vit\ae{}} % List of enclosed documents

\makelettertitle % Print letter title
\lipsum[1-2] % Dummy text

\makeletterclosing % Print letter signature

%----------------------------------------------------------------------------------------

\end{document}

enter image description here