-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchronology.sty
More file actions
132 lines (132 loc) · 4.5 KB
/
Copy pathchronology.sty
File metadata and controls
132 lines (132 loc) · 4.5 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{chronology}[2023/08/20 v2.0 - Horizontal Timeline]%
\RequirePackage{calc}%
\RequirePackage{tikz}%
\RequirePackage{xparse}%
% Defining counters and lengths
\newcounter{step}\newcounter{stepstart}\newcounter{stepstop}%
\newcounter{yearstart}\newcounter{yearstop}\newcounter{deltayears}%
\newlength{\xstart}\newlength{\xstop}%
\newlength{\unit}\newlength{\timelinewidth}%
\newsavebox{\timelinebox}%
%
% Defining TikZ styles for labels and events
%
\tikzset{%
,chronevent/.style={fill=black,draw=none,opacity=0.5}
,chronlabel/.style={opacity=1}
,chrontickslabel/.style={chronlabel}
,chroneventlabel/.style={chronlabel}
,eventlabel/.style={chroneventlabel,anchor=south west,yshift=.2\unit,rotate=45}
,flippedeventlabel/.style={chroneventlabel,anchor=north west,yshift=-.2\unit,rotate=-45}
,eventlabelbottom/.style={chroneventlabel,anchor=south west,yshift=-0cm,rotate=0} % Bottom label
}
%
% For compatibity with babel. Handling of active characters in TikZ.
%
\tikzset{
handle active characters in code,
handle active characters in nodes
}
\makeatletter%
\newif\ifchronology@star%
\newenvironment{chronology}{%
\@ifstar{\chronology@startrue\chronology@i*}{\chronology@starfalse\chronology@i*}%
}{%
\end{tikzpicture}%
\end{lrbox}%
\raisebox{2ex}{\resizebox{\timelinewidth}{!}{\usebox{\timelinebox}}}%
}%
\def\chronology@i*{%
\@ifnextchar[{\chronology@ii*}{\chronology@ii*[{5}]}%
}%
\def\chronology@ii*[#1]#2#3#4{%
\@ifnextchar[{\chronology@iii*[{#1}]{#2}{#3}{#4}}{\chronology@iii*[{#1}]{#2}{#3}{#4}[{#4}]}%
}%
\def\chronology@iii*[#1]#2#3#4[#5]{%
\newif\ifflipped%
\ifchronology@star%
\flippedtrue%
\else%
\flippedfalse%
\fi%
\setcounter{step}{#1}%
\setcounter{yearstart}{#2}\setcounter{yearstop}{#3}%
\setcounter{deltayears}{\theyearstop-\theyearstart}%
\setlength{\unit}{#5/\thedeltayears}%
\setlength{\timelinewidth}{#4}%
\pgfmathsetcounter{stepstart}{\theyearstart+\thestep-mod(\theyearstart,\thestep)}%
\pgfmathsetcounter{stepstop}{\theyearstop-mod(\theyearstop,\thestep)}%
\addtocounter{step}{\thestepstart}%
\begin{lrbox}{\timelinebox}%
\begin{tikzpicture}[baseline={(current bounding box.north)}]%
\draw [|->] (0,0) -- (\thedeltayears*\unit+\unit, 0);%
\foreach \x in {1,...,\thedeltayears}%
\draw[xshift=\x*\unit] (0,-.1\unit) -- (0,.1\unit);%
\addtocounter{deltayears}{1}%
\foreach \x in {\thestepstart,\thestep,...,\thestepstop}{%
\pgfmathsetlength\xstop{(\x-\theyearstart)*\unit}%
\draw[xshift=\xstop] (0,-.3\unit) -- (0,.3\unit);%
\ifflipped%
\node[chrontickslabel] at (\xstop,0) [above=.2\unit] {\x};%
\else%
\node[chrontickslabel] at (\xstop,0) [below=.2\unit] {\x};%
\fi%
}%
}%
%
% Event (legacy code for compatibility)
%
\makeatother%
\DeclareDocumentCommand \event {o m m}{% [Startdate] Enddate Label
\pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
\IfNoValueTF {#1} {%
\ifflipped%
\draw[chronevent]%
(\xstop, 0) circle (.2\unit)%
node[flippedeventlabel] {#3};%
\else%
\draw[chronevent]%
(\xstop, 0) circle (.2\unit)%
node[eventlabel] {#3};%
\fi%
}{%
\pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
\ifflipped%
\draw[chronevent,rounded corners=.2\unit]%
(\xstart,-.2\unit) rectangle%
node[flippedeventlabel] {#3} (\xstop,.2\unit);%
\else%
\draw[chronevent,rounded corners=.2\unit]%
(\xstart,-.2\unit) rectangle%
node[eventlabel] {#3} (\xstop,.2\unit);%
\fi%
}%
}
%
% Eventspan
%
\DeclareDocumentCommand \eventspan {m m m O{black} O{0.3} O{0.2} o}{% Startdate Enddate Label Fill Opacity Height Bottom?
\pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
\pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
\IfNoValueTF {#7} {%
\draw[style={fill=#4,draw=none,opacity=#5},rounded corners=.05\unit]%
(\xstart,-#6\unit) rectangle node[eventlabel] {#3} (\xstop,.2\unit);%
}{%
\draw[style={fill=#4,draw=none,opacity=#5},rounded corners=.05\unit]% Event, bottom label
(\xstart,-#6\unit) rectangle node[eventlabelbottom, anchor=north west,rotate=-45]{#3} (\xstop,.2\unit);%
}%
}
%
% Eventpoint
%
\DeclareDocumentCommand \eventpoint {m m O{red} O{1} O{0.3}}{% Date Label Fill Opacity Height
\pgfmathsetlength\xstop{(#1-\theyearstart)*\unit}%
\draw[style={fill=#3,draw=none,opacity=#4},rounded corners=0\unit]%
(\xstop, .1\unit) coordinate(A) -- (\xstop-.2*#5\unit,#5\unit) coordinate(B) -- (\xstop+.2*#5\unit,#5\unit)coordinate(C)%
-- cycle node[eventlabel] {#2};%
}
%
\newcommand{\decimaldate}[3]{(#1-1)/31/12+(#2-1)/12+#3}%
%
\endinput%