One possible solution (notice the additional "n" at the end of the newly defined commands):
\documentclass[11pt,a4paper]{moderncv}
\moderncvtheme[green]{classic}
\usepackage[utf8]{inputenc}
\usepackage{floatflt}
\usepackage{fancyhdr}
\usepackage{geometry}
\geometry{a4paper,left=2cm,right=1cm, top=2cm, bottom=1.5cm,headheight=21pt}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{xparse}
\usepackage[firstyear=1996,lastyear=2013]{moderntimeline}
% for timeline
\makeatletter
\pgfmathsetmacro\tl@textstartabove{\tl@width-2pt}
\NewDocumentCommand\tldatelabelcventryn{O{center}O{color1}mmmmmmm}{%
\pgfmathsetmacro\tl@endyear{\tl@lastyear}%
\pgfmathsetmacro\tl@startfraction{(#3-\tl@firstyear)/(\tl@lastyear-\tl@firstyear)}%
\pgfmathsetmacro\tl@endfraction{(\tl@endyear-\tl@firstyear)/(\tl@lastyear-\tl@firstyear)}%
\cventry{\tikz[baseline]{%
\useasboundingbox (0,-1.5ex) rectangle (\hintscolumnwidth,1ex);
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidth,\tl@runningwidth);
\fill [#2] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear,yshift=5pt,anchor=#1] {#4}
node {$\bullet$};
}
}
{#5}{#6}{#7}{#8}{#9}
}
\newcommand\tllabelcventryn[9][color1]{%
\gdef\Argi{#1}%
\gdef\Argii{#2}%
\gdef\Argiii{#3}%
\gdef\Argiv{#4}%
\gdef\Argv{#5}%
\gdef\Argvi{#6}%
\gdef\Argvii{#7}%
\gdef\Argviii{#8}%
\gdef\Argix{#9}%
\auxtllabelcventryn
}
\def\auxtllabelcventryn#1{%
\gdef\Argx{#1}%
\pgfmathsetmacro\tl@endyear{ifthenelse(\Argiii==0,\tl@lastyear,\Argiii)}
\pgfmathsetmacro\tl@startfraction{(\Argii-\tl@firstyear)/(\tl@lastyear-\tl@firstyear)}%
\pgfmathsetmacro\tl@endfraction{(\tl@endyear-\tl@firstyear)/(\tl@lastyear-\tl@firstyear)}%
\cventry{\tikz[baseline=0pt]{
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidth,\tl@runningwidth);
\useasboundingbox (0,-1.5ex)
rectangle (\hintscolumnwidth,1ex);
\fill [\Argi] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear,anchor=north east] {\Argiv} node [tl@startyear,above] {\Argv}
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width-1pt);
\pgfmathsetlength{\pgf@xa}{\Argiii} \ifdim\pgf@xa=0pt
\shade [left color=\Argi] (\tl@startfraction*\hintscolumnwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\else
\fill [\Argi] (\tl@startfraction*\hintscolumnwidth,0)
rectangle (\tl@endfraction*\hintscolumnwidth,\tl@width);
\fi
}
}
{\Argvi}{\Argvii}{\Argviii}{\Argix}{\Argx}%
}
\makeatother
%
\tltextstart[north]{\scriptsize}
\tltextend[south]{\scriptsize}
%
\firstname{C}
\familyname{N}
\title{Curriculum vit\ae{}}
\address{}{}
\photo[128pt]{picture}
\begin{document}
\makecvtitle
born on .... in xxxxx
\section{school education}
\tlcventry[cyan!60!black]{2000}{2008}{test1}{test}{}{}{grade: 22}
\tlcventry[cyan!60!black]{1996}{2000}{test2}{}{}{}{test}
\section{studies}
\tllabelcventryn[cyan!60!black]{2011}{2013}{Oct 01, 2011}{today}{test3a}{}{}{}{test}
\tllabelcventry[cyan!60!black]{2011}{2013}{Oct 01, 2011--today}{test3b}{}{}{}{test}
\tldatelabelcventryn[east][cyan!60!black]{2011}{Apr 06, 2011}{Test4}{}{test}
{test}{}
\tllabelcventryn[cyan!60!black]{2009}{2011}{Dec 01,2009}{Jan 01,2011}{Test5}{}{}{}{test}
\end{document}
You could write something like that
\newif\ifnumericCVbibliography
\numericCVbibliographytrue % replace true with false to disable
\newlength{\hintscolumnwidthV}
\setlength\hintscolumnwidthV{\hintscolumnwidth}
\ifnumericCVbibliography
\usepackage[backend = biber,
style = nature,
sorting = none
]{biblatex}
\def\printbibnumber{\hspace*{1.5em}%
\llap{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
}%
}%
}
\addtolength\hintscolumnwidthV{-1.75em}
\else
\usepackage[backend = biber,
style = authoryear,
sorting = none
]{biblatex}
\def\printbibnumber\relax
\fi
and then use the \printnumber
macro before your \tldatecventryV
.
The \hspace{1.5em}
makes room for two-digit numbers.
Complete (working, I hope) example:
\documentclass[sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{orange}
\usepackage[scale=0.75]{geometry}
\usepackage{moderntimeline}
\tlmaxdates{1888}{1929}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Article{Jones1929,
author = {Jones, Grinnell and Dole, Malcolm},
title = {THE VISCOSITY OF AQUEOUS SOLUTIONS OF STRONG ELECTROLYTES},
journaltitle = {J. Am. Chem. Soc.},
date = {1929},
volume = {51},
number = {10},
pages = {2950--2964},
doi = {10.1021/ja01385a012}
}
@Article{Drude1894,
author = {Drude, P. and Nernst, W.},
title = {{\"U}ber Elektrostriktion durch freie Ionen},
journaltitle = {Z. Phys. Chem.},
date = {1894},
volume = {15},
pages = {79--85},
}
@Article{Hofmeister1888,
author = {Hofmeister, Franz},
title = {Zur Lehre von der Wirkung der Salze},
journaltitle = {Arch. Exp. Pathol. Pharmakol.},
date = {1888},
volume = {25},
number = {1},
pages = {1--30},
doi = {10.1007/BF01838161},
}
\end{filecontents*}
%-----------------------------------------------------------
\newif\ifnumericCVbibliography
\numericCVbibliographytrue % replace true with false to disable
\newlength{\hintscolumnwidthV}
\setlength\hintscolumnwidthV{\hintscolumnwidth}
\ifnumericCVbibliography
\usepackage[backend = biber,
style = nature,
sorting = none
]{biblatex}
\def\printbibnumber{\hspace*{1.5em}%
\llap{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
}%
}%
}
\addtolength\hintscolumnwidthV{-1.75em}
\else
\usepackage[backend = biber,
style = authoryear,
sorting = none
]{biblatex}
\def\printbibnumber\relax % do nothing
\fi
\addbibresource{\jobname.bib}
%-----------------------------------------------------------
\makeatletter
\newcommand*{\cventryV}[1][.25em]{}
% for numeric bibliography
\newcommand{\tldatecventryV}[2][color1]{%
\issincefalse
\tl@formatstartyear{#2}
\cventryV{\tikz[baseline=0pt]{
\useasboundingbox (2ex,0ex) rectangle (\hintscolumnwidthV,1ex);
\fill [\tl@runningcolor] (0,0)
rectangle (\hintscolumnwidthV,\tl@runningwidth);
\fill [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidthV,0pt)
node [tl@singleyear] {#2}
node {$\bullet$};
}}}
\makeatother
% 'numeric' bibliography environment (from numeric.bbx)
\defbibenvironment{bibliography}
{\list
{\printbibnumber % here you see the macro in action
\tldatecventryV{%
\thefield{year} % actual year from bibitem
}}
{\setlength{\topsep}{0pt}% layout parameters based on moderncvstyleclassic.sty
\setlength{\labelwidth}{\hintscolumnwidth}%
\setlength{\labelsep}{\separatorcolumnwidth}%
\setlength{\itemsep}{\bibitemsep}%
\leftmargin\labelwidth%
\addtolength{\leftmargin}{-.35\labelsep}% <-- changed
\advance\leftmargin\labelsep
}%
\sloppy\clubpenalty4000\widowpenalty4000}
{\endlist}
{\item}
%-----------------------
\AtEveryBibitem{\clearfield{year}}
%-------------------------------------------------------------------------------
% reverse numbering of publications
%-------------------------------------------------------------------------------
% Count total number of entries in each refsection
\AtDataInput{%
\csnumgdef{entrycount:\therefsection}{%
\csuse{entrycount:\therefsection}+1}}
% Print the labelnumber as the total number of entries in the
% current refsection, minus the actual labelnumber, plus one
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\newrobustcmd*{\mkbibdesc}[1]{%
\number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}
%------------------- Personal Data for CV header -------------------------------
\name{Joan}{Doe}
%-------------------------------------------------------------------------------
\begin{document}
\makecvtitle
\nocite{*}
\printbibliography[type=article,title={Journal Publications}]
\end{document}
Best Answer
You can use
xshift=(0.5-\tl@startfraction)*\hintscolumnwidth
to shift the label to the centre of the timeline. The label uses thetl@startyear
style, so you can use that to set thexshift
option.