LaTeX-proposal/base/pdata.sty

264 lines
13 KiB
Plaintext
Raw Normal View History

2014-02-15 12:01:14 +01:00
%%
%% This is file `pdata.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% proposal.dtx (with options: `pdata')
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pdata}[2016/04/15 v1.5 Project Data]
2016-07-06 10:35:37 +02:00
\RequirePackage{workaddress}[2016/07/06]
2014-02-15 12:01:14 +01:00
\RequirePackage{eurosym}
\newif\if@sites\@sitesfalse\let\prop@gen@sites=\relax%
\newcounter{@site}%
\define@key{prop@gen}{site}{\@sitestrue\@dmp{site=#1}%
\stepcounter{@site}\pdata@def{site}{#1}{number}{\the@site}%
\@ifundefined{prop@gen@sites}{\xdef\prop@gen@sites{#1}}{\xdef\prop@gen@sites{\prop@gen@sites,#1}}%
\define@key{prop@gen}{#1RM}{\pdata@def{site}{#1}{intendedRM}{##1}}%
2016-09-28 17:05:53 +02:00
\if@RAM\define@key{prop@gen}{#1RAM}{\pdata@def{site}{#1}{intendedRAM}{##1}}\fi
2014-02-15 12:01:14 +01:00
\define@key{workpackage}{#1RM}{\pdata@def\wp@id{#1}{RM}{##1}}%
2016-09-28 17:05:53 +02:00
\if@RAM\define@key{workpackage}{#1RAM}{\pdata@def\wp@id{#1}{RAM}{##1}}\fi
2014-02-15 12:01:14 +01:00
\define@key{prop@gen}{#1employed}{{\let\tabularnewline\relax\let\hline\relax\let\wa@ref\relax%
\@ifundefined{prop@gen@employed@lines}%
2016-07-06 10:35:37 +02:00
{\xdef\prop@gen@employed@lines{\wa@ref3{institution}{#1}{shortname} & ##1\tabularnewline\hline}}%
{\xdef\prop@gen@employed@lines{\prop@gen@employed@lines \wa@ref3{institution}{#1}{shortname} & ##1\tabularnewline\hline}}}}}
2014-02-15 12:01:14 +01:00
\define@key{prop@gen}{RM}{\@dmp{RM=#1}\if@sites%
\PackageWarning{Do not use the RM key in the presence of sites}\else%
\pdata@def{all}{intended}{RM}{#1}\fi}
\define@key{prop@gen}{RAM}{\@dmp{RAM=#1}\if@sites%
\PackageWarning{Do not use the RAM key in the presence of sites}\else%
\pdata@def{all}{intended}{RAM}{#1}\fi}
\define@key{prop@gen}{PI}{\@dmp{PI=#1}%
\@ifundefined{prop@gen@PIs}{\xdef\prop@gen@PIs{#1}}{\xdef\prop@gen@PIs{\prop@gen@PIs,#1}}}
\define@key{prop@gen}{pubspage}{\@ifundefined{prop@gen@pubspages}%
{\xdef\prop@gen@pubspages{#1}}{\xdef\prop@gen@pubspages{\prop@gen@pubspages,#1}}}
\define@key{prop@gen}{importfrom}{\message{importing proposal data from #1.pdata}\readpdata{#1}}
\define@key{prop@gen}{instrument}{\def\prop@gen@instrument{#1}%
\pdata@def{prop}{gen}{instrument}{#1}\@dmp{inst=#1}}
\define@key{prop@gen}{title}{\def\prop@gen@title{#1}%
\pdata@def{prop}{gen}{title}{#1}}
\define@key{prop@gen}{acronym}{\gdef\prop@gen@acronym{#1}%
\pdata@def{prop}{gen}{acronym}{#1}\@dmp{acro=#1}}
\define@key{prop@gen}{acrolong}{\def\prop@gen@acrolong{#1}%
\pdata@def{prop}{gen}{acrolong}{#1}}
\define@key{prop@gen}{proposalnumber}{\def\prop@gen@proposalnumber{#1}%
\pdata@def{prop}{gen}{proposalnumber}{#1}}
2014-02-15 12:01:14 +01:00
\define@key{prop@gen}{discipline}{\def\prop@gen@discipline{#1}%
\pdata@def{prop}{gen}{discipline}{#1}}
\define@key{prop@gen}{areas}{\def\prop@gen@areas{#1}%
\pdata@def{prop}{gen}{areas}{#1}}
\define@key{prop@gen}{start}{\def\prop@gen@start{#1}%
\pdata@def{prop}{gen}{start}{#1}}
\define@key{prop@gen}{months}{\def\prop@gen@months{#1}%
\pdata@def{prop}{gen}{months}{#1}}
\define@key{prop@gen}{since}{\def\prop@gen@since{#1}%
\pdata@def{prop}{gen}{since}{#1}}
\define@key{prop@gen}{totalduration}{\def\prop@gen@totalduration{#1}%
\pdata@def{prop}{gen}{totalduration}{#1}}
\define@key{prop@gen}{fundsuntil}{\def\prop@gen@fundsuntil{#1}%
\pdata@def{prop}{gen}{fundsuntil}{#1}}
\define@key{prop@gen}{topdownPM}[true]{\def\prop@gen@topdownPM{#1}}
\define@key{prop@gen}{botupPM}[true]{\def\prop@gen@botupPM{#1}}
\define@key{prop@gen}{keywords}{\def\prop@gen@keywords{#1}}
2014-10-27 17:49:59 +01:00
\newcommand\prop@gen@acro@default{ACRONYM}
\def\prop@gen@acro{\prop@gen@acro@default}
\newcommand\prop@gen@months@default{???months???}
\def\prop@gen@months{\prop@gen@months@default}
\newcommand\prop@gen@title@default{???Proposal Title???}
\def\prop@gen@title{\prop@gen@title@default}
\newcommand\prop@gen@instrument@default{??? Instrument ???}
\def\prop@gen@instrument{\prop@gen@instrument@default}
2014-02-15 12:01:14 +01:00
\newcommand\prop@tl[2]{\xdef\tab@line{}
\@for\tl@ext:={#1}\do{\xdef\tab@line{\tab@line&#2}}
\tab@line}
\def\prop@gen@compactht{false}
\define@key{prop@gen}{compactht}[true]{\def\prop@gen@compactht{#1}}
\newcommand\deliv@error{\PackageError{proposal}
{To use use deliverables, you have to specify the option 'deliverables'}}
\newenvironment{wpdelivs}{\begin{wp@delivs}}{\end{wp@delivs}}
\newenvironment{wp@delivs}
{\ifdelivs\textbf\deliv@legend@delivs:\\[-3ex]%
\begin{compactdesc}\else\deliv@error\fi}
{\ifdelivs\end{compactdesc}\fi}
\newcommand\deliv@legend@delivs{Deliverables}
\newenvironment{wadelivs}
{\textbf\deliv@legend@delivs:\\[-3ex]\begin{wp@delivs}}
{\end{wp@delivs}}
\newcommand\lec[1]{\strut\hfil\strut\null\nobreak\hfill\hbox{$\leadsto$#1}\par}
\newcommand\deliv@label[1]{D{#1}}
\newcommand\delivref[2]{\pdataRef{deliv}{#1@#2}{label}}
\newcommand\localdelivref[1]{\delivref{\wp@id}{#1}}
\newcommand\delivtref[2]{\delivref{#1}{#2}: \pdataRefFB{deliv}{#1@#2}{short}{title}}
\newcommand\localdelivtref[1]{\delivtref{\wp@id}{#1}}
\define@key{deliv}{id}{\def\deliv@id{#1}}
\define@key{deliv}{due}{\def\deliv@due{#1}}
\define@key{deliv}{dissem}{\def\deliv@dissem{#1}}
\define@key{deliv}{nature}{\def\deliv@nature{#1}}
\define@key{deliv}{miles}{\def\deliv@miles{#1}}
\define@key{deliv}{short}{\def\deliv@short{#1}}
\define@key{deliv}{lead}{\def\deliv@lead{#1}}
\define@key{deliv}{issue}{\def\deliv@issue{#1}}
\newcounter{deliverable}
\newcommand{\wpg@deliv}[3]{% keys, title, type
\stepcounter{deliverable}
\let\deliv@miles=\relax% clean state
\def\@type{#3}\def\@wp{wp}% set up ifx
\def\wpg@id{\csname #3@id\endcsname}
\setkeys{deliv}{#1}\stepcounter{deliv}% set state
\ifx\@type\@wp\def\current@label{\deliv@label{\ifwork@areas\thewa.\fi\thewp.\thedeliv}}
\else\def\current@label{\deliv@label{\thewa.\thedeliv}}\fi
\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{label}{\current@label}
\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{title}{#2}
\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{page}{\thepage}%
\@ifundefined{deliv@short}
{\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{short}{#2}}
{\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{short}{\deliv@short}}
\@ifundefined{deliv@nature}
{\protect\G@refundefinedtrue\@latex@warning{key 'nature' for Deliv \wpg@id undefined}}
{\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{nature}{\deliv@nature}}
\@ifundefined{deliv@dissem}
{\protect\G@refundefinedtrue\@latex@warning{key 'dissem' for Deliv \wpg@id undefined}}
{\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{dissem}{\deliv@dissem}}
\@ifundefined{deliv@lead}
{\protect\G@refundefinedtrue\@latex@warning{key 'lead' for Deliv \wpg@id undefined}}
{\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{lead}{\deliv@lead}}
\@ifundefined{deliv@due}{}{%
\@ifundefined{deliv@issue}{}{\pdata@def{deliv}{\taskin\deliv@id\wpg@id}{issue}{\deliv@issue}}
\@for\@I:=\deliv@due\do{\protected@write\wpg@delivs{}{\string\deliverable%
{\ifnum\@I<10 0\@I\else\@I\fi}% sort key
{\@I}% due date
{\current@label}% label
{\@ifundefined{deliv@id}{??}{\taskin\deliv@id\wpg@id}}% id
{\@ifundefined{deliv@dissem}{??}{\deliv@dissem}}% dissemination level
{\@ifundefined{deliv@nature}{??}{\deliv@nature}}% nature
{#2}
{\ifx\@type\@wp{WP\ifwork@areas\thewa.\fi\thewp}\else{WA\thewa}\fi}%WP
{\@ifundefined{deliv@lead}{??}{\string\site{\deliv@lead}}}}}}% lead
\item[\current@label\ (%
\delivs@legend@due: \@ifundefined{deliv@due}{??}{\deliv@due},
\delivs@legend@nature: \@ifundefined{deliv@nature}{??}{\deliv@nature},
\delivs@legend@dissem: \@ifundefined{deliv@dissem}{??}{\deliv@dissem},
\delivs@legend@lead: \@ifundefined{deliv@lead}{??}{\site{\deliv@lead}})]
\pdata@target{deliv}{\taskin\deliv@id\wpg@id}{\textit{#2}}
\@ifundefined{deliv@miles}{}{% print the milestones and update their deliverables
\let\m@sep=\relax% do not print the separator the first time round
\lec{\@for\@I:=\deliv@miles\do{% Iterate over the milestones mentioned
\m@sep\pdataRef{mile}{\@I}{label}% print the milestone reference
\let\m@sep=,}}%set the separator for the next times
\def\d@sep{,}
\@for\@I:=\deliv@miles\do{% Iterate over the milestones mentioned
\expandafter\ifx\csname\@I delivs\endcsname\relax% Check that the miles@delivs is empty
{\expandafter\xdef\csname\@I delivs\endcsname{\wpg@id @\deliv@id}}% if so, skip the separator
\else\expandafter\xdef\csname\@I delivs\endcsname%if not add it
{\csname\@I delivs\endcsname\d@sep\wpg@id @\deliv@id}\fi}}}
\newenvironment{wadeliv}[2][]{\ifdelivs\wpg@deliv{#1}{#2}{wa}\else\deliv@error\fi}{}
\newenvironment{wpdeliv}[2][]{\ifdelivs\wpg@deliv{#1}{#2}{wp}\else\deliv@error\fi}{}
\newcommand\milestone@label[1]{M{#1}}
\newcommand\mileref[1]{\pdataRef{mile}{#1}{label}}
\newcommand\miletref[1]{\mileref{#1}: \pdataRefFB{mile}{#1}{short}{title}}
\newcounter{milestone}
\define@key{milestone}{id}{\gdef\mile@id{#1}}
\define@key{milestone}{month}{\gdef\mile@month{#1}}
\newcommand\milestone[3][]{%
\ifdelivs%
\setkeys{milestone}{#1}\stepcounter{milestone}%
\pdata@def{mile}\mile@id{label}{\milestone@label{\themilestone}}%
\pdata@def{mile}\mile@id{month}{\mile@month}%
\pdata@def{mile}\mile@id{title}{#2}%
\pdata@def{mile}\mile@id{description}{#3}%
\@ifundefined{mile@stones}%
{\xdef\mile@stones{\mile@id}}%
{\xdef\mile@stones{\mile@stones,\mile@id}}%
\@milestone{\mile@id}{#2}{#3}% presentation
\else\deliv@error\fi}
\newcommand\@milestone[3]{% id, title, description
\item \textbf{\miles@legend@milestone\xspace\pdata@target{mile}\mile@id{\pdataref{mile}{#1}{label}}
(\miles@legend@month \pdataref{mile}\mile@id{month})
\textbf{#2}} #3}
\newcommand\miles@legend@month{Month}
\newcommand\miles@legend@milestone{Milestone}
\newenvironment{milestones}%
{\ifdelivs\begin{@milestones}\else\deliv@error\fi}
{\ifdelivs\pdata@def{all}{mile}{ids}{\mile@stones}%
\pdata@def{all}{mile}{count}{\themilestone}%
\end{@milestones}\fi}
\newenvironment{@milestones}{\begin{enumerate}}{\end{enumerate}}
\newcommand{\deliverable}[9]{\pdataRef{deliv}{#4}{label}&#7&#8&#9&#6&#5&#2\\\hline}%sortkey,due,label,id,title,type,level,lead
\newenvironment{deliverables}[1]{\ifdelivs\begin{longtable}{|l|p{#1}|l|l|l|l|l|}\hline%
\#&\textbf{\delivs@legend@name}&%
\textbf{\delivs@legend@wp}&%
\textbf{\delivs@legend@lead}&%
\textbf{\delivs@legend@nature}&%
\textbf{\delivs@legend@level}&%
\textbf{\delivs@legend@due}\\\hline\hline%
\endhead%
\else\deliv@error\fi}
{\ifdelivs\end{longtable}\fi}
\newcommand\delivs@legend@name{Deliverable name}
\newcommand\delivs@legend@wp{WP}
\newcommand\delivs@legend@nature{Type}
\newcommand\delivs@legend@level{Level}
\newcommand\delivs@legend@due{Due}
\newcommand\delivs@legend@dissem{Dissem.}
\newcommand\delivs@legend@lead{Lead}
\newcommand{\inputdelivs}[1]{%
\begin{deliverables}{#1}%
\IfFileExists{\jobname.deliverables}%
{\input{\jobname.deliverables}}%
{\IfFileExists{\jobname.delivs}{\input{\jobname.delivs}}{}}
\end{deliverables}}
2014-02-15 12:01:14 +01:00
\newif\ifwork@areas\work@areastrue
\DeclareOption{noworkareas}{\work@areasfalse}
\ProcessOptions
\RequirePackage{xspace}
\newwrite\pdata@out
\newcommand\pdata@open[1]{\immediate\openout\pdata@out=#1.pdata}
\newcommand\pdata@close{\closeout\pdata@out}
\newcommand\readpdata[1]{\IfFileExists{#1.pdata}
{\message{proposal: Reading Project Data}\makeatletter\input{#1.pdata}\makeatother}
{proposal: No Project Data found, (forward) references may be compromized}}
\newcommand\pdata@target[3]{\hypertarget{#1@#2@target}{#3}}
\newcommand\pdata@def[4]{%\@pdata@def{#1}{#2}{#3}{#4}%
\protected@write\pdata@out{}{\string\@pdata@def{#1}{#2}{#3}{#4}}}
\newcommand\@pdata@def[4]{\expandafter\gdef\csname #1@#2@#3\endcsname{#4}}
\newcommand\pdataref[3]{\@ifundefined{#1@#2@#3}%
{\protect\G@refundefinedtrue\@latex@warning{#3 for #1 #2 undefined}??}%
{\csname #1@#2@#3\endcsname}}%
\newcommand\pdataref@aux[3]{\@ifundefined{#1@#2@#3}{??}{\csname #1@#2@#3\endcsname}}%
\newcommand\pdataref@num[3]{\@ifundefined{#1@#2@#3}{0}{\csname #1@#2@#3\endcsname}}%
\newcommand\pdataref@safe[3]{\@ifundefined{#1@#2@#3}{}{\csname #1@#2@#3\endcsname}}%
\newcommand\pdatarefFB[4]{\@ifundefined{#1@#2@#3}%
{\@ifundefined{#1@#2@#4}%
{\protect\G@refundefinedtrue\@latex@warning{both #3 and its fallback #4 undefined for #1 #2}??}%
{\csname #1@#2@#4\endcsname}}
{\csname #1@#2@#3\endcsname}}
2014-02-15 12:01:14 +01:00
\newcommand\pdataRef[3]{\@ifundefined{#1@#2@#3}%
{\protect\G@refundefinedtrue\@latex@warning{#3 for #1 #2 undefined}??}%
{\hyperlink{#1@#2@target}{\csname #1@#2@#3\endcsname}}}
\newcommand\pdataRefFB[4]{\@ifundefined{#1@#2@#3}%
{\@ifundefined{#1@#2@#4}%
{\protect\G@refundefinedtrue\@latex@warning{both #3 and its fallback #4 undefined for #1 #2}??}%
{\hyperlink{#1@#2@target}{\csname #1@#2@#4\endcsname}}}
{\hyperlink{#1@#2@target}{\csname #1@#2@#3\endcsname}}}
2014-02-15 12:01:14 +01:00
\newcommand\prop@count[1]{\ifcase #1 zero\or one\or two\or three\or four\or five\or six\or seven \or
eight\or nine\or ten\or eleven \or twelve\else#1\fi}
\newcommand\pdatacount[2]{\prop@count{\pdataref@num{#1}{#2}{count}}}
\newcommand\pn{\pdataref{prop}{gen}{acronym}\xspace}
\newcommand\pnlong{\pdataref{prop}{gen}{acrolong}\xspace}
\newcommand\WPref[1]{\pdataRef{wp}{#1}{label}}
\newcommand\WPtref[1]{\WPref{#1}: \pdataRefFB{wp}{#1}{short}{title}}
2014-02-15 12:01:14 +01:00
\ifwork@areas
\newcommand\WAref[1]{\pdataRef{wa}{#1}{label}}
\newcommand\WAtref[1]{\WAref{#1}: \pdataRefFB{wa}{#1}{short}{title}}
2014-02-15 12:01:14 +01:00
\fi
\newcommand{\signatures}[1]{\section{#1}
\qquad\number\day. \number\month. \number\year\\[6ex]
\strut\qquad Date\hfill\@for\@p:=\prop@gen@PIs\do{%
2016-07-06 10:35:37 +02:00
\wa@ref3{person}\@p{personaltitle}~\wa@ref3{person}\@p{name}\hfill}}
2014-02-15 12:01:14 +01:00
\def\@dmp#1{\ifkeys\marginpar{#1}\fi}
\renewcommand\euro{\officialeuro\xspace}
\endinput
%%
%% End of file `pdata.sty'.