I need to introduce in my preamble a conditional structure to load a package if its complete version is installed, load its light version if it exists, or load some standard package otherwise. The need to do this is that I have to forward the code to some other person and I don't know the specs of her latex installation. The package is mtpro2, that can be loaded with or without the “lite” option (“lite” is free, complete is not).

To check whether a package exists is simple (use \IfFileExists). To check whether a package is loaded with a certain property set is simple too (use ifpackagewith). But how can I check whether the package is installed in its full version or light one?

My current structure attempts a workaround, which is to check some font that is available in the full version only. But strangely enough it seems that this doesn't work properly. In any case this approach cannot be extended to other packages, therefore I think my question is valuable in more general case.

\IfFileExists{mtpro2.sty}{%this checks whether mtpro2 is installed
\IfFileExists{umt2hrb.fd}{%check whether there is this font: if the font is present, then full version is installed
}{%otherwise, load standard packages

Thanks for helping. Hope will be useful to other as well.

1 Answer 1


Testing for the fd-file is useless: It exists anyway, also it contains only font definitions, it is not the font itself. You need to test for a tfm and/or a pfb-font which is specific to the complete version. With pipes enabled you could do something like this (see Search for files first in the texmf trees):


\openin\mypipe="|kpsewhich mt2syat.tfm"
  \read\mypipe to \x  

a $a=b$

  • Thanks Ulrike. This is a good solution on my computer, but what if I have to share the code with other users with very different installations? (e.g. Windows). Is there a way to program something like "load the package; if loading fails, do another thing [e.g. load another package]"? Apr 30, 2016 at 10:11
  • On windows the code works too, miktex users will have to use --enable-pipes. Beside this you idea of a "package test" is too broad. mtpro2 consists of a lot of files and it is quite possible that only some are missing. Apr 30, 2016 at 20:44
  • In the case some are missing I would regard it as failed. I am wondering how one can use the fact that there should be a warning if some option cannot be loaded. (In particular, I don't know what happens if one doesn't have the complete version of mtpro2 and tries to load it without the lite option: maybe an error?) I'll update this thread if I'll find a satisfactory way to solve the issue. Thanks for your contribution. May 2, 2016 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .