6

I'm doing my cv with the moderncv package and I'm using the classic style. I would like to add a date of birth line directly above the adress. Does anyone know how to do this? I've tried various solutions but they all seem to be broken.

  • Welcome to TeX.SE . Did you have any MWE? – Romain Picot Sep 15 '15 at 8:00
  • 1
    How about \extrainfo{* 01 January 1900}? – hbaderts Sep 15 '15 at 8:16
  • 1
    The problem \extrainfo is that it adds it at the bottom of my personal information instead of the top. – user112110 Sep 15 '15 at 9:01
5

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}
  • I have tried this solution by following the step in order to get the latest version of the package (I think it didn't change), but I can't seem to add \dateofbirth{xx} to the other lines in the header. – thymaro Sep 19 '18 at 22:26
  • Hi thymaro. Does copy&pasting the example from the bottom of the answer into your LaTeX editor work? Maybe it would be the easiest if you create a new question where you can include a MWE (minimum working example) of what you tried and what doesn't work. Then we have a more space and possibilities than here in the comments. If you do, please add a comment here with a link to the question, so I don't miss it. – hbaderts Sep 20 '18 at 4:15
  • Right, sorry, I should have mentioned that that's exactly my intention: new question, link to it here. Only problem is I don't have the mwe ready, yet, and had other priorities. I'll link to it here, when the question is up. – thymaro Sep 20 '18 at 4:38
  • 1
    Hm, interesting. Does your document still compile (but birthdate is missing) or does it throw some error? Can you try putting the makeatletter--makeatother block right before \begin{document} to make sure it is not changed by some other package? – hbaderts Sep 20 '18 at 5:30
  • 1
    Oh you're right of course. Thank you for the link, I added an answer with an explanation why this happens. Hope this explains why this has happened. – hbaderts Sep 20 '18 at 14:18
0

Because I struggled a lot with putting the birth of date and the family status in all five pre-existing styles (casual, classic, banking, oldstyle and fancy) and making them work out of the box without being bothered too much with defining anything else, I wanted to post the MWE for this here in case someone else wants to use these variables in other styles than only the classic one:

WE (to call it minimal would be a bit off...) with only the only need to change the style-information:

    \documentclass[12pt]{moderncv}

    % These commands have to come BEFORE you choose the style!
    \usepackage{xpatch}
    \makeatletter
    \providecommand{\@moderncvstyle}{}
    \providecommand{\@moderncvstyleoptions}{}
    \xapptocmd{\moderncvstyle}{%
        \renewcommand{\@moderncvstyleoptions}{#1}{}{}
        \renewcommand{\@moderncvstyle}{#2}{}{}
    }
    \makeatother

    % Choose one of the 5 styles here (casual, classic, banking, oldstyle or fancy):
    \moderncvstyle{fancy}


    \makeatletter
    % new commands to enter the birth of date and the family status:
    \newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}
    \newcommand*{\family}[1]{\def\@family{#1}}

    % 5 ifthenelse statements to test for the 5 styles and change the header accordingly:

    \ifthenelse{\equal{\@moderncvstyle}{casual}}{
        \renewcommand*{\makecvhead}{% TODO: use \@initializecommand,         which requires modifying its definition to handle \par
    % recompute lengths (in case we are switching from letter to resume, or vice versa)
    \recomputecvlengths%
    % optional picture (pre-rendering)
    \@initializebox{\makecvheadpicturebox}%
    \savebox{\makecvheadpicturebox}{%
        \ifthenelse{\isundefined{\@photo}}%
        {}%
        {%
            \setlength\fboxrule{\@photoframewidth}%
            \ifdim\@photoframewidth=0pt%
            \setlength{\fboxsep}{0pt}\fi%
            {\color{color1}\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}}%
    % name (pre-rendering)
    \@initializelength{\makecvheadpicturewidth}%
    \settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
    \@initializebox{\makecvheadnamebox}%
    \savebox{\makecvheadnamebox}{%
        \parbox[b]{\textwidth-\makecvheadpicturewidth}{%
            \if@left\raggedright\fi%
            \if@right\raggedleft\fi%
            \namefont%
            \if@alternate% alternate design: first- and lastname in lowercase with no space in between (distinction is made by color difference)
            {\color{color2!50}\MakeLowercase\@firstname}{\color{color2}\MakeLowercase\@lastname}%
            \else% default design: first- and lastname as given with a space in between
            {\color{color2!50}\@firstname} {\color{color2}\@lastname}\fi}}%
    % rendering
    \if@left%
    \usebox{\makecvheadnamebox}%
    \usebox{\makecvheadpicturebox}\fi
    \if@right%
    \usebox{\makecvheadpicturebox}%
    \usebox{\makecvheadnamebox}\fi\\[-.35em]%
    {\color{color2!50}\rule{\textwidth}{.25ex}}%
    % optional detailed information
    \if@details{%
        \\\null%
        \addressfont\color{color2}%
        \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
            \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
            \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
            \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
            \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
        \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
            \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
        \flushmakeheaddetails}\fi% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
    % optional title
    \ifthenelse{\equal{\@title}{}}{}{%
        \\[1.25em]\null% \null is required as there is no box on the line after \\, so glue such as \hfill (and leaders) disappear; this is in contrast to after \par, where the next line starts with an indent box (even after \noindent)
        \if@right\hfill\fi%
        \if@alternate%
        \titlestyle{\MakeLowercase\@title}%
        \else%
        \titlestyle{\@title}\fi%
    }%
    % optional birthofdate and family:
    \ifthenelse{\not\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
        {\null\hfill%
            \begin{flushright}
                \textsl{\@dateofbirth\\
                    \@family
                }
            \end{flushright}\hfill\null
    }}{}
    % optional no birthofdate and no family needs no ifthenelse
    % optional birthofdate but no family:
    \ifthenelse{\not\isundefined{\@dateofbirth} \and \isundefined{\@family}}{
        {\null\hfill%
            \begin{flushright}
                \textsl{\@dateofbirth}
            \end{flushright}\hfill\null
    }}{}
    % optional family but no birthofdate:
    \ifthenelse{\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
        {\null\hfill%
            \begin{flushright}
                \textsl{\@family}
            \end{flushright}\hfill\null
    }}{}\\[2em]%
    % optional quote
    \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\null\hfill%
            \begin{minipage}{\quotewidth}%
                \centering%
                \quotestyle{\@quote}%
            \end{minipage}\hfill\null\\[2em]
        }
    }%
    \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle
    }{}
    \ifthenelse{\equal{\@moderncvstyle}{classic}}{
        \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{\@family}}{}{\makenewline\@family}%
                \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
}{}
\ifthenelse{\equal{\@moderncvstyle}{banking}}{
    \@initializecommand{\makehead}{%
        \setlength{\makeheaddetailswidth}{0.8\textwidth}%
        \hfil%
        \parbox{\makeheaddetailswidth}{%
            \centering%
            % name and title
            \namestyle{\@firstname~\@lastname}%
            \ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title) 
            % optional birthofdate and family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \textsl{\@dateofbirth~~\textbullet~~\@family}\hfill\null\\[1.5em]
            }}{}
            % optional no birthofdate and no family needs no ifthenelse
            % optional birthofdate but no family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \isundefined{\@family}}{
                {\null\hfill%
                    \textsl{\@dateofbirth}\hfill\null\\[1.5em]
            }}{}
            % optional family but no birthofdate:
            \ifthenelse{\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \textsl{\@family}\hfill\null\\[1.5em]
            }}{}
            % optional detailed information
            \if@details{%
                \addressfont\color{color2}%
                \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
                    \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
                    \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
                    \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}%
                \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                    \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
                \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
                \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
                \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
                    \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
                \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
                \flushmakeheaddetails}\fi}\\[2.5em]}% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
}{}
\ifthenelse{\equal{\@moderncvstyle}{oldstyle}}{
    \renewcommand*{\makecvhead}{
        % recompute lengths (in case we are switching from letter to resume, or vice versa)
        \recomputecvlengths%
        % optional picture box
        \newbox{\makecvheadpicturebox}%
        \savebox{\makecvheadpicturebox}{%
            \ifthenelse{\isundefined{\@photo}}%
            {}%
            {%
                \color{color1}%
                \setlength\fboxrule{\@photoframewidth}%
                \ifdim\@photoframewidth=0pt%
                \setlength{\fboxsep}{0pt}\fi%
                \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
        % name and optional title
        \newlength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
        \newlength{\makecvheadnamewidth}\setlength{\makecvheadnamewidth}{\textwidth-\makecvheadpicturewidth}%
        \begin{minipage}[b]{\makecvheadnamewidth}%
            \namestyle{\@firstname\ \@lastname}%
            \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
            % optional birthofdate and family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \begin{flushleft}
                        \textsl{\@dateofbirth\\
                            \@family
                        }
                    \end{flushleft}\hfill\null
            }}{}
            % optional no birthofdate and no family needs no ifthenelse
            % optional birthofdate but no family:
            \ifthenelse{\not\isundefined{\@dateofbirth} \and \isundefined{\@family}}{
                {\null\hfill%
                    \begin{flushleft}
                        \textsl{\@dateofbirth}
                    \end{flushleft}\hfill\null
            }}{}
            % optional family but no birthofdate:
            \ifthenelse{\isundefined{\@dateofbirth} \and \not\isundefined{\@family}}{
                {\null\hfill%
                    \begin{flushleft}
                        \textsl{\@family}
                    \end{flushleft}\hfill\null
            }}{}
        \end{minipage}%
        % optional photo
        \usebox{\makecvheadpicturebox}\\[2.5em]%
        % optional quote
        \ifthenelse{\isundefined{\@quote}}%
        {}%
        {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
        % optional details
        \if@details%
        \makecvheadinfo{%
            \addressfont\color{color2}%
            \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}}%
            \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                \makenewline\hbox to 1.0em{\csname\collectionloopkey phonesymbol\endcsname}~\collectionloopitem}%
            \ifthenelse{\isundefined{\@email}}{}{\makenewline\hbox to 1.0em{\emailsymbol}~\emaillink{\@email}}%
            \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\hbox to 1.0em{\homepagesymbol}~\httplink{\@homepage}}%
            \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
                \makenewline\hbox to 1.0em{\csname\collectionloopkey socialsymbol\endcsname}~\collectionloopitem}%
            \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi}
}{}
\ifthenelse{\equal{\@moderncvstyle}{fancy}}{
    \renewcommand*{\makecvhead}{%
        % recompute lengths (in case we are switching from letter to resume, or vice versa)
        \recomputecvlengths%
        % optional photo (pre-rendering)
        \@initializebox{\makecvheadpicturebox}%
        \savebox{\makecvheadpicturebox}{%
            \ifthenelse{\isundefined{\@photo}}%
            {}%
            {%
                \color{color1}%
                \setlength{\fboxrule}{\@photoframewidth}%
                \ifdim\@photoframewidth=0pt%
                \setlength{\fboxsep}{0pt}\fi%
                \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
        % rendering
        \@makecvtitle%
        {%
            \raggedleft%
            % optional photo
            \usebox{\makecvheadpicturebox}%
            % optional details
            \if@details%
            \ifthenelse{\isundefined{\@photo}}{}{\\[0.5em]}%
            \addressfont\color{color2}%
            \ifthenelse{\isundefined{\@dateofbirth}}{}{\makenewline\@dateofbirth}%
            \ifthenelse{\isundefined{\@family}}{}{\makenewline\@family}%
            \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}}%
            \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
                \makenewline\csname\collectionloopkey phonesymbol\endcsname~\collectionloopitem}%
            \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol~\emaillink{\@email}}%
            \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol~\httplink{\@homepage}}%
            \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
                \makenewline\csname\collectionloopkey                socialsymbol\endcsname~\collectionloopitem}%
            \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline        \@extrainfo}\fi}%
                {%
                    % name and optional title
                    \newlength{\makecvheadpictureboxskip}%
            \setlength{\makecvheadpictureboxskip}        {\totalheightof{\usebox{\makecvheadpicturebox}}}%
                    \namestyle{\@firstname\ \@lastname}%
            \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]        \titlestyle{\@title}}\\[2.5em]%
                    % optional quote
                    \ifthenelse{\isundefined{\@quote}}%
                    {}%
            {\begin{minipage}{\quotewidth}\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

    \name{John}{Doe}
    \dateofbirth{01.01.1970}
    \family{married}
    \address{111 Mimimi}{Here}{Somewhere}
    \phone[mobile] {+01~(0)123 456789}
    \email{John.Doe@mail.com} 
    \title{CV}
    \begin{document}

    \makecvtitle

    \end{document}

It is rather lengthy, I know, but it should work... Ihad problems with a \ifnum0=\pdfstrcmp{}{} structure so I used \ifthenelse and this example now works fine for me.

Hope this helps!

P.S. This was only possible with the help of @christian-hupfer who provided this answer to my question how to catch the style info for use in conditionals:

https://tex.stackexchange.com/a/376757/136789

0

Another way to get the date of birth going without having to fix/patch the template is to make 'creative' use of the address command like this:

\address{\mbox{\hspace*{-2cm}\textsuperscript{\textborn}01.~April~1900,~Berlin}\makenewline Somestreet 123}{12345 Somewhere}{InACountry}

This will add your date of birth and a linebreak before your address. Caution: This is a really bad idea if you want to reuse your postal address in other parts of your CV (footer, header, return address etc). But if you dont it's an easy fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.