Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer

up vote 8 down vote accepted

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

share|improve this answer
you've rescued my life, again... thx a lot – Megachip Nov 21 '12 at 0:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.