2

In the question Moderncv adding date of birth to personal information, a solution is given to produce a field where one can input one's birthday and make it appear in the CV title minipage head. After following the steps described in the accepted answer, I couldn't make it work for me. Here is the MWE:

%% start of modified file `template.tex'.
%% Copyright 2006-2015 Xavier Danaux (xdanaux@gmail.com).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.

\documentclass[11pt,a4paper,sans]{moderncv}

\usepackage{duckuments}

% source: https://tex.stackexchange.com/questions/267604
\makeatletter
\newcommand*{\dateofbirth}[1]{\def\@dateofbirth{#1}}
\newcommand*{\dateofbirthfont}{}
\newcommand*{\dateofbirthstyle}[1]{{\dateofbirthfont#1}}
\renewcommand*{\makecvhead}{%
    \recomputecvlengths%
    \@initializebox{\makecvheaddetailsbox}%
    \if@details%
    \def\phonesdetails{}%
    \collectionloop{phones}{%
        \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
    \def\socialsdetails{}%
    \collectionloop{socials}{%
        \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}%
                \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
            \phonesdetails% 
            \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
            \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
            \socialsdetails%
            \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
        \end{tabular}
    }\fi%
    \@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}}%
    {\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}}%
    \usebox{\makecvheadpicturebox}\fi%
    \if@right%
    \usebox{\makecvheadpicturebox}%
    \rlap{\usebox{\makecvheaddetailsbox}}%
    \hfill%
    \usebox{\makecvheadnamebox}\fi%
    \\[2.5em]%
    % optional quote
    \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
    \par}%
\makeatother

\moderncvstyle{classic}
\moderncvcolor{burgundy}

\usepackage[scale=0.82,bottom=20mm]{geometry}
\setlength{\hintscolumnwidth}{35mm} 

\name{Megenn}{Marggel}
\title{Da Duchess Life is da best}
\address{Deal 24}{2007 Nodeal}{}
\phone[mobile]{+55~(555)~555~55~55}
\email{mema@palace.me}
\homepage{www.mema.com}
\social[linkedin]{mema}
\social[github]{mema}
\extrainfo{I like fruit}
\dateofbirth{4 August 1981}
\photo[64pt][0.4pt]{picture}
\quote{noli simul flare sobereque}

\begin{document}

    \makecvtitle

\end{document}
2

The problem here is the ordering of different commands: First, the custom header which includes the date-of-birth field is defined. Right after that, the moderncv style and color scheme are set:

\makeatletter
    % Definition of custom header
\makeatother

\moderncvstyle{classic}
\moderncvcolor{burgundy}

The command \moderncvstyle{classic} re-defines the header to match the "classic" style of moderncv. Thus, your custom definition is overwritten by the classic style, and the date of birth is not printed.

The solution is to switch the place of those two blocks, i.e.

\moderncvstyle{classic}
\moderncvcolor{burgundy}

\makeatletter
    % Definition of custom header
\makeatother

That way, the header is first defined to be the "classic" header of moderncv, and only after that, you re-define it to include the date of birth.

This site is temporarily in read only mode and not accepting new answers.

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