0

I want to align the timeline bar and the timeline rectangle such that the line passes through the vertical centre of the rectangle and not fully above or below. Below is what I have tried so far.

\documentclass[11pt, a4paper, sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
%=========================================
%--------- Packages Used ------------------
\usepackage[utf8]{inputenc}
\usepackage[scale=0.8]{geometry}
\usepackage{pdfpages}
\usepackage{moderntimeline/moderntimeline}
\usepackage{moderntimeline}

\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=-4pt]{
     \fill [\tl@runningcolor] (0,0)
        rectangle (\hintscolumnwidth,\tl@runningwidth);
     \useasboundingbox (0,0ex)
        rectangle (\hintscolumnwidth,0ex);
     \fill [\Argi] (0,-0.05)
        ++(\tl@startfraction*\hintscolumnwidth,-0.05 pt)
        node [tl@startyear] {\Argiv} 
        node [tl@endyear] {\Argv}
        rectangle (\tl@endfraction*\hintscolumnwidth,-0.05 pt);
     \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}%
}

\begin{document}

\makecvtitle
\bigskip
\section{Educational Background}
\bigskip
\tllabelcventryn{2012}{2014}{Jan, 2012}{June, 2014}{PhD Extragalactic Astrophysics}{Institute of Astronomy, Geophysics, and Atmospheric Sciences - University of São Palo \emph{(hereafter IAG-USP)}}{}{São Paulo, Brazil}{}

\end{document}

I managed to create another rectangle at the bottom, however, it increased the height of the bar, which is not desired.

I don't understand which part of the code is responsible for drawing the rectangle and how to set its position and size.

1 Answer 1

1

I guess this is what you want to achieve:

\documentclass[11pt, a4paper, sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
%=========================================
%--------- Packages Used ------------------
\usepackage[utf8]{inputenc}
\usepackage[scale=0.8]{geometry}
\usepackage{pdfpages}
\usepackage[firstyear=2010,lastyear=2016]{moderntimeline}
\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
}

\makeatletter
\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]{
     \fill [\tl@runningcolor] (0,0)
        rectangle (\hintscolumnwidth,\tl@runningwidth);
     \useasboundingbox (0,0ex)
        rectangle (\hintscolumnwidth,0ex);
     \fill [\Argi] (0,0) 
        ++(\tl@startfraction*\hintscolumnwidth,-1pt)
        node [tl@startyear] {\Argiv}
        rectangle (\tl@endfraction*\hintscolumnwidth,0) ;
     \pgfmathsetlength{\pgf@xa}{\Argiii} \ifdim\pgf@xa=0pt
        \shade [left color=\Argi] (\tl@startfraction*\hintscolumnwidth,-0.5*\tl@width)
            rectangle (\tl@endfraction*\hintscolumnwidth,0.5*\tl@width);
     \else
        \fill [\Argi] (\tl@startfraction*\hintscolumnwidth,-0.5*\tl@width)
            rectangle (\tl@endfraction*\hintscolumnwidth,0.5*\tl@width) node [yshift=-1pt,tl@endyear] {\Argv};
     \fi
     }
}
{\Argvi}{\Argvii}{\Argviii}{\Argix}{\Argx}%
}
\makeatother
\firstname{John}
\lastname{Smith}
\sethintscolumnlength{5cm}

\begin{document}
\makecvtitle
\section{Educational Background}
\bigskip\tllabelcventryn{2012}{2014}{Jan, 2012}{June, 2014}{PhD Extragalactic Astrophysics}{Institute of Astronomy, Geophysics, and Atmospheric Sciences - University of São Palo \emph{(hereafter IAG-USP)}}{}{São Paulo, Brazil}{}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .