[Tex/LaTex] Modify moderncv header

moderncv

Is there a possibility to change the order of photo and name in the moderncv class using \moderncvtheme[blue]{casual}?

Right now it looks like this:

PHOTOPHOTO
PHOTOPHOTO
PHOTOPHOTO
PHOTOPHOTO
PHOTOPHOTO                      FirstName LastName
__________________________________________________

But actually I want it to look like this:

                                        PHOTOPHOTO
                                        PHOTOPHOTO
                                        PHOTOPHOTO
                                        PHOTOPHOTO
FirstName LastName                      PHOTOPHOTO
__________________________________________________

How can I do that?

Best Answer

You just need to change the \maketitle command:

% reverse the name and photo
\makeatletter
% maketitle
\renewcommand*{\maketitle}{%
  {%
    {\firstnamestyle{\@firstname}~\familynamestyle{\@familyname}}}%
    \hfill%
    \ifthenelse{\isundefined{\@photo}}%
      {}%
      {{\color{firstnamecolor}\framebox{\includegraphics[width=\@photowidth]{\@photo}}}\\[-.35em]}%
    {\color{firstnamecolor}\rule{\textwidth}{.25ex}\\[2.5em]}%
% optional quote
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\centering{}\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
  \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle
\makeatother

The hardest part is determining where to put this block of code. The \maketitle command is defined not in moderncv.cls, but in the theme (package) file such as moderncvthemecasual.sty. Moreover, the implementation of \moderncvtheme makes sure that this theme package is not loaded until the end of the preamble.

So if you want to do this once, put it in your cv TeX file, but it has to be expanded after \begin{document} and before \maketitle. The best way to do this is to surround the block above with \AtBeginDocument{...} in the preamble, after \moderncvtheme[blue]{casual}.

If you want to do this more than once, you could copy the file moderncvthemecasual.sty and add a package option. If this is beyond your expertise you may want to email the developers and see if they'll consider it.