There seems to be a problem with the implementation (probably of \tldatelabelcventry
) in moderntimeline.sty
; the second entry in the following example is shifted to the left:
\documentclass{moderncv}
\moderncvstyle{casual}
\usepackage[firstyear=1999,lastyear=2012]{moderntimeline}
\firstname{John}
\familyname{Doe}
\begin{document}
\makecvtitle
\tldatelabelcventry{2008}{Okt. 2008}{Test}{}{}{}{}{}
\tlmaxdates{2008}{2012}
\tldatelabelcventry{2008}{Okt. 2008}{Test}{}{}{}{}{}
\tldatelabelcventry{2012}{Okt. 2012}{Test}{}{}{}{}{}
\end{document}
Using a proper bounding box in the definition solves the problem with the alignment (but the labels overlap with the following text):
\documentclass{moderncv}
\moderncvstyle{casual}
\usepackage[firstyear=1999,lastyear=2012]{moderntimeline}
\makeatletter
\renewcommand{\tldatelabelcventry}[8][color1]{%
\pgfmathsetmacro\tl@endyear{\tl@lastyear}%
\pgfmathsetmacro\tl@startfraction{(#2-\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 [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear] {#3}
node {$\bullet$};
}
}
{#4}{#5}{#6}{#7}{#8}
}
\makeatother
\firstname{John}
\familyname{Doe}
\begin{document}
\makecvtitle
\tldatelabelcventry{2008}{Okt. 2008}{Test}{}{}{}{}{}
\tlmaxdates{2008}{2012}
\tldatelabelcventry{2008}{Okt. 2008}{Test}{}{}{}{}{}
\tldatelabelcventry{2012}{Okt. 2012}{Test}{}{}{}{}{}
\end{document}
With the code in the original question, besides adding a proper bounding box, some work with the position of the labels will have to be done:
\documentclass{moderncv}
\moderncvstyle{casual}
\usepackage[firstyear=1999,lastyear=2012]{moderntimeline}
\makeatletter
\pgfmathsetmacro\tl@textstartabove{\tl@width-2pt}
\renewcommand{\tldatelabelcventry}[8][color1]{%
\pgfmathsetmacro\tl@endyear{\tl@lastyear}%
\pgfmathsetmacro\tl@startfraction{(#2-\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 [#1] (0,0)
++(\tl@startfraction*\hintscolumnwidth,0pt)
node [tl@startyear,yshift=5pt,anchor=east] {#3}
node {$\bullet$};
}
}
{#4}{#5}{#6}{#7}{#8}
}
\makeatother
%
\tltextstart[north]{\scriptsize}
\tltextend[south]{\scriptsize}
\firstname{John}
\familyname{Doe}
\begin{document}
\makecvtitle
\tlcventry[cyan!60!black]{2007}{2010}{test}{test}{test}{}{test}
\tllabelcventry[cyan!60!black]{2007}{2010}{Test}{test}{test}{test}{}{test}
\tlmaxdates{2008}{2012}
\tldatelabelcventry{2008}{Okt. 2008}{Test}{}{}{}{}{}
\tldatelabelcventry{2012}{Okt. 2012}{Test}{}{}{}{}{}
\tldatecventry[brown]{2011}{test}{}{test}{test}{}{test}
\end{document}
Finally, to get the desired alignment, one can produce a command similar to \tldatelabelcventry
but with another optional argument, allowing to specify the anchor for the label; this can be easily done with the help of the xparse
package:
\documentclass{moderncv}
\moderncvstyle{casual}
\usepackage{xparse}
\usepackage[firstyear=1999,lastyear=2012]{moderntimeline}
\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}
}
\makeatother
%
\tltextstart[north]{\scriptsize}
\tltextend[south]{\scriptsize}
\firstname{John}
\familyname{Doe}
\begin{document}
\makecvtitle
\tlcventry[cyan!60!black]{2007}{2010}{test}{test}{test}{}{test}
\tllabelcventry[cyan!60!black]{2007}{2010}{Test}{test}{test}{test}{}{test}
\tlmaxdates{2008}{2012}
\tldatelabelcventryn[west]{2008}{Okt. 2008}{Test}{}{}{}{}{}
\tldatelabelcventryn[center][red!70!black]{2010}{Okt. 2010}{Test}{}{}{}{}{}
\tldatelabelcventryn[east]{2012}{Okt. 2012}{Test}{}{}{}{}{}
\tldatecventry[brown]{2011}{test}{}{test}{test}{}{test}
\end{document}