forked from moderncv/moderncv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoderncvverticaltimeline.sty
79 lines (65 loc) · 2.94 KB
/
moderncvverticaltimeline.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%% start of file `moderncvverticaltimeline.sty'.
%% Copyright 2023 Javier Lopez-Gomez (javier.lopez.gomez@proton.me).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
%-------------------------------------------------------------------------------
% identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvverticaltimeline}[2023/11/29 v2.0.0 modern curriculum vitae vertical timeline]
%-------------------------------------------------------------------------------
% required packages
%-------------------------------------------------------------------------------
\RequirePackage{tikz}
%-------------------------------------------------------------------------------
% vertical timeline implementation
%-------------------------------------------------------------------------------
\tikzset{
tl_milestone/.style={circle,inner sep=1.5pt,draw=color0!20,label={west:#1}},
tl_link/.style={thick,densely dotted,color0!20},
}
\newcounter{tl@chainidx}\setcounter{tl@chainidx}{0}
\newcounter{tl@nodeidx}\setcounter{tl@nodeidx}{0}
% Mark the end of the current chain; any `\tl@milestone` issued afterward will be on a new timeline.
\def\tl@resetchain{%
\stepcounter{tl@chainidx}%
\setcounter{tl@nodeidx}{0}%
}
% Create a node in the current timeline and link it to the previous node; if the previous milestone
% is on the last shipped out page, draw a line that extends until the top margin. The argument is laid out as a label (default left).
\def\tl@milestone#1{%
\edef\@tl@prev{tl-\thetl@chainidx-\thetl@nodeidx}%
\stepcounter{tl@nodeidx}%
\edef\@tl@this{tl-\thetl@chainidx-\thetl@nodeidx}%
\tikz[remember picture,overlay] {
\node[tl_milestone={#1}] (\@tl@this) {};
\ifnum\thetl@nodeidx>1
\pgfpointdiff{\pgfpointanchor{\@tl@prev}{center}}{\pgfpointanchor{\@tl@this}{center}}
\ifnum\pgf@y>0
\draw[tl_link] (\@tl@this) -- ([yshift=-1em] \@tl@this |- current page.north);
\else
\draw[tl_link] (\@tl@this) -- (\@tl@prev);
\fi
\fi
}
}
\AddToHook{shipout/background}{%
% If there are follow-up milestones in the current timeline, draw a line that extends until the bottom margin
\edef\@tl@prev{tl-\thetl@chainidx-\number\numexpr\thetl@nodeidx-1}%
\edef\@tl@this{tl-\thetl@chainidx-\thetl@nodeidx}%
\tikz[remember picture,overlay] {
\ifnum\thetl@nodeidx>1
\pgfpointdiff{\pgfpointanchor{\@tl@prev}{center}}{\pgfpointanchor{\@tl@this}{center}}
\ifnum\pgf@y>0
\draw[tl_link] (\@tl@prev) -- ([yshift=1em] \@tl@prev |- current page.south);
\fi
\fi
}
}
\AtEndDocument{\tl@resetchain}
\let\@old@section=\section%
\RenewDocumentCommand{\section}{sm}{\tl@resetchain\@old@section{#1}}
\endinput
%% end of file `moderncvverticaltimeline.sty'.