| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2026 by Bret Watson <[email protected]> |
| 4 |
% ======================================================== |
| 5 |
% |
| 6 |
% This file is part of the milestonetimeline package. |
| 7 |
% |
| 8 |
% The milestonetimeline package is free software: you can redistribute it |
| 9 |
% and/or modify it under the terms of the GNU General Public License |
| 10 |
% as published by the Free Software Foundation, either version 3 of |
| 11 |
% the License, or (at your option) any later version. |
| 12 |
% |
| 13 |
% The milestonetimeline package is distributed in the hope that it will be |
| 14 |
% useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 15 |
% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
% GNU General Public License for more details. |
| 17 |
% |
| 18 |
% You should have received a copy of the GNU General Public License |
| 19 |
% along with the milestonetimeline package. If not, see |
| 20 |
% <https://www.gnu.org/licenses/>. |
| 21 |
% |
| 22 |
% This work consists of all files listed in manifest.txt. |
| 23 |
% |
| 24 |
% \fi |
| 25 |
% |
| 26 |
% \iffalse |
| 27 |
%<*driver> |
| 28 |
\ProvidesFile{milestonetimeline.dtx} |
| 29 |
%</driver> |
| 30 |
%<package>\NeedsTeXFormat{LaTeX2e}[1994/06/01] |
| 31 |
%<package>\ProvidesPackage{milestonetimeline} |
| 32 |
%<*package> |
| 33 |
[2026/02/25 v1.0 Milestone Timeline Package] |
| 34 |
%</package> |
| 35 |
% |
| 36 |
%<*driver> |
| 37 |
\documentclass{ltxdoc} |
| 38 |
\usepackage{milestonetimeline} |
| 39 |
\EnableCrossrefs |
| 40 |
\CodelineIndex |
| 41 |
\RecordChanges |
| 42 |
\begin{document} |
| 43 |
\DocInput{milestonetimeline.dtx} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
% \fi |
| 47 |
% |
| 48 |
% \CheckSum{0} |
| 49 |
% |
| 50 |
% \CharacterTable |
| 51 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 52 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 53 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 54 |
% Exclamation \! Double quote \" Hash (number) \# |
| 55 |
% Dollar \$ Percent \% Ampersand \& |
| 56 |
% Acute accent \' Left paren \( Right paren \) |
| 57 |
% Asterisk \* Plus \+ Comma \, |
| 58 |
% Minus \- Point \. Solidus \/ |
| 59 |
% Colon \: Semicolon \; Less than \< |
| 60 |
% Equals \= Greater than \> Question mark \? |
| 61 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 62 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 63 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 64 |
% Right brace \} Tilde \~} |
| 65 |
% |
| 66 |
% |
| 67 |
% \changes{v1.0}{2026/02/25}{Initial public release on CTAN} |
| 68 |
% \changes{v0.9}{2026/02/25}{Added per-milestone height control} |
| 69 |
% \changes{v0.8}{2026/02/25}{Fixed rotate origin syntax error} |
| 70 |
% \changes{v0.7}{2026/02/25}{Fixed hanging issues, simplified API} |
| 71 |
% \changes{v0.6}{2026/02/25}{Added rotation and compact options} |
| 72 |
% \changes{v0.5}{2026/02/25}{Fixed counter/register mixing} |
| 73 |
% \changes{v0.4}{2026/02/25}{Fixed dimension overflow errors} |
| 74 |
% \changes{v0.3}{2026/02/25}{Fixed pgfcalendar library loading} |
| 75 |
% \changes{v0.2}{2026/02/25}{Added date-based positioning} |
| 76 |
% \changes{v0.1}{2026/02/25}{Initial development version} |
| 77 |
% |
| 78 |
% \GetFileInfo{milestonetimeline.dtx} |
| 79 |
% |
| 80 |
% \title{The \textsf{milestonetimeline} package\thanks{This document |
| 81 |
% corresponds to \textsf{milestonetimeline}~\fileversion, dated \filedate.}} |
| 82 |
% \author{Your Name \\ \texttt{[email protected]}} |
| 83 |
% \maketitle |
| 84 |
% |
| 85 |
% \tableofcontents |
| 86 |
% |
| 87 |
% \section{Introduction} |
| 88 |
% |
| 89 |
% The \textsf{milestonetimeline} package provides a simple yet powerful way to create |
| 90 |
% horizontal milestone timelines in LaTeX documents. It supports both date-based |
| 91 |
% positioning (for accurate timelines) and automatic spacing (for conceptual timelines). |
| 92 |
% |
| 93 |
% \subsection{Key Features} |
| 94 |
% |
| 95 |
% \begin{itemize} |
| 96 |
% \item \textbf{Date-based positioning}: Milestones are placed proportionally based on actual dates |
| 97 |
% \item \textbf{Automatic spacing}: Even distribution when dates are not specified |
| 98 |
% \item \textbf{Label rotation}: Support for 0°, 45°, and 90° label angles |
| 99 |
% \item \textbf{Per-milestone height}: Individual control over vertical spacing |
| 100 |
% \item \textbf{Highlighted milestones}: Special markers for important events |
| 101 |
% \item \textbf{Date markers}: Optional month/quarter markers on the timeline |
| 102 |
% \item \textbf{Customizable colors}: Change timeline and highlight colors |
| 103 |
% \end{itemize} |
| 104 |
% |
| 105 |
% \section{Installation} |
| 106 |
% |
| 107 |
% \subsection{Option 1: CTAN (Recommended)} |
| 108 |
% |
| 109 |
% Once published on CTAN, install via your TeX distribution: |
| 110 |
% |
| 111 |
% \begin{verbatim} |
| 112 |
% tlmgr install milestonetimeline # TeX Live |
| 113 |
% \end{verbatim} |
| 114 |
% |
| 115 |
% \subsection{Option 2: Manual Installation} |
| 116 |
% |
| 117 |
% \begin{verbatim} |
| 118 |
% # Generate .sty from .dtx |
| 119 |
% latex milestonetimeline.ins |
| 120 |
% |
| 121 |
% # Move to your TeX directory |
| 122 |
% mkdir -p ~/texmf/tex/latex/milestonetimeline |
| 123 |
% mv milestonetimeline.sty ~/texmf/tex/latex/milestonetimeline/ |
| 124 |
% |
| 125 |
% # Update filename database |
| 126 |
% texhash ~/texmf |
| 127 |
% \end{verbatim} |
| 128 |
% |
| 129 |
% \subsection{Required Packages} |
| 130 |
% |
| 131 |
% The package automatically loads: |
| 132 |
% \begin{itemize} |
| 133 |
% \item \texttt{tikz} |
| 134 |
% \item \texttt{xifthen} |
| 135 |
% \item \texttt{xparse} |
| 136 |
% \item \texttt{kvoptions} |
| 137 |
% \item \texttt{pgfcalendar} (via tikz) |
| 138 |
% \end{itemize} |
| 139 |
% |
| 140 |
% \section{Basic Usage} |
| 141 |
% |
| 142 |
% \subsection{Simple Timeline} |
| 143 |
% |
| 144 |
% \begin{verbatim} |
| 145 |
% \begin{timeline}[width=14] |
| 146 |
% \milestone[above]{2025-01-15}{Kickoff} |
| 147 |
% \milestone[below]{2025-06-30}{Midpoint} |
| 148 |
% \milestone[above]{2025-12-31}{Complete} |
| 149 |
% \end{timeline} |
| 150 |
% \end{verbatim} |
| 151 |
% |
| 152 |
% \subsection{Timeline with Date Range} |
| 153 |
% |
| 154 |
% \begin{verbatim} |
| 155 |
% \begin{timeline}[width=14,startdate=2025-01-01,enddate=2025-12-31] |
| 156 |
% \milestone[above]{2025-01-15}{Kickoff} |
| 157 |
% \milestone[below]{2025-06-30}{Midpoint} |
| 158 |
% \milestone[above]{2025-12-31}{Complete} |
| 159 |
% \end{timeline} |
| 160 |
% \end{verbatim} |
| 161 |
% |
| 162 |
% \section{Environment Options} |
| 163 |
% |
| 164 |
% All options are set in the optional argument of the \texttt{timeline} environment. |
| 165 |
% |
| 166 |
% \begin{description} |
| 167 |
% \item[\texttt{width}] (default: \texttt{14}) Timeline width in centimeters |
| 168 |
% \item[\texttt{heightabove}] (default: \texttt{1.5}) Default height above timeline (cm) |
| 169 |
% \item[\texttt{heightbelow}] (default: \texttt{1.5}) Default height below timeline (cm) |
| 170 |
% \item[\texttt{dotsize}] (default: \texttt{3pt}) Size of milestone dots |
| 171 |
% \item[\texttt{color}] (default: \texttt{timelineblue}) Main timeline color |
| 172 |
% \item[\texttt{highlightcolor}] (default: \texttt{timelineorange}) Color for highlighted milestones |
| 173 |
% \item[\texttt{startdate}] (default: empty) Start date for date-based positioning (YYYY-MM-DD) |
| 174 |
% \item[\texttt{enddate}] (default: empty) End date for date-based positioning (YYYY-MM-DD) |
| 175 |
% \item[\texttt{rotation}] (default: \texttt{0}) Label rotation angle in degrees (0, 45, 90) |
| 176 |
% \item[\texttt{labelwidth}] (default: \texttt{3cm}) Width of label text box |
| 177 |
% \item[\texttt{fontsize}] (default: \texttt{\textbackslash small}) Font size for labels |
| 178 |
% \end{description} |
| 179 |
% |
| 180 |
% \section{Milestone Commands} |
| 181 |
% |
| 182 |
% \subsection{\texttt{\textbackslash milestone}} |
| 183 |
% |
| 184 |
% Adds a standard milestone to the timeline. |
| 185 |
% |
| 186 |
% \begin{verbatim} |
| 187 |
% \milestone[position][options]{date}{label} |
| 188 |
% \end{verbatim} |
| 189 |
% |
| 190 |
% \textbf{Parameters:} |
| 191 |
% \begin{itemize} |
| 192 |
% \item \texttt{position} (optional): \texttt{above} (default) or \texttt{below} |
| 193 |
% \item \texttt{options} (optional): Per-milestone height settings |
| 194 |
% \item \texttt{date}: Milestone date (YYYY-MM-DD format recommended) |
| 195 |
% \item \texttt{label}: Milestone text label |
| 196 |
% \end{itemize} |
| 197 |
% |
| 198 |
% \textbf{Examples:} |
| 199 |
% \begin{verbatim} |
| 200 |
% % Basic usage |
| 201 |
% \milestone[above]{2025-01-15}{Kickoff Meeting} |
| 202 |
% \milestone[below]{2025-02-20}{Review} |
| 203 |
% |
| 204 |
% % With custom height |
| 205 |
% \milestone[above][heightabove=2.5]{2025-03-15}{Long Label Text} |
| 206 |
% \milestone[below][heightbelow=2.0]{2025-04-10}{Another Label} |
| 207 |
% \milestone[above][height=3.0]{2025-05-01}{Very Tall} |
| 208 |
% \end{verbatim} |
| 209 |
% |
| 210 |
% \subsection{\texttt{\textbackslash highlightmilestone}} |
| 211 |
% |
| 212 |
% Adds a highlighted milestone (different color) for important events. |
| 213 |
% |
| 214 |
% \begin{verbatim} |
| 215 |
% \highlightmilestone[position][options]{date}{label} |
| 216 |
% \end{verbatim} |
| 217 |
% |
| 218 |
% \subsection{\texttt{\textbackslash milestoneat}} |
| 219 |
% |
| 220 |
% Adds a milestone at a specific x-position (overrides date positioning). |
| 221 |
% |
| 222 |
% \begin{verbatim} |
| 223 |
% \milestoneat[position][options]{x}{date}{label} |
| 224 |
% \end{verbatim} |
| 225 |
% |
| 226 |
% \subsection{\texttt{\textbackslash timelinetitle}} |
| 227 |
% |
| 228 |
% Adds a title above the timeline. |
| 229 |
% |
| 230 |
% \begin{verbatim} |
| 231 |
% \timelinetitle{Your Timeline Title} |
| 232 |
% \end{verbatim} |
| 233 |
% |
| 234 |
% \subsection{\texttt{\textbackslash datemarker}} |
| 235 |
% |
| 236 |
% Adds date markers (e.g., month labels) on the timeline. |
| 237 |
% |
| 238 |
% \begin{verbatim} |
| 239 |
% \datemarker{date}{label} |
| 240 |
% \end{verbatim} |
| 241 |
% |
| 242 |
% \section{Per-Milestone Options} |
| 243 |
% |
| 244 |
% These options can be set individually for each milestone: |
| 245 |
% |
| 246 |
% \begin{description} |
| 247 |
% \item[\texttt{heightabove}] Height for above milestones only |
| 248 |
% \item[\texttt{heightbelow}] Height for below milestones only |
| 249 |
% \item[\texttt{height}] Sets both above and below heights |
| 250 |
% \end{description} |
| 251 |
% |
| 252 |
% \section{Complete Examples} |
| 253 |
% |
| 254 |
% \subsection{Project Timeline} |
| 255 |
% |
| 256 |
% \begin{verbatim} |
| 257 |
% \begin{timeline}[ |
| 258 |
% width=16, |
| 259 |
% heightabove=1.5, |
| 260 |
% heightbelow=1.5, |
| 261 |
% startdate=2025-01-26, |
| 262 |
% enddate=2025-12-11 |
| 263 |
% ] |
| 264 |
% \timelinetitle{Project Timeline} |
| 265 |
% \milestone[above]{2025-01-26}{Kickoff} |
| 266 |
% \milestone[below]{2025-02-06}{Vendor Selection} |
| 267 |
% \milestone[above]{2025-03-15}{Requirements} |
| 268 |
% \milestone[below]{2025-04-12}{Prototype} |
| 269 |
% \highlightmilestone[above][heightabove=2.5]{2025-09-02}{User Training} |
| 270 |
% \milestone[below]{2025-10-20}{UAT Complete} |
| 271 |
% \milestone[above]{2025-12-01}{Go-Live} |
| 272 |
% |
| 273 |
% \datemarker{2025-04-01}{Apr} |
| 274 |
% \datemarker{2025-08-01}{Aug} |
| 275 |
% \datemarker{2025-12-01}{Dec} |
| 276 |
% \end{timeline} |
| 277 |
% \end{verbatim} |
| 278 |
% |
| 279 |
% \subsection{Compact Timeline} |
| 280 |
% |
| 281 |
% \begin{verbatim} |
| 282 |
% \begin{timeline}[ |
| 283 |
% width=16, |
| 284 |
% heightabove=0.8, |
| 285 |
% heightbelow=0.8, |
| 286 |
% labelwidth=2cm, |
| 287 |
% fontsize=\footnotesize, |
| 288 |
% rotation=45, |
| 289 |
% startdate=2025-01-01, |
| 290 |
% enddate=2025-12-31 |
| 291 |
% ] |
| 292 |
% \milestone[above]{2025-01-15}{Phase 1} |
| 293 |
% \milestone[below]{2025-02-20}{Review} |
| 294 |
% \milestone[above]{2025-03-31}{Milestone 1} |
| 295 |
% \milestone[below]{2025-05-10}{Phase 2} |
| 296 |
% \milestone[above]{2025-06-30}{Midpoint} |
| 297 |
% \milestone[below]{2025-08-15}{Milestone 2} |
| 298 |
% \milestone[above]{2025-10-01}{Phase 3} |
| 299 |
% \milestone[below]{2025-12-31}{Complete} |
| 300 |
% \end{timeline} |
| 301 |
% \end{verbatim} |
| 302 |
% |
| 303 |
% \section{Troubleshooting} |
| 304 |
% |
| 305 |
% \subsection{Common Errors} |
| 306 |
% |
| 307 |
% \begin{description} |
| 308 |
% \item[\texttt{Dimension too large}] Use TeX count registers (fixed in v0.4+) |
| 309 |
% \item[\texttt{Missing number}] Ensure date format is YYYY-MM-DD |
| 310 |
% \item[\texttt{Undefined control sequence}] Check all required packages are installed |
| 311 |
% \item[\texttt{Package hangs}] Avoid nested optional arguments (fixed in v0.7+) |
| 312 |
% \end{description} |
| 313 |
% |
| 314 |
% \subsection{Compilation Issues} |
| 315 |
% |
| 316 |
% \begin{itemize} |
| 317 |
% \item Run \texttt{pdflatex} twice for proper positioning |
| 318 |
% \item Clear auxiliary files if errors persist |
| 319 |
% \item Ensure \texttt{milestonetimeline.sty} is in the correct location |
| 320 |
% \end{itemize} |
| 321 |
% |
| 322 |
% \section{License} |
| 323 |
% |
| 324 |
% This package is free software: you can redistribute it and/or modify |
| 325 |
% it under the terms of the GNU General Public License as published by |
| 326 |
% the Free Software Foundation, either version 3 of the License, or |
| 327 |
% (at your option) any later version. |
| 328 |
% |
| 329 |
% \StopEventually{\PrintIndex} |
| 330 |
% |
| 331 |
% \section{Implementation} |
| 332 |
% |
| 333 |
% \subsection{Package Setup} |
| 334 |
% |
| 335 |
% \begin{macrocode} |
| 336 |
%<*package> |
| 337 |
\NeedsTeXFormat{LaTeX2e}[1994/06/01] |
| 338 |
\ProvidesPackage{milestonetimeline} |
| 339 |
[2026/02/25 v1.0 Milestone Timeline Package] |
| 340 |
|
| 341 |
% ============================================================================ |
| 342 |
% Copyright (C) 2026 by Your Name <[email protected]> |
| 343 |
% |
| 344 |
% This file is part of the milestonetimeline package. |
| 345 |
% |
| 346 |
% The milestonetimeline package is free software: you can redistribute it |
| 347 |
% and/or modify it under the terms of the GNU General Public License |
| 348 |
% as published by the Free Software Foundation, either version 3 of |
| 349 |
% the License, or (at your option) any later version. |
| 350 |
% |
| 351 |
% The milestonetimeline package is distributed in the hope that it will be |
| 352 |
% useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 353 |
% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 354 |
% GNU General Public License for more details. |
| 355 |
% |
| 356 |
% You should have received a copy of the GNU General Public License |
| 357 |
% along with the milestonetimeline package. If not, see |
| 358 |
% <https://www.gnu.org/licenses/>. |
| 359 |
% ============================================================================ |
| 360 |
|
| 361 |
% Required packages |
| 362 |
\RequirePackage{tikz} |
| 363 |
\RequirePackage{xifthen} |
| 364 |
\RequirePackage{xparse} |
| 365 |
\RequirePackage{kvoptions} |
| 366 |
\usetikzlibrary{calendar} |
| 367 |
|
| 368 |
% Setup key-value options |
| 369 |
\SetupKeyvalOptions{ |
| 370 |
family=milestonetimeline, |
| 371 |
prefix=mtl@ |
| 372 |
} |
| 373 |
|
| 374 |
% Define package options |
| 375 |
\DeclareStringOption[14]{width} |
| 376 |
\DeclareStringOption[1.5]{heightabove} |
| 377 |
\DeclareStringOption[1.5]{heightbelow} |
| 378 |
\DeclareStringOption[3pt]{dotsize} |
| 379 |
\DeclareStringOption[timelineblue]{color} |
| 380 |
\DeclareStringOption[timelineorange]{highlightcolor} |
| 381 |
\DeclareStringOption[]{startdate} |
| 382 |
\DeclareStringOption[]{enddate} |
| 383 |
\DeclareStringOption[0]{rotation} |
| 384 |
\DeclareStringOption[3cm]{labelwidth} |
| 385 |
\DeclareStringOption[\small]{fontsize} |
| 386 |
|
| 387 |
% Define colors |
| 388 |
\definecolor{timelineblue}{RGB}{65, 105, 165} |
| 389 |
\definecolor{timelineorange}{RGB}{205, 100, 50} |
| 390 |
\definecolor{timelinegray}{RGB}{200, 200, 200} |
| 391 |
|
| 392 |
\ProcessKeyvalOptions* |
| 393 |
|
| 394 |
% Counter for automatic positioning |
| 395 |
\newcounter{mtl@milestonepos} |
| 396 |
|
| 397 |
% TeX count registers for Julian day calculations |
| 398 |
\newcount\mtl@startjulian |
| 399 |
\newcount\mtl@endjulian |
| 400 |
\newcount\mtl@milestonejulian |
| 401 |
\newcount\mtl@tempjulian |
| 402 |
\newcount\mtl@totaldays |
| 403 |
\newcount\mtl@markerjulian |
| 404 |
|
| 405 |
% Per-milestone height variables |
| 406 |
\newcommand{\mtl@milestone@heightabove}{\mtl@heightabove} |
| 407 |
\newcommand{\mtl@milestone@heightbelow}{\mtl@heightbelow} |
| 408 |
|
| 409 |
% \end{macrocode} |
| 410 |
% |
| 411 |
% \subsection{Timeline Environment} |
| 412 |
% |
| 413 |
% \begin{macrocode} |
| 414 |
% Timeline environment |
| 415 |
\NewDocumentEnvironment{timeline}{O{}} |
| 416 |
{% |
| 417 |
% Process local options |
| 418 |
\setkeys{milestonetimeline}{#1} |
| 419 |
|
| 420 |
% Initialize per-milestone heights to defaults |
| 421 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 422 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 423 |
|
| 424 |
\begin{tikzpicture}[ |
| 425 |
every node/.style={font=\sffamily}, |
| 426 |
] |
| 427 |
% Draw main timeline |
| 428 |
\draw[thick,\mtl@color!50] (0,0) -- (\mtl@width,0); |
| 429 |
\setcounter{mtl@milestonepos}{0} |
| 430 |
|
| 431 |
% Initialize total days |
| 432 |
\mtl@totaldays=0 |
| 433 |
|
| 434 |
% Calculate date range if provided |
| 435 |
\ifthenelse{\equal{\mtl@startdate}{}}{}{% |
| 436 |
\ifthenelse{\equal{\mtl@enddate}{}}{}{% |
| 437 |
\pgfcalendardatetojulian{\mtl@startdate}{\mtl@startjulian} |
| 438 |
\pgfcalendardatetojulian{\mtl@enddate}{\mtl@endjulian} |
| 439 |
\mtl@totaldays=\mtl@endjulian |
| 440 |
\advance\mtl@totaldays by -\mtl@startjulian |
| 441 |
}% |
| 442 |
}% |
| 443 |
} |
| 444 |
{ |
| 445 |
\end{tikzpicture} |
| 446 |
} |
| 447 |
|
| 448 |
% \end{macrocode} |
| 449 |
% |
| 450 |
% \subsection{Position Calculation} |
| 451 |
% |
| 452 |
% \begin{macrocode} |
| 453 |
% Calculate position based on date |
| 454 |
\newcommand{\mtl@calculateposition}[2]{% |
| 455 |
% #1 = milestone date |
| 456 |
% #2 = output macro (x position) |
| 457 |
\ifnum\mtl@totaldays>0 |
| 458 |
% Date-based positioning |
| 459 |
\pgfcalendardatetojulian{#1}{\mtl@milestonejulian} |
| 460 |
\mtl@tempjulian=\mtl@milestonejulian |
| 461 |
\advance\mtl@tempjulian by -\mtl@startjulian |
| 462 |
% Now use pgfmath with the smaller relative day number |
| 463 |
\pgfmathsetmacro{#2}{(\the\mtl@tempjulian / \the\mtl@totaldays) * \mtl@width} |
| 464 |
% Ensure position is within bounds |
| 465 |
\ifdim#2pt<0pt \def#2{0}\fi |
| 466 |
\ifdim#2pt>\mtl@width pt \edef#2{\mtl@width}\fi |
| 467 |
\else |
| 468 |
% Automatic positioning (fallback) |
| 469 |
\stepcounter{mtl@milestonepos} |
| 470 |
\pgfmathsetmacro{#2}{(\themtl@milestonepos-1)*(\mtl@width/12)} |
| 471 |
\fi |
| 472 |
} |
| 473 |
|
| 474 |
% \end{macrocode} |
| 475 |
% |
| 476 |
% \subsection{Drawing Commands} |
| 477 |
% |
| 478 |
% \begin{macrocode} |
| 479 |
% Internal command to draw milestone above timeline |
| 480 |
\newcommand{\mtl@drawmilestoneabove}[3]{% |
| 481 |
% #1 = x position |
| 482 |
% #2 = date |
| 483 |
% #3 = label |
| 484 |
\draw (#1,0.1) -- (#1,-0.1); |
| 485 |
\fill[\mtl@color] (#1,\mtl@milestone@heightabove) circle (\mtl@dotsize); |
| 486 |
\draw (#1,\mtl@milestone@heightabove) -- (#1,0.1); |
| 487 |
\node[anchor=south west,align=left,xshift=5pt,inner sep=1pt,rotate=\mtl@rotation] at (#1,\mtl@milestone@heightabove) |
| 488 |
{\begin{minipage}{\mtl@labelwidth}\mtl@fontsize\textbf{#3}\\[2pt]#2\end{minipage}}; |
| 489 |
% Reset to default for next milestone |
| 490 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 491 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 492 |
} |
| 493 |
|
| 494 |
% Internal command to draw milestone below timeline |
| 495 |
\newcommand{\mtl@drawmilestonebelow}[3]{% |
| 496 |
% #1 = x position |
| 497 |
% #2 = date |
| 498 |
% #3 = label |
| 499 |
\draw (#1,0.1) -- (#1,-0.1); |
| 500 |
\fill[\mtl@color] (#1,-\mtl@milestone@heightbelow) circle (\mtl@dotsize); |
| 501 |
\draw (#1,-\mtl@milestone@heightbelow) -- (#1,-0.1); |
| 502 |
\node[anchor=north west,align=left,xshift=5pt,inner sep=1pt,rotate=\mtl@rotation] at (#1,-\mtl@milestone@heightbelow) |
| 503 |
{\begin{minipage}{\mtl@labelwidth}\mtl@fontsize#3\\[2pt]#2\end{minipage}}; |
| 504 |
% Reset to default for next milestone |
| 505 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 506 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 507 |
} |
| 508 |
|
| 509 |
% Internal command to draw highlight milestone above timeline |
| 510 |
\newcommand{\mtl@drawhighlightabove}[3]{% |
| 511 |
% #1 = x position |
| 512 |
% #2 = date |
| 513 |
% #3 = label |
| 514 |
\draw (#1,0.1) -- (#1,-0.1); |
| 515 |
\fill[\mtl@highlightcolor] (#1,\mtl@milestone@heightabove) circle (\mtl@dotsize); |
| 516 |
\draw (#1,\mtl@milestone@heightabove) -- (#1,0.1); |
| 517 |
\node[anchor=south west,align=left,xshift=5pt,inner sep=1pt,rotate=\mtl@rotation] at (#1,\mtl@milestone@heightabove) |
| 518 |
{\begin{minipage}{\mtl@labelwidth}\mtl@fontsize\textbf{#3}\\[2pt]#2\end{minipage}}; |
| 519 |
% Reset to default for next milestone |
| 520 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 521 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 522 |
} |
| 523 |
|
| 524 |
% Internal command to draw highlight milestone below timeline |
| 525 |
\newcommand{\mtl@drawhighlightbelow}[3]{% |
| 526 |
% #1 = x position |
| 527 |
% #2 = date |
| 528 |
% #3 = label |
| 529 |
\draw (#1,0.1) -- (#1,-0.1); |
| 530 |
\fill[\mtl@highlightcolor] (#1,-\mtl@milestone@heightbelow) circle (\mtl@dotsize); |
| 531 |
\draw (#1,-\mtl@milestone@heightbelow) -- (#1,-0.1); |
| 532 |
\node[anchor=north west,align=left,xshift=5pt,inner sep=1pt,rotate=\mtl@rotation] at (#1,-\mtl@milestone@heightbelow) |
| 533 |
{\begin{minipage}{\mtl@labelwidth}\mtl@fontsize#3\\[2pt]#2\end{minipage}}; |
| 534 |
% Reset to default for next milestone |
| 535 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 536 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 537 |
} |
| 538 |
|
| 539 |
% \end{macrocode} |
| 540 |
% |
| 541 |
% \subsection{Per-Milestone Options} |
| 542 |
% |
| 543 |
% \begin{macrocode} |
| 544 |
% Key-value setup for per-milestone options |
| 545 |
\define@key{mtlmilestone}{heightabove}{\edef\mtl@milestone@heightabove{#1}} |
| 546 |
\define@key{mtlmilestone}{heightbelow}{\edef\mtl@milestone@heightbelow{#1}} |
| 547 |
\define@key{mtlmilestone}{height}{\edef\mtl@milestone@heightabove{#1}\edef\mtl@milestone@heightbelow{#1}} |
| 548 |
|
| 549 |
% \end{macrocode} |
| 550 |
% |
| 551 |
% \subsection{User Commands} |
| 552 |
% |
| 553 |
% \begin{macrocode} |
| 554 |
% Command to add a milestone with optional height |
| 555 |
% Usage: \milestone[position][height=value]{date}{label} |
| 556 |
\NewDocumentCommand{\milestone}{O{above}O{}mm}{% |
| 557 |
% Reset to defaults first |
| 558 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 559 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 560 |
% Apply per-milestone options |
| 561 |
\setkeys{mtlmilestone}{#2} |
| 562 |
|
| 563 |
\mtl@calculateposition{#3}{\mtl@xpos} |
| 564 |
|
| 565 |
\ifthenelse{\equal{#1}{above}} |
| 566 |
{% |
| 567 |
\mtl@drawmilestoneabove{\mtl@xpos}{#3}{#4}% |
| 568 |
} |
| 569 |
{% |
| 570 |
\mtl@drawmilestonebelow{\mtl@xpos}{#3}{#4}% |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
% Command for highlighted milestone with optional height |
| 575 |
\NewDocumentCommand{\highlightmilestone}{O{above}O{}mm}{% |
| 576 |
% Reset to defaults first |
| 577 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 578 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 579 |
% Apply per-milestone options |
| 580 |
\setkeys{mtlmilestone}{#2} |
| 581 |
|
| 582 |
\mtl@calculateposition{#3}{\mtl@xpos} |
| 583 |
|
| 584 |
\ifthenelse{\equal{#1}{above}} |
| 585 |
{% |
| 586 |
\mtl@drawhighlightabove{\mtl@xpos}{#3}{#4}% |
| 587 |
} |
| 588 |
{% |
| 589 |
\mtl@drawhighlightbelow{\mtl@xpos}{#3}{#4}% |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
% Command for manual positioning |
| 594 |
\NewDocumentCommand{\milestoneat}{O{above}O{}mmm}{% |
| 595 |
% Reset to defaults first |
| 596 |
\edef\mtl@milestone@heightabove{\mtl@heightabove} |
| 597 |
\edef\mtl@milestone@heightbelow{\mtl@heightbelow} |
| 598 |
% Apply per-milestone options |
| 599 |
\setkeys{mtlmilestone}{#2} |
| 600 |
|
| 601 |
\ifthenelse{\equal{#1}{above}} |
| 602 |
{% |
| 603 |
\mtl@drawmilestoneabove{#3}{#4}{#5}% |
| 604 |
} |
| 605 |
{% |
| 606 |
\mtl@drawmilestonebelow{#3}{#4}{#5}% |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
% Command for title |
| 611 |
\NewDocumentCommand{\timelinetitle}{m}{% |
| 612 |
\node[anchor=south,font=\sffamily\Large] at (\mtl@width/2,\mtl@heightabove+1) {#1}; |
| 613 |
} |
| 614 |
|
| 615 |
% Command to add date markers on timeline |
| 616 |
\NewDocumentCommand{\datemarker}{mm}{% |
| 617 |
\ifnum\mtl@totaldays>0 |
| 618 |
\pgfcalendardatetojulian{#1}{\mtl@markerjulian} |
| 619 |
\mtl@tempjulian=\mtl@markerjulian |
| 620 |
\advance\mtl@tempjulian by -\mtl@startjulian |
| 621 |
\pgfmathsetmacro{\mtl@markerpos}{(\the\mtl@tempjulian / \the\mtl@totaldays) * \mtl@width} |
| 622 |
\draw (\mtl@markerpos,0.05) -- (\mtl@markerpos,-0.05); |
| 623 |
\node[anchor=north,font=\sffamily\small,text=\mtl@color!70] at (\mtl@markerpos,-0.1) {#2}; |
| 624 |
\fi |
| 625 |
} |
| 626 |
|
| 627 |
%</package> |
| 628 |
% \end{macrocode} |
| 629 |
% |
| 630 |
% \Finale |