% \iffalse meta-comment
% A class for preparing FP7 proposals for collaborative projects
%
% Copyright (c) 2011 Michael Kohlhase, all rights reserved
%
% This file is distributed under the terms of the LaTeX Project Public
% License from CTAN archives in directory  macros/latex/base/lppl.txt.
% Either version 1.0 or, at your option, any later version.
%
% The development version of this file can be found at
% https://github.com/KWARC/LaTeX-proposal
% \fi
% 
% \iffalse
%<cls|pdata|reporting>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<cls>\ProvidesClass{euproposal}[2020/08/21 v1.7 EU Proposal]
%<pdata>\ProvidesPackage{eupdata}[2020/08/21 v1.7 EU Project Data]
%<reporting>\ProvidesPackage{eureporting}[2020/08/21 v1.7 EU Project Reporting]
%<*driver>
\documentclass[twoside]{ltxdoc}
\DoNotIndex{\def,\long,\edef,\xdef,\gdef,\let,\global}
\DoNotIndex{\begin,\AtEndDocument,\newcommand,\newcounter,\stepcounter}
\DoNotIndex{\immediate,\openout,\closeout,\message,\typeout}
\DoNotIndex{\section,\scshape,\arabic}
\EnableCrossrefs
%\CodelineIndex
%\OnlyDescription
\RecordChanges
\usepackage{textcomp,url,paralist,a4wide,xspace}
\usepackage[show]{ed}
\usepackage[maxbibnames=6,hyperref=auto,style=alphabetic,backend=bibtex]{biblatex}
\addbibresource{../lib/proposal.bib}
\usepackage[bookmarks=true,linkcolor=blue,
 citecolor=blue,urlcolor=blue,colorlinks=true,
 breaklinks=true, bookmarksopen=true]{hyperref}
\makeindex
\newcommand\subversion{\textsc{Subversion}\xspace}
\begin{document}
\DocInput{euproposal.dtx}
\end{document}
%</driver>
% \fi
% 
%\iffalse\CheckSum{639}\fi
% 
% \changes{v0.1}{2007/05/07}{used in the SciML proposal}
% \changes{v0.2}{2007/05/09}{First Version with Documentation}
% \changes{v0.3}{2007/06/04}{staff effort table finally works, released}
% \changes{v0.3a}{2008/01/18}{error corrections and more documentation}
% \changes{v1.3}{2011/05/18}{basing this on proposal.cls}
% \changes{v1.4}{2012/01/18}{various tweaks for the Jan 2012 proposal deadline}
% \changes{v1.4}{2015/01/14}{lots of tweaks}%
% \changes{v1.5}{2020/08/21}{removing dependency on workaddress}
% \GetFileInfo{euproposal.cls}
% 
% \MakeShortVerb{\|}
% \title{Preparing FP7 EU Proposals and Reports in {\LaTeX} with \texttt{euproposal.cls}}
%    \author{Michael Kohlhase\\
%      Computer Science, Jacobs University Bremen\\
%      \url{http://kwarc.info/kohlhase}}
% \maketitle
%
% \begin{abstract}
%   The |euproposal| class supports many of the specific elements of a Framework 7
%   Proposal. It is optimized towards collaborative projects. The package comes with an
%   extensive example (a fake EU proposal) that shows all elements in action. 
% \end{abstract}
% 
% \tableofcontents\newpage
%
% \section{Introduction}\label{sec:intro}
%
%   Writing grant proposals is a collaborative effort that requires the integration of
%   contributions from many individuals. The use of an ASCII-based format like {\LaTeX}
%   allows to coordinate the process via a source code control system like
%   \subversion, allowing the proposal writing team to concentrate on the contents
%   rather than the mechanics of wrangling with text fragments and revisions. 
% 
%   The |euproposal| class extends the |proposal| class~\cite{Kohlhase:pplp:svn} and
%   supports many of the specific elements of Part B of a Framework 7 Proposal. The
%   package documentation is still preliminary, fragmented and incomplete and only dwells
%   on the particulars of DFG proposals, so we treat~\cite{Kohlhase:pplp:svn} as a
%   prerequisite. Please consult the example proposal |propB.tex|, which comes with the
%   package and shows the usage of the class in action. It is intended as a template for
%   your proposal, but please bear in mind that the EU guidelines may change from call to
%   call, if in doubt, please consult the FP7 guide for proposers.\ednote{say something
%   about the proposers guide.}
%
%   The |eureporting| class supports most of the specific elements of the project reports
%   to the EC. The example report |dfg/report.tex| is intended as a template for your
%   final report\ednote{say something about reporting}.
%
%   The |euproposal| and |eureporting| classes and the |eupdata| package are distributed
%   under the terms of the LaTeX Project Public License from CTAN archives in directory
%   macros/latex/base/lppl.txt.  Either version 1.0 or, at your option, any later
%   version. The CTAN archive always contains the latest stable version, the development
%   version can be found at \url{https://github.com/KWARC/LaTeX-proposal}. For bug reports
%   please use the sTeX TRAC at \url{https://github.com/KWARC/LaTeX-proposal/issues}.
%   
% \section{The User Interface}\label{sec:user-interface}
% 
% In this section we will describe the functionality offered by the |euproposal| class
% along the lines of the macros and environments the class provides. Much of the
% functionality can better be understood by studying the functional example |proposal.tex|
% (and its dependents) that comes with the |euproposal| package in conjunction with the
% proposer's EU proposer's guidelines (we have included it as |***| for convenience into
% the package distribution).\ednote{MK@MK do that and talk about reporting as well.}
% 
% \subsection{Package Options}\label{sec:user:options}
%
% As usual in {\LaTeX}, the package is loaded by
% |\documentclass[|\meta{options}|]{euproposal}|, where |[|\meta{options}|]| is optional
% and gives a comma separated list of options specified in~\cite{Kohlhase:pplp:svn}.  Some
% versions EU proposals want non-standard numbering schemes (e.g. starting with
% \textbf{B...} since we are writing Part B.), this can be reached by giving the |partB|
% option. Finally the |split| option cases the |euproposal| to write a file |SPLIT.at|
% that can be used in the |Makefile| to split the final proposal |final.pdf| into a files
% |final123.pdf| and |final45.pdf| for submission in the EU system (often this has to be
% separated so that the submission system can count pages.)
% 
% \subsection{Proposal Metadata and Title page}\label{sec:user:metadata}
% 
% The metadata of the proposal is specified in the \DescribeEnv{proposal}|proposal|
% environment, which also generates the title page and the first section of the proposal
% as well as the last pages of the proposal with the signatures, enclosures, and
% references. The |proposal| environment should contain all the mandatory parts of the
% proposal text. The |proposal| environment uses the following EU-specific keys to
% specify metadata.
% \begin{compactitem}
% \item \DescribeMacro{callname}|callname| specifies the call the proposal addresses. It is
%   usually a string of the form |ICT Call 1|, \DescribeMacro{callid}|callid| is the
%   corresponding identifier, usually a string of the form |FP7-???-200?-?|. An overview
%   over open calls can be found at \url{http://cordis.europa.eu/fp7/dc/index.cfm}
% \item The \DescribeMacro{challenge}|challenge|, \DescribeMacro{objective}|objective|,
%   and \DescribeMacro{outcome}|outcome| keys specifies the specific parts in the call
%   this proposal addresses. These are specified in the ``call fiche'' that can be
%   obtained from the URL above. All of these have an identifier, which can be specified
%   via the \DescribeMacro{challengeid}|challengeid|,
%   \DescribeMacro{objectiveid}|objectiveid|, and \DescribeMacro{outcomeid}|outcomeid|
%   keys.\ednote{MK@MK: the outcomeid should key should be a list key, I am not
%   implementing this right now, since it comes more natural when we change the class to
%   metakeys support.}
% \item \DescribeMacro{topicsaddressed}|topicsaddressed| allows to enter free-form text
%   instead of specifying the |challenge*|, |objective*|, and |outcome*| keys.
% \item The \DescribeMacro{coordinator}|coordinator| key full name of the proposal
%   coordinator. 
% \item The \DescribeMacro{Csite}|Csite|, \DescribeMacro{Cemail}|Cemail|, and
%   \DescribeMacro{Ctelfax}|Ctelfax| keys give further metadata of the coordinator (for
%   the table).
% \item If given, the \DescribeMacro{iconrowheight}|iconrowheight| key instructs the
%   |euproposal| class to make a line with the logos of the participants at the bottom of
%   the title page, and specify their heights; |1.5cm| is often a good value.
% \end{compactitem}
% 
% \subsection{Work Packages and Work Areas}\label{sec:user:wpwa}
% 
% \DescribeMacro{type} The |type| key specifies the activity type of the work package:
% |RTD| = Research and technological development (including any activities to prepare for
% the dissemination and/or exploitation of project results, and coordination activities);
% |DEM| = Demonstration; |MGT| = Management of the consortium; |OTHER| = Other specific
% activities, if applicable in this call.
%
% \subsection{Milestones and Deliverables}\label{sec:user:deliverables}
% 
% |euproposal.cls| adds the \DescribeMacro{verif}|verif| key to \DescribeMacro{\milestone}
% for specifying a means of verification that the milestone has been successful.
% 
% With this, we can generate the milestone table that is required in many EU
% proposals. This can simply be done via the
% \DescribeMacro{\milestonetable}|\milestonetable| macro. It takes a keyword argument with
% the keys \DescribeMacro{caption}|caption| for specifying a different caption, and the
% widths \DescribeMacro{wname}|wname|, \DescribeMacro{wdeliv}|wdeliv|, and
% \DescribeMacro{wverif}|wverif| that can be used to specify different widths for the
% name/deliverables/verification columns in the milestone table.
% 
% \subsection{Risks}\label{sec:user:risks}
% In some EU proposals (e.g. FET), we need to identify risks and contingency and specify
% mitigation plans for them. In the |euproposal| we use two environments to mark them up.
% 
% \DescribeMacro{risk}|\begin{risk}{|\meta{title}|}{|\meta{prob}|}{|\meta{grav}|}|\ldots|\end{risk}|
% makes a paragraph no a risk \meta{title} with gravity \meta{grav} and probability
% \meta{prob}, where the body of the environment contains a description of the risk. The
% \DescribeMacro{riskcont}|riskcont| is a variant, where \meta{title} names a risk and the
% body is a description of the contingency plan.
% 
% \subsection{Relevant Papers/Key Publications}\label{sec:user:papers}
% 
% Sometimes we want to list the relevant papers in the site descriptions.  We use the
% |biblatex| package to automate this. We only need to use
% \DescribeMacro{\keypubs}|\keypubs[|\meta{keys}|]{|\meta{refs}|}|, where \meta{keys} that
% specify what papers are selected and \meta{refs} is a comma-separated list of {bib\TeX}
% keys from the bibTeX database used in the proposal.
% 
% The papers listed in |\keypubs| are put into a section bibliography which is displayed
% in place.
% 
%
% \begin{newpart}{MK@MK: This is new, and only partially implemented}
% \subsection{Reporting Infrastructure}\label{sec:user:report}
% 
% The |eureporting| class gives an infrastructure for writing final reports of completed
% projects (see the file |finalreport.tex| in the package distribution). The
% \DescribeEnv{report}|report| environment has functionality analogous to the |proposal|
% environment. It takes the same metadata keys --- making it easy to generate by
% copy/paste from the proposal --- but adds the keys \DescribeMacro{key}|key| can be used
% to specify the reference key (something like \texttt{KO 2428 47-11}) given to the
% project by EU. Note that in the case of multiple proposers, you can use multiple
% instances of |key| to specify more than one reference key.
% \end{newpart}
% 
% \subsection{The Grant Agreement}\label{sec:user:grantagreement}
% 
% EU Proposals reuse large parts of the proposal in the grant agreement -- a part of the
% contract that describes the work and research the consortium has agreed to undertake. We
% can directly can directly generate the the grant agreement from the proposal by
% subsetting and adding some special source files. The |euproposal| class takes the option
% |grantagreement| for this, if this option is given, then a grant agreement is
% generated. This is most simply done by an options trick: We use a macro |\classoptions|
% in the class options in the preamble of the main proposal file |proposal.tex|, e.g. 
% \begin{verbatim}
% \providecommand{\classoptions}{keys}
% \documentclass[noworkareas,deliverables,\classoptions]{proposal}
% ... 
% \end{verbatim}
% and then we can just make a new file |grantagreement.tex| of the form 
% \begin{verbatim}
% \newcommand{\classoptions}{submit,grantagreement}
% \input{proposal.tex}
% \end{verbatim}
% that amounts to running |proposal.tex| with different options.
% 
% \section{Limitations and Enhancements}\label{sec:limitations}
% 
% The |euproposal| is relatively early in its development, and many enhancements are
% conceivable. We will list them here.
% \begin{enumerate}
% \item none reported yet. 
% \end{enumerate}
% If you have other enhancements to propose or feel you can alleviate some limitation,
% please feel free to contact the author. 
%
% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\newpage\printbibliography}\newpage
%
% \section{The Implementation}\label{sec:implementation}
%
% In this section we describe the implementation of the functionality of the |euproposal|
% and |eureporting| classes and the |eupdata| package. 
%
% \subsection{Package Options and Format Initialization}\label{sec:impl:options}
% 
% We first set up the options for the package. 
% 
%    \begin{macrocode}
%<*cls>
\newif\ifpartB\partBfalse
\DeclareOption{partB}{\partBtrue}
\newif\if@split\@splitfalse
\DeclareOption{split}{\@splittrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{proposal}}
%</cls>
%<reporting>\DeclareOption*{\PassOptionsToClass{\CurrentOption}{reporting}}
%<cls|reporting>\ProcessOptions
%    \end{macrocode}
%
%    Then we load the packages we make use of
% 
%    \begin{macrocode}
%<cls>\ifpartB\LoadClass[report]{proposal}\else\LoadClass{proposal}\fi
%<reporting>\LoadClass[report]{reporting}
%<*cls|reporting>
\RequirePackage{longtable}
\RequirePackage{eurosym}
\RequirePackage{wrapfig}
\RequirePackage{eupdata}
\RequirePackage{datetime}
%    \end{macrocode}
% we want to change the numbering of figures and tables
%    \begin{macrocode}
\RequirePackage{chngcntr}
\counterwithin{figure}{subsection}
\counterwithin{table}{subsection}
%    \end{macrocode}
%    And finally, we set the section numbering depth, so that paragraphs are numbered and
%    can be cross-referenced.
%    \begin{macrocode}
\setcounter{secnumdepth}{4}
%</cls|reporting>
%    \end{macrocode}
%
% \subsection{Proposal Metadata and Title Page}\label{sec:impl:metadata}
%  
% We extend the metadata keys from the |proposal| class.
%    \begin{macrocode}
%<*pdata>
\define@key{prop@gen}{coordinator}{\def\prop@gen@coordinator{#1}\pdata@def{prop}{gen}{coordinator}{#1}}
\define@key{prop@gen}{Csite}{\def\prop@gen@Csite{#1}\pdata@def{prop}{gen}{Csite}{#1}}
\define@key{prop@gen}{Cemail}{\def\prop@gen@Cemail{#1}\pdata@def{prop}{gen}{Cemail}{#1}}
\define@key{prop@gen}{Ctelfax}{\def\prop@gen@Ctelfax{#1}\pdata@def{prop}{gen}{Ctelfax}{#1}}
\def\prop@gen@challenge{??}\def\prop@gen@challengeid{??}
\define@key{prop@gen}{challenge}{\def\prop@gen@challenge{#1}\pdata@def{prop}{gen}{challenge}{#1}}
\define@key{prop@gen}{challengeid}{\def\prop@gen@challengeid{#1}\pdata@def{prop}{gen}{challengeid}{#1}}
\def\prop@gen@objective{??}\def\prop@gen@objectiveid{??}
\define@key{prop@gen}{objective}{\def\prop@gen@objective{#1}\pdata@def{prop}{gen}{objective}{#1}}
\define@key{prop@gen}{objectiveid}{\def\prop@gen@objectiveid{#1}\pdata@def{prop}{gen}{objectiveid}{#1}}
\def\prop@gen@outcome{??}\def\prop@gen@outcomeid{??}
\define@key{prop@gen}{outcome}{\def\prop@gen@outcome{#1}\pdata@def{prop}{gen}{outcome}{#1}}
\define@key{prop@gen}{outcomeid}{\def\prop@gen@outcomeid{#1}\pdata@def{prop}{gen}{outcomeid}{#1}}
\define@key{prop@gen}{callname}{\def\prop@gen@callname{#1}\pdata@def{prop}{gen}{callname}{#1}}
\define@key{prop@gen}{callid}{\def\prop@gen@callid{#1}\pdata@def{prop}{gen}{callid}{#1}}
\define@key{prop@gen}{iconrowheight}{\def\prop@gen@iconrowheight{#1}}
\define@key{prop@gen}{topicsaddressed}{\def\prop@gen@topicsaddressed{#1}}
%</pdata>
%    \end{macrocode}
%
% and now the ones for the final report 
%    \begin{macrocode}
%<*reporting>
\define@key{prop@gen}{reportperiod}{\def\prop@gen@reportperiod{#1}}
\define@key{prop@gen}{key}{\@dmp{key=#1}%
\@ifundefined{prop@gen@keys}{\xdef\prop@gen@keys{#1}}{\xdef\prop@gen@keys{\prop@gen@keys,#1}}}
\define@key{prop@gen}{projpapers}{\def\prop@gen@projpapers{#1}}
%</reporting>
%    \end{macrocode}
% 
% and the default values, these will be used, if the author does not specify something
% better.
%
% If the |partB| option is given, we need to redefine some of the internal counters and
% table of contents mechanisms to adapt to the fact that the proposal text is just Part B.
%
%    \begin{macrocode}
%<*cls>
\ifpartB
\def\thepart{\Alph{part}}
\setcounter{part}{2}
\def\thechapter{\thepart.\arabic{chapter}}
\def\numberline#1{\hb@xt@\@tempdima{#1\hfil} }
\fi% ifpartB 
%    \end{macrocode}
% 
% \begin{macro}{\prop@sites@table}
%    \begin{macrocode}
\newcommand\prop@sites@table{\def\@@table{}
{\let\tabularnewline\relax\let\hline\relax
\@for\@I:=\prop@gen@sites\do{\xdef\@@table{\@@table\pdataref@safe{site}\@I{number}}
\xdef\@@table{\@@table&\pdataref@safe{site}\@I{shortname}\ifx\@I\prop@gen@coordinatorsite (coordinator)\fi}
\xdef\@@table{\@@table&\pdataref@safe{site}\@I{acronym}}
\xdef\@@table{\@@table&\pdataref@safe{site}\@I{countryshort}\tabularnewline\hline}}}
\begin{tabular}{|l|p{8cm}|l|l|}\hline%|
\# & Participant organisation name & Short name &  Country\\\hline\hline
\@@table
\end{tabular}}
%    \end{macrocode}
% \end{macro}
% 
% \begin{environment}{prop@proposal}
%    \begin{macrocode}
\renewenvironment{prop@proposal}
{\ifgrantagreement\else
  \thispagestyle{empty}\begin{center}
  {\Large \prop@gen@instrument}\\[.2cm]
  {\Large\textbf\prop@gen@callname}\\[.4cm]
  {\LARGE \prop@gen@callid}\\[.8cm]
  {\huge\textbf\prop@gen@title}\\[.4cm]
  \ifx\prop@gen@acronym\@empty\else{\LARGE Acronym: {\prop@gen@acronym}}\\[2cm]\fi
\end{center}
%{\large\prop@gen@instrument}\\
{\large\textbf{Date of Preparation: \today: \currenttime}}
% \ifsubmit\else\if@svninfo\if@gitinfo\\
% {\large\textbf{Revision}: 
% \if@svninfo\svnInfoRevision\fi\if@gitinfo\gitAbbrevHash\fi
%  of 
% \if@svninfo\svnInfoDate\fi\if@gitinfo\gitAuthorDate\fi}
% \fi\fi\fi
\\[1em]
\begin{large}
 \begin{description}
  % \item[Work program topics addressed by \pn:]
  %   \@ifundefined{prop@gen@topicsaddressed}
  %   {\textbf{Challenge \prop@gen@challengeid}: \prop@gen@challenge,
  %   \textbf{Objective \prop@gen@objectiveid}: \prop@gen@objective,
  %   \textbf{target outcome \prop@gen@outcomeid}) \prop@gen@outcome.
  %   {\prop@gen@topicsaddressed}\\[1em]
  \item[Coordinator:] \prop@gen@coordinator
  \item[e-mail:] \prop@gen@Cemail
  \item[tel/fax:] \prop@gen@Ctelfax
    \@ifundefined{prop@gen@keywords}{}{\item[Keywords:]  \prop@gen@keywords}
  \end{description}
\end{large}
\vspace*{1em}
\begin{center}
\prop@sites@table\vfill
\@ifundefined{prop@gen@iconrowheight}{}
{\@for\@site:=\prop@gen@sites\do{\includegraphics[height=\prop@gen@iconrowheight]{\pdataref@safe{site}\@site{logo}}\qquad}}
\end{center}
\newpage
\fi% ifgrantagreement
\setcounter{tocdepth}{2}\setcounter{part}{2}}
{\newpage\printbibliography[heading=warnpubs]%
\if@split
\newwrite\@@SPLIT%
\immediate\openout\@@SPLIT=SPLIT.at%
\protected@write\@@SPLIT{}{\thepage}%
\closeout\@@SPLIT%
\fi}% if@split  
%    \end{macrocode}
% \end{environment}
% 
%    \begin{macrocode}
\def\prop@gen@instrument{Proposal Instrument (e.g. IP)}
%    \end{macrocode}
%
% \subsection{Site Descriptions}\label{sec:sitedesc}
% \ednote {this functionality should probably be refactored into proposal.dtx}
%
% \begin{environment}{sitedescription}
%   \ednote{document this above} |\begin{sitedescritpion}[|\meta{opt}|]{\meta{site}}|
%     marks up the description for the site \meta{site}. The options argument \meta{opt}
%     is a key-value list for the keys \DescribeMacro{logo}|logo| (add the logo from
%     |\WAinstitution| to the site description), \DescribeMacro{width}|width|,
%     \DescribeMacro{height}|height| (intended dimensions of the logo), \ednote{more?}.
%    \begin{macrocode}
\define@key{site@desc}{box}[true]{\def\site@desc@box{#1}%
\pdata@def{sitedesc}{\@site}{box}{#1}}
\define@key{site@desc}{logo}[true]{\def\site@desc@logo{#1}%
\pdata@def{sitedesc}{\@site}{logo}{#1}}
\define@key{site@desc}{width}{\def\site@desc@width{#1}%
\pdata@def{sitedesc}{\@site}{width}{#1}\@dmp{wd=#1}}
\define@key{site@desc}{height}{\def\site@desc@height{#1}%
\pdata@def{sitedesc}{\@site}{height}{#1}\@dmp{ht=#1}}
\newenvironment{sitedescription}[2][]%
{\def\c@site{#2}% remember the site ID
\newcounter{site@#2@PM} % for the site PM
\def\site@desc@box{false}% not box unless requested
\def\site@desc@logo{false}% not logo unless requested
\def\site@desc@height{1.3cm}% default height
\def\site@desc@width{5cm}% default width
\setkeys{site@desc}{#1}% read the keys to overwrite the defaults
\ifx\@site@desc@box\@true% if we want a logo
\begin{wrapfigure}{r}{\site@desc@width}\vspace{-2.5ex}%
\begin{tabular}{|p{\site@desc@width}|}\hline\vspace{1mm}%
\ifx\@site@desc@logo\@true% if we want a logo
\includegraphics[height=\site@desc@width]{#2}\\[1ex]%
\fi% end logo
\textbf{\pdataref@safe{site}{#2}{type}.\hfill \pdataref@safe{site}{#2}{country}}\\%
\small\pdataref@safe{site}{#2}{streetaddress}, \pdataref@safe{site}{#2}{townzip}\\\hline%
\end{tabular}\vspace{-2.5ex}%
\end{wrapfigure}%
\fi% end box
\pdata@target{site}{#2}%
{\subsubsection{\pdataref@safe{site}{#2}{acronym}: % space here
{\textsc{\pdataref@safe{site}{#2}{shortname}}  (\pdataref@safe{site}{#2}{countryshort})}}}%
\small%
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {0.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}}
{\pdata@def{site}{\c@site}{reqPM}{\csname thesite@\c@site @PM\endcsname}}
%    \end{macrocode}
% \end{environment}
% 
% \begin{environment}{participant}
%   \ednote{document this above} |\begin{picv}[|\meta{PM}|]{\meta{name}}| marks up the CV
%     and metadata about a principal investigator of a site (it can only be use inside a
%     |sitedescription| environment). The first argument \meta{PM} specifies the
%     involvement in person months: a fair estimation this PI will spend on this specific
%     project over its whole duration.
%    \begin{macrocode}
\define@key{site@part}{type}{\def\site@part@type{#1}\@dmp{type=#1}}
\define@key{site@part}{PM}{\def\site@part@PM{#1}\@dmp{PM=#1}}
\define@key{site@part}{salary}{\def\site@part@salary{#1}}%\@dmp{\euro=#1}}
\define@key{site@part}{gender}{\def\site@part@gender{#1}}%\@dmp{\euro=#1}}
\newenvironment{participant}[2][]%
{\def\site@part@type{}\def\site@part@PM{}\def\site@part@salary{}\def\site@part@gender{}%
\setkeys{site@part}{#1}%
\ifx\site@part@PM\@empty\else\addtocounter{site@\c@site @PM}{\site@part@PM}\fi%
\paragraph*{#2\ %
(\ifx\site@part@type\@empty\else\site@part@type\fi%
\ifx\site@part@gender\@empty\else, \site@part@gender\fi%
\ifx\site@part@PM\@empty\else, \site@part@PM~PM\fi%
)}%
\ignorespaces}
{\par\medskip}
%    \end{macrocode}
% \end{environment}
% 
% \subsection{Work Packages, Work Areas, and Deliverables}\label{sec::impl:wpwa}
%
% \begin{environment}{wp*}
%    \begin{macrocode}
\newmdenv[frametitle=Objectives]{wpobjectives}
\newmdenv[frametitle=Description]{wpdescription}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{workpackage}
%    
%    \begin{macrocode}
\renewenvironment{workpackage}[1][]
{\begin{work@package}[#1]\medskip\wpheadertable%
\addcontentsline{toc}{subsubsection}{\wp@label\wp@num: \pdataref{wp}\wp@id{title}}}
{\end{work@package}}
%    \end{macrocode}
% \end{environment}
% 
% \begin{macro}{\wpheadertable}
%   We redefine the macro that computes the default work package header table, since there
%   are more sites in a EU proposal, we do this in a tabular form as asked for in the
%   template. We use the internal counter |@sites@po| (sites plus one) for convenience.
%    \begin{macrocode}
\newcounter{@sitespo}\newcounter{@sitespt}
\renewcommand\wpheadertable{%
\wp@sites@efforts@lines%
\setcounter{@sitespo}{\thewp@sites@num}\addtocounter{@sitespo}{1}%
\par\noindent\begin{tabular}{|l|*{\thewp@sites@num}{c|}c|}\hline%
\multicolumn{\the@sitespo}{|l|}{\textbf{\wp@mk@title{\wp@num}: }%
\textsf{\pdata@target{wp}{\wp@id}{\pdataref{wp}\wp@id{title}}}}
&\textbf{Start: }\pdataref{wp}\wp@id{start}\\\hline%
\wp@sites@line\\\hline%
\wp@efforts@line\\\hline%
\end{tabular}\smallskip\par\noindent\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Milestones and Deliverables}\label{sec:impl:deliverables}
%
% \begin{environment}{wpdelivs}
%   We make the deliverables boxed in EU proposals, this is simple with |mdframed.sty|.
%    \begin{macrocode}
\surroundwithmdframed{wpdelivs}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\milestone}
%    \begin{macrocode}
\define@key{milestone}{verif}{\gdef\mile@verif{#1}\pdata@def{mile}\mile@id{verif}{#1}}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{milestonetable}
% here we do the work, but only if the file |\jobname.deliverables| exists to make sure
% that the deliverables macros are really defined.
%    \begin{macrocode}
\define@key{mst}{caption}{\gdef\mst@caption{#1}}
\define@key{mst}{wname}{\gdef\mst@wname{#1}}
\define@key{mst}{wdeliv}{\gdef\mst@wdeliv{#1}}
\define@key{mst}{wverif}{\gdef\mst@wverif{#1}}
\newcommand\milestonetable[1][]{%
\IfFileExists{./\jobname.deliverables}{% to avoid errors
\message{euproposal.cls: Generating Milestones Table}%
\def\mst@caption{Milestones, Deliverables, and Verification}%
\def\mst@wname{2.5cm}\def\mst@wdeliv{7cm}\def\mst@wverif{4cm}
\setkeys{mst}{#1}%
{\gdef\mst@lines{}%initialize
\let\tabularnewline\relax\let\hline\relax% so they
\let\textbf\relax\let\emph\relax% do not bother us
\edef\@@miles{\pdataref{all}{mile}{ids}}
\@for\@I:=\@@miles\do{
\edef\@delivs{\pdataref@safe{mile}{\@I}{delivs}}%
\def\@@delivs{}
\@for\@J:=\@delivs\do{\xdef\@@delivs{\@@delivs\ \pdataref{deliv}\@J{label}}}
\def\@@line{
\textbf{\pdataref{mile}\@I{label}}&
\emph{\pdataref{mile}{\@I}{title}} &
\@@delivs&
\pdataref{mile}\@I{month} &
\pdataref{mile}\@I{verif}}
\xdef\mst@lines{\mst@lines\@@line\tabularnewline\hline}}}
\begin{table}[ht]
\begin{tabular}{|l|p{\mst@wname}|p{\mst@wdeliv}|l|p{\mst@wverif}|}\hline
\#&\textbf{\miles@legend@name}
&\textbf{\miles@legend@involved}
&\textbf{\miles@legend@mo}
&\textbf{\miles@legend@verif}\\\hline\hline
\mst@lines
\end{tabular}
\caption{\mst@caption\ ($^\ast$\miles@legend)}\label{tab:milestonetable}
\end{table}}
{\ClassWarning{not formatting mile stones table yet, deliverables are
  still missing; generate\jobname.deliverables\ to get it!}}}
%    \end{macrocode}
% now the multilinguality support 
%    \begin{macrocode}
\newcommand\miles@legend@name{Name}
\newcommand\miles@legend@mo{Mo}
\newcommand\miles@legend@verif{Means of Verif.}
\newcommand\miles@legend@involved{WPs$^\ast$/Deliverables involved}
\newcommand\miles@legend{WP is first number in deliverable label}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\prop@milesfor}
%    the due date is the first argument to facilitate sorting
%    \begin{macrocode}
\newcommand\prop@milesfor[1]{\edef\@delivs{\pdataref@safe{mile}{#1}{delivs}}%
\let\m@sep=\relax\def\new@sep{,\ }%
\@for\@I:=\@delivs\do{\m@sep\pdataRef{deliv}\@I{label}\let\m@sep=\new@sep}}
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Risks}\label{sec:impl:risks}
% 
% \begin{environment}{risk}
%    \begin{macrocode}
\newenvironment{risk}[3]
{\paragraph{Risk: #1}\hfill\emph{probability}: #2, \emph{gravity}: #3\par\noindent\ignorespaces}
{}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{riskcont}
%    \begin{macrocode}
\newenvironment{riskcont}[3]
{\begin{risk}{#1}{#2}{#3}\textbf{Contingency:} }
{\end{risk}}
%    \end{macrocode}
% \end{environment}
%
% \subsection{Relevant Papers}\label{sec:impl:papers}
% 
% \begin{macro}{\keypubs}
% we just use the {bib\LaTeX} |refsection| facility. NOTE, this needs biber to work
% easily.
%    \begin{macrocode}
\newcommand\keypubs[1]{%
\begin{refsection}\nocite{#1}\printbibliography[heading=empty]\end{refsection}}
%</cls>
%    \end{macrocode}
% \end{macro}
%
% \Finale
\endinput
% Local Variables:
% mode: doctex
% TeX-master: t
% End:
%
% LocalWords:  coordinatorsite coordinatorsite verif verif milestonetable milestonetable
%  LocalWords:  wname wname wdeliv wdeliv wverif wverif biblatex notcategory newif gdef
%  LocalWords:  grantagreement Initialization ifpartB partBfalse partBtrue report openout
%  LocalWords:  chngcntr counterwithin ifgrantagreement currenttime mst@caption delivs
%  LocalWords:  initialize deliv multilinguality prop@milesfor refsection nocite doctex
%  LocalWords:  secnumdepth newwrite thepage jobname.deliverables
% LocalWords:  iffalse cls euproposal euproposal.dtx tt maketitle newpage wpwa eudata dfg
% LocalWords:  tableofcontents ednote euproposal DescribeEnv compactitem impl eureporting
% LocalWords:  longtable eurosym pdata thepart setcounter env vfill qquad NeedsTeXFormat
% LocalWords:  thechapter newcommand tabularnewline hline xdef pdataref nameuse SciML gen
% LocalWords:  countryshort rpoposal clange wrapfig wrapfigure vspace bfseries eupdata wd
% LocalWords:  startsection normalfont normalsize baselinestretch callname hb newpart wp
% LocalWords:  countryshort rpoposal clange wrapfig renewenvironment worktelfax prop@gen
% LocalWords:  tocdepth wpobjectives newenvironment noindent boxedminipage fbox warnpubs
% LocalWords:  textwidth textbf wpdescription sitedescription pgfdeclareimage projpapers
% LocalWords:  wrapfigure vspace pgfuseimage streetaddress townzip textsc xt wa maxnames
% LocalWords:  renewcommand startsection normalfont normalsize bfseries wptitle sitedesc
% LocalWords:  workpackage subsubsection wpheadertable newcounter sitespo hfil if@svninfo
% LocalWords:  newcounter sitespt addtocounter textsf smallskip ignorespaces pn setkeys
% LocalWords:  cellcolor lightgray keypubs paperlist callname callid callid ifx csname
% LocalWords:  challengeid challengeid objectiveid objectiveid outcomeid hfill if@gitinfo
% LocalWords:  outcomeid metakeys numberline tempdima ifsubmit iconrowheight
% LocalWords:  proposal.dtx texttt paperslist topicsaddressed thesite mst
%  LocalWords:  topicsaddressed iconrowheight finalreport.tex printbibliography endcsname
%  LocalWords:  reportperiod organisation thispagestyle gitAbbrevHash sitedescritpion WPs
%  LocalWords:  WAinstitution picv medskip newmdenv frametitle wpdelivs mdframed.sty emph
%  LocalWords:  surroundwithmdframed emph riskcont prob grav ldots endinput optimized
