I understand that "the convention is to use \RequirePackage in a package or class and \usepackage in a document", but apart from that, is there any practical difference between the two commands?

(I am thinking for example that it could be the case that \RequirePackage is a "stronger" command and you wouldn't run into problems with hyperref not being at the end)

  • 3
    You're question has been answered for the most part, so this is just a comment. What hasn't been answered was the final question about problems caused by hyperref not being at the end. RequirePackage isn't going to help with that problem. In fact, it may well make it worse. (What if you want to use two packages, both of which RequirePackage{hyperref} ?) Take great care if you RequirePackage{hyperref} in some package. It had better be the last package you need. Commented Jun 5, 2011 at 19:42
  • Well, yeah, I meant your, not you are. Yet another example of the necessity of editors. Commented Jun 6, 2011 at 1:06

5 Answers 5


Sorry but there is a difference, you can write :

\documentclass ....

and not

\documentclass ...
  • I created myclass.cls, and \documentclass{myclass} it on main.tex. As per comment and answers around here I cannot usepackage{anypackage} before \documentclass{myclass} on main.tex. But looks like I still can usepackage{anypackage} on myclass.cls, which I wasn't expecting. Does this makes sense?
    – KcFnMi
    Commented Apr 3, 2019 at 17:32
  • 5
    What do you mean? The two code snippets are exactly the same with the only difference being whether RequirePackage or usepackage is used. Commented Apr 12, 2021 at 10:49
  • The point here is that the first snippet is valid but the second snippet is not since \usepackage{...} cannot be used before \documentclass.
    – Icarus
    Commented Nov 29, 2023 at 11:45

The only difference is that \usepackage cannot be used before \documentclass. Otherwise there is no functional difference. The LaTeX kernel defines \usepackage to issue an error message initially, and \documentclass is defined as

  \let\documentclass\@twoclasseserror % a second \documentclass command produces an error
  \if@compatibility\else\let\usepackage\RequirePackage\fi % define \usepackage to be the same as \RequirePackage
  • 1
    Thanks. Your answer added a lot to my understanding, but I will accept @Altermundus' answer since it was given first.
    – Vivi
    Commented Jun 5, 2011 at 8:36
  • 37
    @Vivi Not the best reason to accept an answer, but the choice is yours. :) Commented Jan 26, 2015 at 2:15
  • 31
    @vivi: A very bad reason indeed. Commented Jan 31, 2016 at 15:50

From a technical point \usepackage is first defined to the error message \usepackage before \documentclass but than set to the definition of \RequirePackage by the \documentclass before the class file is loaded. You can use \RequirePackage before \documentclass, which might be sometimes required.

However, the true difference is the logical usage: \usepackage is an user macro intended for the document file while \RequirePackage is intended for package and class files to describe dependencies. Using \usepackage inside a package will also work, as long it isn't loaded with \RequirePackage before \documentclass. :-)

  • 6
    I don't really get the point of this "logical usage". If a package uses another package, then it surely requires it! From the naming of the macros I was always under the impression that \RequirePackage was taking extra care in order to warrant the package to being loaded without "loading" it twice in case it was already loaded by someone else. But it seems I was wrong. I guess package designers don't want to impose the requirement of even having a \documentclass statement. Therefore, they use \RequirePackage. Commented Jan 31, 2016 at 16:02
  • Well, to me it sounds like "This package has this dependency, but if the dependency is already loaded (by some other package or explicitly by the user with \usepackage), do nothing.".
    – sesodesa
    Commented May 24, 2019 at 11:38

you can use \RequirePackage before the \documentclass statement, which has some advantages in some special cases.

  • 4
    As I understood reading up to now, \usepackage was intentionally created in order to avoid people "using packages" before the \documentclass statement. Therefore, I guess emphasis should be given on why is it a problem if you put thing before documentclass, and when and why it is unavoidable or not worth avoiding. Commented Jan 31, 2016 at 15:55

Both expand to \@fileswithoptions \@pkgextension. I.e., no difference.

  • 15
    no, that's not correct ...
    – user2478
    Commented Jun 5, 2011 at 6:56
  • 5
    \usepackage is first defined to an error message but than \let\usepackage\RequirePackage is executed by \documentclass. Commented Jun 5, 2011 at 9:23
  • @Herbert: Sure. I can think of exactly one situation where one needs to include a package before a documentclass. Maybe there are others, but for most purposes, they are functionally identical and certainly one is not "stronger" than another.
    – TH.
    Commented Jun 6, 2011 at 8:34
  • 6
    @TH what is that situation?
    – rogerl
    Commented Mar 26, 2014 at 22:20
  • 1
    @rogerl It has been years, but I'm pretty sure I was thinking of the fix-cm package that should be loaded via \RequirePackage before the \documentclass: bakoma-tex.com/doc/latex/base/fixltx2e.pdf But tex.stackexchange.com/questions/360656/… makes a good case for a second.
    – TH.
    Commented Feb 26, 2018 at 4:09

You must log in to answer this question.

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