I use the following code to check if a package is loaded:
\RequirePackage{ltxcmds}
\newcommand{\IfPackageLoaded}[2]{\ltx@ifpackageloaded{#1}{#2}{}}
However, sometimes I want to check if more than one package is loaded. Therefore I would like to generalise the command, such that more than one package can be added in a list separated with commas:
\IfPackagesLoaded{xcolor, colortbl, hyperref}{
...
}%
What would the typical implementation of the processing of such a list look like?
Best Answer
You can use the LaTeX kernel's
\@for
macro, which processes a comma-separated list, in conjunction with anif
switch. The\IfPackagesLoaded
macro initially sets the switch to true, then goes through the list and sets the switch to false if a package is missing.