8

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.

2
  • What do you mean with the "header" part? Is it the header as in headers/footers of a document or is it the part containing the name and personal information? Which theme (casual, classic) are you using? Mar 5, 2014 at 23:54
  • I mean the part containing personal info. Currently I'm using the classic theme.
    – Ketouem
    Mar 6, 2014 at 0:00

1 Answer 1

10

One option using the tikzmark library:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\name{John}{Doe}
\title{Title}
\address{\tikzmark{start}street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information\tikzmark{end}}
\photo[64pt][0.4pt]{picture}
\quote{Some quote}

\begin{document}

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

\makecvtitle

\section{Education}

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

\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

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

\end{document}

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]
\fill[color1!30]
  (current page.north west) rectangle ([yshift=-1cm]current page.east|-{pic cs:end});
\end{tikzpicture}

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.

0

You must log in to answer this question.

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