Problema com moderntimeline após personalizar \section em moderncv

Problema com moderntimeline após personalizar \section em moderncv

Personalizei o \sectioncomando moderncvpara obter um desbotamento da cor nos títulos das seções. Mas agora isso me bagunça moderntimelinee move as etiquetas dele. Eu já descobri que isso se deve ao \usetikzlibrary{positioning}. Alguém pode descobrir como usar meu personalizado \sectionsem afetar o 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 

exemplo

\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}

Responder1

Isso parece ser um bug no moderntimeline. Sugiro que você entre em contato com o autor do pacote sobre esse problema.

Consegui rastrear o problema até a definição de \tltextstart, especificamente, até a definição do tl@startyearestilo usado para compor o ano inicial; a definição original é

\newcommand{\tltextstart}[2][base west]{%
   \tikzset{
       tl@startyear/.style={
           font=#2,
           name=tl@startyear,
           above=\tl@textstartabove,
           inner xsep=0pt,
           anchor=#1,
       }
   }
}

e o problema é que \tl@textstartabovenão parece ser atualizado adequadamente ao usar o \tlcventry. Uma solução alternativa é usar

\tikzset{
     tl@startyear/.style={
         font=\scriptsize,
         name=tl@startyear,
         above=\tl@width+1pt,
         inner xsep=0pt,
         anchor=base west,
     }
}

Um exemplo 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}

O resultado:

insira a descrição da imagem aqui

informação relacionada