1

I added a photo in ModernCV Title using the command below. The results are in example 1. I would like to have it in a way that the both the photo and title are centered in the title as one bloc as in example 2.

Code

\makeatletter
\@ifpackageloaded{moderncvstylebanking}{%
\let\oldmakecvtitle\makecvtitle
\renewcommand*{\makecvtitle}{%
  \oldmakecvtitle%
  {\raggedleft\includegraphics[scale=0.8]{picture}\par}%
}%
}{%
}
\makeatother

Example 1

Example 2

4
  • No it's not. I want both the title and photo on the same line. Thanks ;)
    – Odin
    Commented Sep 14, 2014 at 17:39
  • what about this: tex.stackexchange.com/questions/154383/… ?
    – d-cmst
    Commented Sep 14, 2014 at 18:25
  • but this is not I want :D I saw this before. I want them together centered in half. Actually what he did in this post can be also achieved using \begin{textblock}{0}(11.4,0.5) \includegraphics[scale=0.07]{photo} \end{textblock}
    – Odin
    Commented Sep 14, 2014 at 18:32
  • If you notice from my photos examples that even the title is shifted to the left to make space for photo.
    – Odin
    Commented Sep 14, 2014 at 18:33

2 Answers 2

1

You can patch \maketitle - used by the banking style in moderncv to create the title.

The default width of the title in banking is .8\textwidth, leaving .2\textwidth "to play with. The patch below inserts an image to the right of the title:

\patchcmd{\maketitle}% <cmd>
  {\\[2.5em]}% <search>
  {\hfill\includegraphics[width=.2\textwidth,height=50pt]{example-image}\\[2.5em]}% <replace>
  {}{}% <success><failure>

You may have to fiddle with the vertical positioning through \raisebox:

enter image description here

5
  • but for the size of the photo am using it also goes on new line :/
    – Odin
    Commented Sep 14, 2014 at 18:38
  • maybe I just flush to left and use textblock to locate it where I want.
    – Odin
    Commented Sep 14, 2014 at 18:40
  • @Odin: I've used the width and height options to rescale the image to fit. Anything wider than .2\textwidth will make it go to the following line.
    – Werner
    Commented Sep 14, 2014 at 18:41
  • Exactly. My idea if possible to have them as one block to center in page. For now I will flush title left to see if someone comes up with solution
    – Odin
    Commented Sep 14, 2014 at 18:42
  • 1
    You may also be interested in using \raisebox{<len>}[0pt][0pt]{\includegraphics[..]{...}} which will raise the box <len> from it's current placement (downward if <len> is negative) but won't influence the other components (due to [0pt][0pt]).
    – Werner
    Commented Sep 14, 2014 at 18:43
1

Easy workaround. I used \hskip to shift \makecvtitle and placed the photo using \begin{textblock} as follows

\hskip -3.5cm {\makecvtitle}

\begin{textblock}{0}(10.5,1)
  \includegraphics[]{picture}\par
\end{textblock}

I believe you can use \being{minipage} in \begin{document} to achieve the same results but this is working just perfect for me.

Result

Update You have to add \usepackage[absolute,overlay]{textpos} in the preamble.

You must log in to answer this question.

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