0

When you \RequirePackage{foo} in a document class, this "loads" the package so you can start using it. But what if you don't want to do that? What if you only want to ensure it is available for loading, e.g. for other code to be able to \usepackage{foo} later on?

Is that possible?

Motivation: I'm going to be deferring the loading of a package within a document class, but I do want to fail immediately if the package isn't there so as not to confuse whoever is reading the logs.

  • 3
    Use \IfFileExists, see tex.stackexchange.com/questions/98203/… – egreg Sep 19 '17 at 23:32
  • @egreg: And the file must be foo.sty and nothing else? – einpoklum Sep 19 '17 at 23:34
  • \IfFileExists{foo.sty}{Do something if it exists}{Do something else otherwise} – egreg Sep 19 '17 at 23:36
  • 3
    What is the use-case for this? It seems pointless. Either the package will get loaded later or it isn't needed. Why does the class need to poke its nose into the business at all? A class is responsible for what it needs. It shouldn't go second-guessing what some other code might need, if we ever get there. – cfr Sep 20 '17 at 0:01
  • 2
    @MichaelPalmer: Yes. As a matter of fact, \usepackage itself indirectly calls \IfFileExists to load the .sty file. – GuM Sep 20 '17 at 1:55