# How can I call a macro within \tldatelabelcventry

Edit2: Provided working intermediate MWE.

I am using moderncv with moderntimeline package.

I wanted to include a hack from https://tex.stackexchange.com/a/85981/6908 to display publications in the same format as the rest of the CV. This works nicely except that I want it work with the moderntimeline package.

However, I am unable to succeed. I think it has to do with an expansion problem.

This is the MWE.

\documentclass[11pt,a4paper,sans]{moderncv}
\usepackage[firstyear=1996,lastyear=2018]{moderntimeline}
\tlwidth{0.8ex}
\usepackage{xpatch}
\usepackage[url=false,backend=biber,
style=authoryear,
doi=false,
isbn=false,
backref=false,
sorting=ydnt]{biblatex}

%remove brackets from year
\xpatchbibmacro{date+extrayear}{%
\printtext[parens]}{\printtext}{}{}

% remove year from the author bibmacro
\xpatchbibmacro{author}{%
\usebibmacro{date+extrayear}}
{}{}{}

%change order and wrap into \cvline
\DeclareBibliographyDriver{article}{%
\cvline{\usebibmacro{date+extrayear}}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\usebibmacro{related}%
\usebibmacro{finentry}}%
}

% personal data
\name{Joe}{Smith}

\moderncvstyle{classic}
\moderncvcolor{blue}

\begin{document}

\nocite{bertram}
\printbibliography[title={Publications}]
\end{document}


Changing the \cvline to \tldatelabelcventry from the moderntimeline package as follows

\documentclass[11pt,a4paper,sans]{moderncv}
\usepackage[firstyear=1996,lastyear=2018]{moderntimeline}
\tlwidth{0.8ex}
\usepackage{xpatch}
\usepackage[url=false,backend=biber,
style=authoryear,
doi=false,
isbn=false,
backref=false,
sorting=ydnt]{biblatex}

%remove brackets from year
\xpatchbibmacro{date+extrayear}{%
\printtext[parens]}{\printtext}{}{}

% remove year from the author bibmacro
\xpatchbibmacro{author}{%
\usebibmacro{date+extrayear}}
{}{}{}

%change order and wrap into \cvline
\DeclareBibliographyDriver{article}{%
\tldatelabelcventry{
2006 % actual year from bibitem
}{
2006 % Label of year (should be the same)
}{
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
%\usebibmacro{author/translator+others}
%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\usebibmacro{related}%
\usebibmacro{finentry}}{}{}{}%
}

% personal data
\name{Joe}{Smith}

\moderncvstyle{classic}
\moderncvcolor{blue}

\begin{document}

\nocite{bertram}
\printbibliography
\end{document}


yields the following result

which is great except that the year is hardcoded.

What do I need to change to make it work with the actual year of the bibitem?

I tried using \usebibmacro{date+extrayear} with no succees.

• While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill May 23 '14 at 20:56
• Oh you're right... – Trefex May 23 '14 at 20:57
• You could try adding a \protect, but without a MWE I can't test it. – Peter Grill May 23 '14 at 20:57
• OK MWE added @PeterGrill – Trefex May 23 '14 at 21:10
• @StephanLehmke Thank you for the tip. I know provided a version that works with \tldatelabelcventry only the years are hardcoded. – Trefex May 25 '14 at 8:51

Looking at the packages biblatex and moderntimeline which are supposed to work together here, this seems to be a hopeless case at first glance.

All the biblatex user macros are as unexpandable as can be, while the pgfmath computations needed for the timeline seem to require expandability.

I'm getting seemingly acceptable results with the following approach:

%change order and wrap into \cvline
\DeclareBibliographyDriver{article}{%
\tldatelabelcventry{
\thefield{year}% actual year from bibitem
}{
\thefield{year}% Label of year (should be the same)
}{


which yields, with

\nocite{bertram}
\nocite{doody}
\nocite{shore}


the result

Observe that the bib entries

@article{doody,
author       = {Doody, Terrence},
title        = {Hemingway's Style and Jake's Narration},
year         = 1974,

@article{shore,
title        = {Twice-Born, Once Conceived},
journaltitle = {American Anthropologist},
date         = {1991-03},


already show a certain amount of variation with respect to the source of the "year" field, so this approach seems to offer some robustness.

Disclaimer: I know nothing at all about biber, biblatex or moderntimeline, so there might be hidden mantraps I don't recognize.

Update: As the last . is indeed hardcoded in \cventry, it needs to be removed by adding this patch after \moderncvstyle{classic}:

\moderncvstyle{classic}
\moderncvcolor{blue}

\xpatchcmd\cventry{.\strut}{\strut}{}{}


• This is beautiful. would you happen to know how to remove the last "dot" though? I think it comes automatically from tldatelabelcventry – Trefex May 25 '14 at 10:49
• @Trefex I didn't notice... Whoa, the . is indeed hardcoded in \cventry, so it must be removed with a patch. See edit. – Stephan Lehmke May 25 '14 at 11:22