-% Tests whether an package is present in a specific version (or newer)
-% Syntax: \TestPackageVersion{<name>}{<yyyy/mm/dd>}
-
-\newcommand{\TestPackageVersion}[2]{
- % The actual test only works if the package has been loaded before
- \IfFileExists{#1.sty}{\RequirePackage{#1}}{}
- \@TestPackageVersion{#1}{#2}
+% Tests whether an package is present and also adds the version to the package list
+\newcommand{\TestPackageAddVersion}[2][\default]{
+ \def\default{#2}
+ \def\package@version{}
+ % The actual test only works after the package has been loaded
+ \IfFileExists{#1.sty}{%
+ \RequirePackage{#1}%
+ \protected@edef\package@@version{\csname ver@#1.sty\endcsname}%
+ \protected@edef\package@version{\expandafter\@parse@version\package@@version//00\@nil}%
+ }{}
+ \TestItem[#1]{#2}{package}{sty}{\AddPackage[\package@version]{#2}}{}