├── example.pdf ├── README.md ├── example.tex └── tikzlibrarytimeline.code.tex /example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cfiandra/timeline/HEAD/example.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | timeline 2 | ======== 3 | 4 | TikZ timeline library 5 | 6 | Original version published on: 7 | http://tex.stackexchange.com/a/159856/13304 8 | -------------------------------------------------------------------------------- /example.tex: -------------------------------------------------------------------------------- 1 | \documentclass[border=10pt]{standalone} 2 | 3 | \usepackage{tikz} 4 | \usetikzlibrary{timeline} 5 | 6 | \begin{document} 7 | 8 | \begin{tikzpicture}[timespan={}] 9 | % timespan={Day} -> now we have days as reference 10 | % timespan={} -> no label is displayed for the timespan 11 | % default timespan is 'Week' 12 | 13 | \timeline[custom interval=true]{January, March, May, July, September, November} 14 | % \timeline[custom interval=true]{3,...,9} -> i.e., from Day 3 to Day 9 15 | % \timeline{8} -> i.e., from Week 1 to Week 8 16 | 17 | % put here the phases 18 | \begin{phases} 19 | \initialphase{involvement degree=1.75cm,phase color=black} 20 | \phase{between week=1 and 2 in 0.1,involvement degree=2.25cm} 21 | \phase{between week=1 and 2 in 0.5,involvement degree=3cm} 22 | \phase{between week=1 and 2 in 0.9,involvement degree=2.125cm} 23 | \phase{between week=3 and 4 in 0.7,phase color=blue!80!cyan} 24 | \end{phases} 25 | 26 | % put here the milestones 27 | \addmilestone{at=phase-0.90,direction=90:1cm,text={Initial meeting},text options={above}} 28 | \addmilestone{at=phase-0.270,direction=270:1cm,text={Initial meeting},text options={below}} 29 | 30 | \addmilestone{at=phase-2.110,direction=120:1.5cm,text={Research},text options={above}} 31 | \addmilestone{at=phase-2.250,direction=240:1.5cm,text={Need Agreement},text options={below}} 32 | \end{tikzpicture} 33 | 34 | \end{document} -------------------------------------------------------------------------------- /tikzlibrarytimeline.code.tex: -------------------------------------------------------------------------------- 1 | % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | % COPYRIGHT 2014 - Claudio Fiandrino 3 | % Released under the LaTeX Project Public License v1.3c or later 4 | % 5 | % email: 6 | % 7 | % Timeline TikZ library version 0.3b - 25/02/2019 8 | 9 | \usetikzlibrary{backgrounds,calc} 10 | 11 | \pgfkeys{/tikz/.cd, 12 | timespan/.store in=\timespan, 13 | timespan=Week, 14 | timeline width/.store in=\timelinewidth, 15 | timeline width=20, 16 | timeline height/.store in=\timelineheight, 17 | timeline height=1, 18 | timeline offset/.store in=\timelineoffset, 19 | timeline offset=0.15, 20 | initial week/.store in=\initialweek, 21 | initial week=1, 22 | end week/.store in=\endweek, 23 | end week=2, 24 | time point/.store in=\timepoint, 25 | time point=0.5, 26 | between day/.style args={#1 and #2 in #3}{% auxiliary style for days 27 | initial week=#1, 28 | end week=#2, 29 | time point=#3, 30 | }, 31 | between week/.style args={#1 and #2 in #3}{% style for weeks 32 | initial week=#1, 33 | end week=#2, 34 | time point=#3, 35 | }, 36 | between month/.style args={#1 and #2 in #3}{% auxiliary style for months 37 | initial week=#1, 38 | end week=#2, 39 | time point=#3, 40 | }, 41 | between year/.style args={#1 and #2 in #3}{% auxiliary style for years 42 | initial week=#1, 43 | end week=#2, 44 | time point=#3, 45 | }, 46 | involvement degree/.store in=\involvdegree, 47 | involvement degree=2cm, 48 | phase color/.store in=\phasecol, 49 | phase color=red!50!orange, 50 | phase appearance/.style={ 51 | circle, 52 | opacity=0.3, 53 | minimum size=\involvdegree, 54 | fill=\phasecol 55 | }, 56 | } 57 | % settings to customize aspect of timeline 58 | \newif\ifcustominterval 59 | \pgfkeys{/tikz/timeline/.cd, 60 | custom interval/.is if=custominterval, 61 | custom interval=false, 62 | } 63 | 64 | % settings to deploy milestones 65 | \pgfkeys{/tikz/milestone/.cd, 66 | at/.store in=\msstartpoint, 67 | at=phase-1.north, 68 | circle radius/.store in=\milestonecircleradius, 69 | circle radius=0.1cm, 70 | direction/.store in=\msdirection, 71 | direction=90:2cm, 72 | text/.store in=\mstext, 73 | text={}, 74 | text options/.code={\tikzset{#1}}, 75 | } 76 | 77 | \newcommand{\reftimespan}{\MakeLowerCase{\timespan}} 78 | 79 | \newcommand{\timeline}[2][]{ 80 | \pgfkeys{/tikz/timeline/.cd,#1} 81 | \draw[fill,opacity=0.8] (0,0) rectangle (\timelinewidth,\timelineheight); 82 | \shade[top color=black, bottom color=white,middle color=black!20] 83 | (0,0) rectangle (\timelinewidth,-\timelineoffset); 84 | \shade[top color=white, bottom color=black,middle color=black!20] 85 | (0,\timelineheight) rectangle (\timelinewidth,\timelineheight+\timelineoffset); 86 | 87 | \ifcustominterval% 88 | \foreach \smitem [count=\tlmxi] in {#2} {\global\let\maxsmitem\tlmxi}% 89 | \else% 90 | \foreach \smitem [count=\tlmxi] in {1,...,#2} {\global\let\maxsmitem\tlmxi}% 91 | \fi% 92 | 93 | \pgfmathsetmacro\position{\timelinewidth/(\maxsmitem+1)} 94 | \node at (0,0.5\timelineheight)(\timespan-0){\phantom{Week 0}}; 95 | 96 | \ifcustominterval% 97 | \foreach \x[count=\tlmxi] in {#2}{% 98 | \node[text=white,text depth=0pt]at +(\tlmxi*\position,0.5\timelineheight) (\timespan-\tlmxi) {\timespan\ \x};% 99 | }% 100 | \else% 101 | \foreach \x[count=\tlmxi] in {1,...,#2}{% 102 | \node[text=white, text depth=0pt]at +(\tlmxi*\position,0.5\timelineheight) (\timespan-\tlmxi) {\timespan\ \x};% 103 | }% 104 | \fi% 105 | } 106 | 107 | \newcounter{involv} 108 | \setcounter{involv}{0} 109 | 110 | \newcommand{\phase}[1]{ 111 | \stepcounter{involv} 112 | \node[phase appearance,#1] 113 | (phase-\theinvolv) 114 | at ($(\timespan-\initialweek)!\timepoint!(\timespan-\endweek)$){}; 115 | } 116 | 117 | \newcommand{\initialphase}[1]{ 118 | \node[phase appearance,#1,anchor=west,between week=0 and 1 in 0,] 119 | (phase-\theinvolv) 120 | at ($(\timespan-0)!0!(\timespan-1)$){}; 121 | \setcounter{involv}{0} 122 | } 123 | 124 | \newenvironment{phases}{\begin{pgfonlayer}{background}}{\end{pgfonlayer}} 125 | 126 | \newcommand{\addmilestone}[1]{ 127 | \pgfkeys{/tikz/milestone/.cd,#1} 128 | \draw[double,fill] (\msstartpoint) circle [radius=\milestonecircleradius]; 129 | \draw(\msstartpoint)--++(\msdirection)node[/tikz/milestone/text options]{\mstext}; 130 | } 131 | 132 | % HISTORY 133 | % 0.1 -> initial release 134 | % 0.2 -> customizable timespan label 135 | % 0.3 -> \timeline command with custom intervals 136 | % styles ``between x'' 137 | % removed unnecessary call to xstring 138 | % 0.3a -> text depth for timeline labels 139 | % 0.3b -> \xi conflict - thanks Enrico Gregorio (egreg) https://tex.stackexchange.com/q/476089 140 | --------------------------------------------------------------------------------