4

I was reading some post here at SE and I noticed that many people load packages one by one. For example,

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}

and so on. Usually, I load those on a single command, like

\usepackage{amsfonts,amsthm,amsmath,amssymb}

Is this correct or some problems could appear?

I know that there are some packages which should be loaded before than others.

  • IMHO there shouldn't be any problem. But how do you load options for packages in this way? This is the only drawback! – user11232 Dec 9 '12 at 12:42
  • 2
    While you are at it add mathtools to the chain to have the full house :) – percusse Dec 9 '12 at 13:02
  • 4
    No need to load amsfonts and amssymb since amssymb internally loads amsfonts. – Gonzalo Medina Dec 9 '12 at 13:05
  • 3
    @percusse -- mathtools loads amsmath so there's no need to load the latter. i'd tend to load mathtools first, but there's no specific order required. – barbara beeton Dec 9 '12 at 14:59
  • 1
    See What does each AMS package do? for a list of AMS package dependencies to minimize your loading sequence. – Werner Dec 9 '12 at 16:54
10

Semantically,

\usepackage{amsfonts,amsthm,amsmath,amssymb}

is the same as

\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}

and clearly, the former looks more tidy and compact in the document.

The following reasons can make one still prefer the latter form:

  1. Package options would be given to all packages at once, which is not always desirable. If one has already written down the preamble and then notices an option needs to be added or removed, this is usually more convenient with one \usepackage call per package.
  2. It is easier to comment one package out (or in) this way.

I usually copy preambles between documents, and one package per line makes customizing easier.

Note that before LaTeX2e, there was only one \documentstyle call (giving the document class as mandatory argument) and all packages had to be given in a big option list to that. This initial command always looked like a total mess in my documents, spread over several lines with a lot of lines commented out.

Being able to say \usepackage was a big relief compared to that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.