13

Again some problems with moderntimeline:


\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]{ \fill [\tl@runningcolor] (0,0) rectangle (\hintscolumnwidth,\tl@runningwidth); \fill [#1] (0,0) ++(\tl@startfraction*\hintscolumnwidth,0pt) node [tl@startyear,yshift=11pt] {#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}

Produce:
enter image description here
Would be nice to have:
enter image description here

Problem also exists with original moderntimeline in a similar way: enter image description here

16

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}

enter image description here

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}

enter image description here

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}

enter image description here

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}

enter image description here

  • 1
    you've rescued my life, again... thx a lot – Megachip Nov 21 '12 at 0:23
  • @Gonzalo Medina This solution is pretty sweet. thanks also from me. but to get this perfect, there are still one thing annoying me: in your last example, the blue '2010' seems to be further away from the blue bar than the blue '2007' is. can the '2010' be moved toward the bar, so that the '2007' and the '2010' are equidistant to the blue bar ? – Fry Oct 10 '13 at 8:45
3

quick workaround to implement is to set before and after each entry the anchor of the labels

%set the anchor as you prefer
\tltextstart[south east]{\scriptsize}
\tltextend[north west]{\scriptsize} 
%--------

\tldatelabelcventry{2008}{Okt. 2008}{Test}{}{}{}{}{}

%------
%set it back as default
\tltextstart[south]{\scriptsize}
\tltextend[north]{\scriptsize}

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.