You can request a minimal version/date using the trailing optional argument of \usepackage[<options>]{<name>}[<min.date>]
(or \RequirePackage
). However, it will only print a warning text and not cause an error if the installed version is older than the requested version.
This feature is realized in the LaTeX core by the macro \@ifpackagelater{<name>}{<date>}{<yes>}{<no>}
, which you can also use yourself (\makeatletter
.. \makeatother
is required if not used inside a package or class file).
You can use the following code to cause an error if the package is older than the given date. However, this only works after the package was loaded.
\makeatletter
\usepackage{<name>}%
\@ifpackagelater{<name>}{<date>}{%
% Package is new enough
}{%
\PackageError{<your package or document name>}{Package <name> is to old <...>}%
}
\makeatother
Note that despite the name \@ifpackagelater
, AFAIK, the macro checks actually if the package date is later or equal. A more accurate name would be therefore ifpackagenotolder
. If you want to check if a package is actually newer than a last version known to you, than simply add one day to the date.
\usepackage[<options>]{<name>}[<min.date>]
(or\RequirePackage
). Then there is\@ifpackagelater{<name>}{<date>}{<yes>}{<no>}
as shown in the linked thread. – Martin Scharrer♦ Mar 12 '12 at 15:28