4

Want to understand how the placements of \RequirePackage, \documentclass, and \usepackage should be made.

In my style files I use \RequirePackage. In my document I call with the following sequence.

\documentclass[b5paper,12pt]{article}
\usepackage{mystyle}

Have seen that \usepackage cannot be put before \documentclass, but \RequirePackage. When is there a requirement for \RequirePackage to precede \documentclass?

1 Answer 1

2

For historical reasons, a few packages should be loaded before \documentclass, but the main one is fix-cm (if you need it). With some proprietary document classes, you might need to load a couple of packages before \documentclass, but it's quite an unusual situation.

For such packages you have to resort to \RequirePackage.

For those you load after \documentclass always do \usepackage.

3
  • Thanks for the detail. From what you outlines, the standard practice is to call packages with \usepackage. Has been said to me that style files use \RequirePackage rather than \usepackage even though they themselves are called after \documentclass and with \usepackage{mystyle}.
    – Veak
    Sep 22, 2022 at 13:32
  • @konmi Yes, it's recommended to use \RequirePackage in .sty files. The fact that after \documentclass the two are presently the same command should not be taken into account (the two commands might become different in future releases of LaTeX, one never knows).
    – egreg
    Sep 22, 2022 at 13:37
  • Was going to ask what different functionality they provide, but you explained at being the same command.
    – Veak
    Sep 22, 2022 at 14:06

You must log in to answer this question.

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