[Tex/LaTex] ny way to add a background color to the header part of a file that use moderncv


I was wondering if there are any way to set the background color of the header part (the one that contains personal info) of a file that uses moderncv in order to visually differentiate the header and the content.

I tried with minipage, \hfill and so on but I guess that moderncv uses a heavily customized template and everything I've tried so far lead to a compile error.

Best Answer

One option using the tikzmark library:


\address{\tikzmark{start}street and number}{postcode city}{country}
\extrainfo{additional information\tikzmark{end}}
\quote{Some quote}


\begin{tikzpicture}[remember picture,overlay]
  (current page.north west) rectangle ([yshift=-1cm]current page.east|-{pic cs:end});



\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\section{Master thesis}
\cvitem{description}{Short thesis abstract}

\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
  \item Sub-achievement (a);
  \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
    \item Sub-sub-achievement i;
    \item Sub-sub-achievement ii;
    \item Sub-sub-achievement iii;
  \item Sub-achievement (c);
\item Achievement 3.


enter image description here

You place some mark(s) using \tikzmark and then use those marks to draw a rectangle filled with the desired color. In my example code I used

\begin{tikzpicture}[remember picture,overlay]
  (current page.north west) rectangle ([yshift=-1cm]current page.east|-{pic cs:end});

which draws a rectangle having opposite vertices in (current page.north west) (i.e., the upper left corner of the page) and in the point with coordinates ([yshift=-1cm]current page.east|-{pic cs:end}) (this means 1cm below the point that has the same x-coordinate as the leftmost end of the page and the y-coordinate of the point marked end); the end mark was placed inside \extrainfo which was the lowest element used in the personal information. I also placed a start mark in the upper field of the personal information, but I never used this mark.

Feel free to change the colors, and position of the colored background, according to your needs.