Last active
July 8, 2024 09:39
-
-
Save michaeldorner/33a1e033bf0b8d1c7edd04040d835b76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{pgffor} | |
\usepackage{pgfkeys} | |
\usepackage{ifthen} | |
\pgfkeys{ | |
/contributions/.cd, | |
1/.initial=Conceptualization, | |
2/.initial=Methodology, | |
3/.initial=Software, | |
4/.initial=Validation, | |
5/.initial=Formal Analysis, | |
6/.initial=Investigation, | |
7/.initial=Resources, | |
8/.initial=Data Curation, | |
9/.initial=Writing---original draft, | |
10/.initial=Writing---review \& editing, | |
11/.initial=Visualization, | |
12/.initial=Supervision, | |
13/.initial=Project administration, | |
14/.initial=Funding acquisition, | |
} | |
\def\printcontributionstatement{} | |
\newcommand{\contribution}[2]{% | |
\def\contributor{#1}% | |
\def\indices{#2}% | |
\def\contributions{}% | |
\foreach \index in \indices {% | |
\pgfmathparse{int(\index)}% | |
\ifthenelse{\pgfmathresult > 0 \AND \pgfmathresult < 15}{ | |
\ifx\contributions\empty | |
\xdef\contributions{\pgfkeysvalueof{/contributions/\pgfmathresult}}% | |
\else | |
\xdef\contributions{\contributions, \pgfkeysvalueof{/contributions/\pgfmathresult}}% | |
\fi | |
}{ | |
\PackageError{Contribution Statement Generator}{Contributor \contributor has an illegal contribution index (\pgfmathresult). Use indices 1-14 representing the CRediT roles} | |
} | |
}% | |
\ifx\printcontributionstatement\empty | |
\xdef\printcontributionstatement{\contributor{} (\contributions)}% | |
\else | |
\xdef\printcontributionstatement{\printcontributionstatement, \contributor{} (\contributions)}% | |
\fi | |
% \ifx\printcontributionstatement\empty | |
% \xdef\printcontributionstatement{\noexpand\contributor (\contributions)}% | |
% \else | |
% \xdef\printcontributionstatement{\unexpanded\expandafter{\printcontributionstatement}. \noexpand\contributor (\contributions)}% | |
% \fi | |
} | |
\begin{document} | |
\contribution{Michael Dorner}{1, 2, 4, 6} | |
\contribution{Andreas Bauer}{14} | |
%\contribution{Prof. R}{15} | |
\printcontributionstatement{} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment