我想对齐时间轴栏和时间轴矩形,使线条穿过矩形的垂直中心,而不是完全位于上方或下方。以下是我迄今为止尝试过的方法。
\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}
我设法在底部创建了另一个矩形,但是,它增加了栏的高度,这是不希望的。
我不明白代码的哪部分负责绘制矩形以及如何设置其位置和大小。
答案1
我想这就是你想要实现的:
\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}