Moderncv adding date of birth to personal information

To put the date of birth above the address, you'll have to tweak the CV header created by moderncv, by redefining the command which prints the header. I would suggest creating a new command \dateofbirth, so you can still use \extrainfo for (well...) extra info. I try to describe the procedure rather generally, so you can also adapt it to other styles then the classic style.

If you look at the structure of the moderncv package, you'll find the package you load (moderncv.cls), as well as many other files. On line 317, you'll find the command definition for \moderncvstyle:

\newcommand*{\moderncvstyle}[2][]{
  \RequirePackage[#1]{moderncvstyle#2}}

This simply loads a package which is called moderncvstyle + the name of the style you are using, that is classic in your case. We'll thus continue with the file moderncvstyleclassic.sty. There, on line 45, the heading is defined as \moderncvhead[...]{1}. To find out what that means, we have to find the definition of \moderncvhead, which is on line 321, back in the file moderncv.cls:

\newcommand*{\moderncvhead}[2][]{
  \expandafter\RequirePackage\expandafter[\expandafter#1\expandafter]{\expandafter moderncvhead\romannumeral #2}}

This is also a \RequirePackage command, which converts the second argument of \moderncvhead to roman numbers. As the classic style calls \moderncvhead with the argument 1 (or in roman: i ), this will load the package moderncvheadi.sty. Now finally, there (lines 63-134) we find the definition of \makecvhead, which creates the heading. The task is now to tweak this command so that it prints the date of birth above the address.

In order to do that, you should copy the existing definition into your preamble and change it there. To add the date of birth, we simply create a new command

\newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}

and print the date of birth if \@dateofbirth exists (is defined):

\ifthenelse{\isundefined{\@dateofbirth}}{}{\makenewline\@dateofbirth}%

Everything put together into a small MWE yields

result

\documentclass{moderncv}
\moderncvstyle{classic}

\makeatletter
\newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}
\renewcommand*{\makecvhead}{%
  % recompute lengths (in case we are switching from letter to resume, or vice versa)
  \recomputecvlengths%
  % optional detailed information (pre-rendering)
  \@initializebox{\makecvheaddetailsbox}%
  \if@details%
    \def\phonesdetails{}%
    \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
      \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
    \def\socialsdetails{}%
    \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
      \protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
    \savebox{\makecvheaddetailsbox}{%
      \addressfont\color{color2}%
      \if@left\begin{tabular}[b]{@{}r@{}}\fi%
      \if@right\begin{tabular}[b]{@{}l@{}}\fi%
        \ifthenelse{\isundefined{\@dateofbirth}}{}{\makenewline\@dateofbirth}%
        \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}}%
        \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
      \end{tabular}
    }\fi%
  % optional photo (pre-rendering)
  \@initializebox{\makecvheadpicturebox}%
  \savebox{\makecvheadpicturebox}{%
    \ifthenelse{\isundefined{\@photo}}%
      {}%
      {%
        \if@left%
          \hspace*{\separatorcolumnwidth}\fi%
        \color{color1}%
        \setlength{\fboxrule}{\@photoframewidth}%
        \ifdim\@photoframewidth=0pt%
          \setlength{\fboxsep}{0pt}\fi%
        \framebox{\includegraphics[width=\@photowidth]{\@photo}}}%
        \if@right%
          \hspace*{\separatorcolumnwidth}\fi}%
  % name and title (pre-rendering)
  \@initializelength{\makecvheaddetailswidth}\settowidth{\makecvheaddetailswidth}{\usebox{\makecvheaddetailsbox}}%
  \@initializelength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
  \ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvheadnamewidth=0pt)
    {\setlength{\makecvheadnamewidth}{\textwidth-\makecvheaddetailswidth-\makecvheadpicturewidth}}%
    {}%
  \@initializebox{\makecvheadnamebox}%
  \savebox{\makecvheadnamebox}{%
    \begin{minipage}[b]{\makecvheadnamewidth}%
      \if@left\raggedright\fi%
      \if@right\raggedleft\fi%
      \namestyle{\@firstname\ \@lastname}%
      \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
    \end{minipage}}%
  % rendering
  \if@left%
    \usebox{\makecvheadnamebox}%
    \hfill%
    \llap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
    \usebox{\makecvheadpicturebox}\fi%
  \if@right%
    \usebox{\makecvheadpicturebox}%
    \rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
    \hfill%
    \usebox{\makecvheadnamebox}\fi%
  \\[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 \makecvhead
\makeatother

\firstname{Peter}
\familyname{Muster}
\dateofbirth{* 01 January 1900}
\address{1 Infinite Loop}{Cupertino, CA 95014}

\begin{document}
    \makecvtitle
\end{document}

Tags:

Moderncv