diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-10 21:45:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-10 21:45:07 +0000 |
commit | a4c88116b51e4cbb34c514b6d9552666fad2205b (patch) | |
tree | f049f474d3d61ce574d801305416492305cdee2a /Master/texmf-dist/tex/latex/pgfgantt | |
parent | bea8b0ad332baefe4b0b75a907674628363f1aa2 (diff) |
pgfgantt (10jan18)
git-svn-id: svn://tug.org/texlive/trunk@46280 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pgfgantt')
-rw-r--r-- | Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty | 202 |
1 files changed, 182 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty b/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty index d87a9a2f7b1..9bac4b1d48d 100644 --- a/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty +++ b/Master/texmf-dist/tex/latex/pgfgantt/pgfgantt.sty @@ -6,17 +6,17 @@ %% %% pgfgantt.dtx (with options: `pgfgantt') %% -%% Copyright (C) 2013 by Wolfgang Skala +%% Copyright (C) 2018 by Wolfgang Skala %% %% This work may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3 +%% conditions of the LaTeX Project Public License, either version 1.3c %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt -%% and version 1.3 or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2008/05/04 or later. %% -\ProvidesPackage{pgfgantt}[2013/06/01 v4.0 Draw Gantt diagrams with TikZ] +\ProvidesPackage{pgfgantt}[2018/01/10 v5.0 Draw Gantt diagrams with TikZ] \NeedsTeXFormat{LaTeX2e}[1999/12/01] \RequirePackage{tikz} \usetikzlibrary{% @@ -25,6 +25,7 @@ } \RequirePackage{pgfcalendar} +\def\@gtt@ifstar#1{\kernel@ifnextchar*{\@firstoftwo{#1}}} \def\ganttset#1{\pgfqkeys{/pgfgantt}{#1}} \def\@gtt@keydef#1#2{% \pgfkeyssetvalue{/pgfgantt/#1}{#2}% @@ -77,7 +78,7 @@ } \def\gtt@hgrid@analyze{% - \@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}% + \@gtt@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}% } \def\gtt@hgrid@draw#1#2\relax{% @@ -125,7 +126,7 @@ } \def\gtt@vgrid@analyze{% - \@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}% + \@gtt@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}% } \def\gtt@vgrid@draw#1#2\relax{% @@ -146,7 +147,11 @@ \newcommand\gtt@juliantotimeslot[2]{% \begingroup% \@tempcnta=#1\relax% - \ifgtt@compresscalendar% + \ifgtt@timeslotunit@day% + \advance\@tempcnta by-\gtt@startjulian\relax% + \advance\@tempcnta by1\relax% + \fi% + \ifgtt@timeslotunit@month% \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}% \@tempcnta=\@tempa\relax% \advance\@tempcnta by-\gtt@startyear\relax% @@ -154,8 +159,11 @@ \advance\@tempcnta by\@tempb\relax% \advance\@tempcnta by-\gtt@startmonth\relax% \advance\@tempcnta by1\relax% - \else% - \advance\@tempcnta by-\gtt@startjulian\relax% + \fi% + \ifgtt@timeslotunit@year% + \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc}% + \@tempcnta=\@tempa\relax% + \advance\@tempcnta by-\gtt@startyear\relax% \advance\@tempcnta by1\relax% \fi% #2=\@tempcnta\relax% @@ -183,6 +191,10 @@ \pgfcalendardatetojulian{#1-01}{#2}% } +\newgantttimeslotformat{isodate-year}{% + \pgfcalendardatetojulian{#1-01-01}{#2}% +} + \newcommand\gtt@tsf@getdmy[1]{% \edef\local@firstarg{#1}% \def\local@decompose##1.##2.##3\relax{% @@ -271,6 +283,7 @@ \@gtt@keydef{y unit title}{1cm} \@gtt@keydef{y unit chart}{1cm} \@gtt@stylekeydef{canvas}{shape=rectangle, draw, fill=white} +\@gtt@keydef{expand chart}{none} \@gtt@keydef{today}{none} \@gtt@keydef{today offset}{1} \@gtt@stylekeydef{today rule}{dashed, line width=1pt} @@ -292,6 +305,10 @@ \newcount\gtt@today@slot \newcount\gtt@startjulian \newcount\gtt@endjulian +\newcount\gtt@chartid +\def\gtt@chartextrasize#1#2{% + \global\@namedef{@gtt@chart@#1@extrasize}{#2}% +} \newenvironment{ganttchart}[3][]{% \ganttset{#1}% \gtt@tsstojulian{#2}{\gtt@startjulian}% @@ -314,6 +331,20 @@ \global\gtt@currentline=0\relax% \global\gtt@lasttitleline=0\relax% \global\gtt@lasttitleslot=0\relax% + \def\@tempa{none}% + \edef\@tempb{\ganttvalueof{expand chart}}% + \ifx\@tempa\@tempb\else% + \@ifundefined{@gtt@chart@\the\gtt@chartid @extrasize}{% + \@gtt@PackageWarning{Gantt chart expansion may have changed. + Rerun to get expansion right}% + }{% + \pgfmathparse{(\ganttvalueof{expand chart}% + - \@nameuse{@gtt@chart@\the\gtt@chartid @extrasize})% + / \gtt@chartwidth}% + \edef\gtt@expanded@xunit{\pgfmathresult pt}% + \ganttset{x unit=\gtt@expanded@xunit}% + }% + \fi% \@ifundefined{useasboundingbox}% {\gtt@tikzpicturefalse\begin{tikzpicture}}% {\gtt@tikzpicturetrue}% @@ -383,6 +414,14 @@ node [/pgfgantt/today label node] {\ganttvalueof{today label}};% \fi% \end{scope}% + \pgfextractx{\@tempdima}{% + \pgfpointdiff{\pgfpointanchor{current bounding box}{south west}}% + {\pgfpointanchor{current bounding box}{north east}}% + }% + \pgfmathparse{\@tempdima -\ganttvalueof{x unit} * \gtt@chartwidth}% + \protected@write\@auxout{}{% + \string\gtt@chartextrasize{\the\gtt@chartid}{\pgfmathresult pt}}% + \global\advance\gtt@chartid by1\relax% \ifgtt@tikzpicture\else\end{tikzpicture}\fi% } @@ -409,12 +448,48 @@ \endgroup% } +\@gtt@keydef{vrule offset}{1} +\@gtt@stylekeydef{vrule}{dashed, line width=1pt} +\@gtt@keydef{vrule label font}{\normalfont} +\@gtt@stylekeydef{vrule label node}{% + anchor=north, font=\ganttvalueof{vrule label font}% +} + +\newcount\gtt@vrule@slot + +\newcommand\ganttvrule[3][]{% + \begingroup + \ganttset{#1} + \gtt@tsstojulian{#3}{\gtt@vrule@slot}% + \gtt@juliantotimeslot{\gtt@vrule@slot}{\gtt@vrule@slot}% + \pgfmathsetmacro\y@upper{% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + }% + \pgfmathsetmacro\y@lower{% + \gtt@lasttitleline * \ganttvalueof{y unit title}% + + (\gtt@currentline - \gtt@lasttitleline - 1)% + * \ganttvalueof{y unit chart}% + }% + \pgfmathsetmacro\x@mid{% + (\gtt@vrule@slot - 1 + \ganttvalueof{vrule offset})% + * \ganttvalueof{x unit}% + }% + \draw [/pgfgantt/vrule] + (\x@mid pt, \y@upper pt) -- (\x@mid pt, \y@lower pt) + node [/pgfgantt/vrule label node] {#2};% + \endgroup +} + \@gtt@stylekeydef{title}{shape=rectangle, inner sep=0pt, draw, fill=white} \@gtt@keydef{title label font}{\small} \@gtt@stylekeydef{title label node}{% anchor=center, font=\ganttvalueof{title label font}% } \ganttset{% + title label text/.code={% + \def\gtt@titlelabeltext##1{#1}% + },% + title label text=\strut#1,% title list options/.code={% \def\gtt@titlelistoptions{[#1]}% },% @@ -430,10 +505,27 @@ include title in canvas } \@gtt@keydef{calendar week text}{Week~\currentweek} -\newif\ifgtt@compresscalendar +\newif\ifgtt@timeslotunit@day +\newif\ifgtt@timeslotunit@month +\newif\ifgtt@timeslotunit@year \ganttset{% - compress calendar/.is if=gtt@compresscalendar,% - compress calendar=false% + time slot unit/.is choice, + time slot unit/day/.code={% + \gtt@timeslotunit@daytrue% + \gtt@timeslotunit@monthfalse% + \gtt@timeslotunit@yearfalse% + },% + time slot unit/month/.code={% + \gtt@timeslotunit@dayfalse% + \gtt@timeslotunit@monthtrue% + \gtt@timeslotunit@yearfalse% + },% + time slot unit/year/.code={% + \gtt@timeslotunit@dayfalse% + \gtt@timeslotunit@monthfalse% + \gtt@timeslotunit@yeartrue% + },% + time slot unit=day } \newcommand\gantttitle[3][]{% @@ -470,7 +562,7 @@ \path (\x@mid pt, \y@mid pt) node [/pgfgantt/title, minimum width=\x@size pt, minimum height=\y@size pt] {} - node [/pgfgantt/title label node] {#2};% + node [/pgfgantt/title label node] {\gtt@titlelabeltext{#2}};% \global\advance\gtt@lasttitleslot by#3\relax% \endgroup% } @@ -484,7 +576,7 @@ \newif\ifgtt@titlecalendarstar \newcommand\gantttitlecalendar{% - \@ifstar% + \@gtt@ifstar% {\gtt@titlecalendarstartrue\@gantttitlecalendar}% {\gtt@titlecalendarstarfalse\@gantttitlecalendar}% } @@ -520,12 +612,79 @@ \newcount\gtt@calendar@slots \newcount\gtt@calendar@weeknumber \newcount\gtt@calendar@startofweek +\def\@gtt@getfourthdigit#1#2#3#4{#4} +\def\@gtt@getdecade#1#2#3#4{#1#2#3} +\pgfkeys{% + /pgf/calendar/end of decade/.code={ + \begingroup + \pgfcalendardatetojulian{#1}{\@tempcnta} + \pgfcalendarjuliantodate{\@tempcnta}{\@tempa}{\@tempb}{\@tempc} + \edef\endofdecade{\expandafter\@gtt@getfourthdigit\@tempa} + \edef\querydecade{\expandafter\@gtt@getfourthdigit\pgfcalendarifdateyear} + \ifnum\endofdecade=\querydecade\relax% + \ifnum\pgfcalendarifdatemonth=\@tempb\relax% + \ifnum\pgfcalendarifdateday=\@tempc\relax% + \global\pgfcalendarmatchestrue% + \fi% + \fi% + \fi% + \endgroup + }% +} + \ganttset{% + calendar/decade/.code={% + \ifgtt@calendar@eol\ganttnewline\fi% + \begingroup% + \gtt@calendar@slots=1\relax% + \ifgtt@timeslotunit@year% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{end of decade=2009-12-31}{% + \gantttitle{% + \expandafter\@gtt@getdecade\pgfcalendarcurrentyear% + 0s% + }{\the\gtt@calendar@slots}% + \gtt@calendar@slots=0\relax% + }{ + \ifdate{equals=01-01}{% + \ifnum\pgfcalendarcurrentjulian>\pgfcalendarbeginjulian\relax% + \advance\gtt@calendar@slots by1\relax% + \fi + }{}% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=0\relax\else% + \gantttitle{% + \expandafter\@gtt@getdecade\pgfcalendarcurrentyear% + 0s% + }{\the\gtt@calendar@slots}% + \fi% + }{}% + }% + \fi% + \endgroup% + \gtt@calendar@eoltrue% + },% calendar/year/.code={% \ifgtt@calendar@eol\ganttnewline\fi% \begingroup% \gtt@calendar@slots=1\relax% - \ifgtt@compresscalendar% + \ifgtt@timeslotunit@year% + \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% + \ifdate{equals=12-31}{% + \gantttitle{\pgfcalendarcurrentyear}{1}% + \gtt@calendar@slots=1\relax% + }{ + \advance\gtt@calendar@slots by1\relax% + }% + \ifdate{equals=\pgfcalendarendiso}{% + \ifnum\gtt@calendar@slots=1\relax\else% + \gantttitle{\pgfcalendarcurrentyear}{1}% + \fi% + }{}% + }% + \fi% + \ifgtt@timeslotunit@month% \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% \ifdate{equals=12-31}{% \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% @@ -544,7 +703,8 @@ }% }{}% }% - \else% + \fi% + \ifgtt@timeslotunit@day% \pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{% \ifdate{equals=12-31}{% \gantttitle{\pgfcalendarcurrentyear}{\the\gtt@calendar@slots}% @@ -572,7 +732,8 @@ \gantttitle{% \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}% }{% - \ifgtt@compresscalendar1\else\the\gtt@calendar@slots\fi% + \ifgtt@timeslotunit@month1\fi% + \ifgtt@timeslotunit@day\the\gtt@calendar@slots\fi% }% \gtt@calendar@slots=1\relax% }{% @@ -584,7 +745,8 @@ \gantttitle{% \csname pgfcalendarmonth#1\endcsname{\pgfcalendarcurrentmonth}% }{% - \ifgtt@compresscalendar1\else\the\gtt@calendar@slots\fi% + \ifgtt@timeslotunit@month1\fi% + \ifgtt@timeslotunit@day\the\gtt@calendar@slots\fi% }% \fi% }{}% @@ -832,7 +994,7 @@ } \def\newganttchartelement{% - \@ifstar\@newganttchartelement@one\@newganttchartelement@two% + \@gtt@ifstar\@newganttchartelement@one\@newganttchartelement@two% } \newcommand\@newganttchartelement@one[1]{% |