next up previous contents
Next: Make it robust Up: General style Previous: General style

   
Loading other files

LATEX provides these commands:

   \LoadClass        \LoadClassWithOptions
   \RequirePackage   \RequirePackageWithOptions
for using classes or packages inside other classes or packages. We recommend strongly that you use them, rather than the primitive % \input command, for a number of reasons. Files loaded with % \input <filename> will not be listed in the \listfiles list. If a package is always loaded with \RequirePackage... or \usepackage then, even if its loading is requested several times, it will be loaded only once. By contrast, if it is loaded with % \input then it can be loaded more than once; such an extra loading may waste time and memory and it may produce strange results. If a package provides option-processing then, again, strange results are possible if the package is % \input rather than loaded by means of \usepackage or \RequirePackage.... If the package foo.sty loads the package baz.sty by use of % \input baz.sty then the user will get a warning:
   LaTeX Warning: You have requested package `foo',
                  but the package provides `baz'.
Thus, for several reasons, using % \input to load packages is not a good idea. Unfortunately, if you are upgrading the file myclass.sty to a class file then you have to make sure that any old files which contain % \input myclass.sty still work.

This was also true for the standard classes (article, book and report), since a lot of existing LATEX 2.09 document styles contain % \input article.sty. The approach which we use to solve this is to provide minimal files article.sty, book.sty and report.sty, which simply load the appropriate class files.

For example, article.sty contains just the following lines:

   \NeedsTeXFormat{LaTeX2e}
   \@obsoletefile{article.cls}{article.sty}
   \LoadClass{article}
You may wish to do the same or, if you think that it is safe to do so, you may decide to just remove myclass.sty.
next up previous contents
Next: Make it robust Up: General style Previous: General style
LaTeX3 Mail Server
1999-07-12