Personalicé el \section
comando moderncv
para obtener un desvanecimiento de color en los títulos de las secciones. Pero ahora esto me arruina moderntimeline
y mueve las etiquetas. Ya descubrí que esto se debe a \usetikzlibrary{positioning}
. ¿Alguien puede descubrir cómo usar mi personalizado \section
sin afectar el moderntimeline
?
\documentclass{moderncv}
\usepackage[firstyear=2007,lastyear=2015]{moderntimeline}
\usepackage{tikz}
\usetikzlibrary{fadings,patterns,positioning,fit,calc}
\tikzset{
zero sep/.style = {inner sep=0pt, outer sep=0pt},
}
\moderncvstyle{classic}
\makeatletter
\renewcommand\section[1]{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#1}%
\pgfmathsetmacro\randref{rand}
\begin{tikzfadingfrompicture}[name=tikzsection \randref]
\node[fill=white,anchor=south east,zero sep,minimum width=5cm,minimum height=2.5mm] (box node){};
\node [text=white,anchor=base west,text depth=5pt,text height=12pt,zero sep,
font=\normalfont\Large\bfseries,right=10pt of box node,
text width=12cm,align=left] (text node) {\strut#1\strut};
\node [fit={(box node)(text node)
},zero sep] (myfit) {};
\path let \p1=(myfit.south west), \p2=(myfit.north east), \n1={\x2-\x1}, \n2={\y2-\y1} in
\pgfextra{\xdef\lenx{\n1} \xdef\leny{\n2}};
\end{tikzfadingfrompicture}
\begin{tikzpicture}[baseline=.5*5pt-.5*12pt]
\path[path fading=tikzsection \randref, fit fading=false,left color=blue, right color=black]
(-.5*\lenx,-.5*\leny) rectangle ++(\lenx,\leny);
\end{tikzpicture}%
\par\nobreak\addvspace{1ex}\@afterheading%
}
\makeatother
\begin{document}
\section{First section}
\tlcventry{2008}{2009}{Student in aerospace engineering}{University of Atlantis}{Atlantis}{}{Majors: Aqua Systems, Fluid Mechanics}
\section{Second muuuuch longer section}
Some text
\section{Short}
Some text
\end{document}
Respuesta1
Esto parece ser un error en moderntimeline
. Le sugiero que se comunique con el autor del paquete sobre este problema.
Pude localizar el problema en la definición de \tltextstart
, específicamente, en la definición del tl@startyear
estilo utilizado para componer el año de inicio; la definición original es
\newcommand{\tltextstart}[2][base west]{%
\tikzset{
tl@startyear/.style={
font=#2,
name=tl@startyear,
above=\tl@textstartabove,
inner xsep=0pt,
anchor=#1,
}
}
}
y el problema es que \tl@textstartabove
no parece actualizarse adecuadamente cuando se usa \tlcventry
. Una solución alternativa es utilizar
\tikzset{
tl@startyear/.style={
font=\scriptsize,
name=tl@startyear,
above=\tl@width+1pt,
inner xsep=0pt,
anchor=base west,
}
}
Un ejemplo completo:
\documentclass{moderncv}
\usepackage[firstyear=2007,lastyear=2015]{moderntimeline}
\usepackage{tikz}
\usetikzlibrary{fadings,patterns,positioning,fit,calc}
\tikzset{
zero sep/.style = {inner sep=0pt, outer sep=0pt},
}
\moderncvstyle{classic}
\makeatletter
\tikzset{
tl@startyear/.style={
font=\scriptsize,
name=tl@startyear,
above=\tl@width+1pt,
inner xsep=0pt,
anchor=base west,
}
}
\renewcommand\section[1]{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#1}%
\pgfmathsetmacro\randref{rand}
\begin{tikzfadingfrompicture}[name=tikzsection \randref]
\node[fill=white,anchor=south east,zero sep,minimum width=5cm,minimum height=2.5mm] (box node){};
\node [text=white,anchor=base west,text depth=5pt,text height=12pt,zero sep,
font=\normalfont\Large\bfseries,right=10pt of box node,
text width=12cm,align=left] (text node) {\strut#1\strut};
\node [fit={(box node)(text node)
},zero sep] (myfit) {};
\path let \p1=(myfit.south west), \p2=(myfit.north east), \n1={\x2-\x1}, \n2={\y2-\y1} in
\pgfextra{\xdef\lenx{\n1} \xdef\leny{\n2}};
\end{tikzfadingfrompicture}
\begin{tikzpicture}[baseline=.5*5pt-.5*12pt]
\path[path fading=tikzsection \randref, fit fading=false,left color=blue, right color=black]
(-.5*\lenx,-.5*\leny) rectangle ++(\lenx,\leny);
\end{tikzpicture}%
\par\nobreak\addvspace{1ex}\@afterheading%
}
\makeatother
\firstname{John}
\lastname{Doe}
\begin{document}
\section{First section}
\tlcventry{2008}{2009}{Student in aerospace engineering}{University of Atlantis}{Atlantis}{}{Majors: Aqua Systems, Fluid Mechanics}
\section{Second much longer section}
Some text
\section{Short}
Some text
\end{document}
El resultado: