10

(This isn't really about a LaTeX issue but more about personal taste and arguments herefore.)

Do you prefer to pass package options at loading time with, say,

\usepackage[something]{geoemtry}
\usepackage[something]{siunitx}

or later in the preamble with

\geometry{something}
\sisetup{something}

? I'm asking because I can't make a decision about what to do.

An argument for doing it at loading time is than not all packages have other ways of selecting package options than at loading time (see, e.g., Options for ``footmisc'' package) and then the first choice makes the preamble more consistent.

4
  • If it makes sense to load options or change them later in the document, a \...setup macro is welcome. Otherwise it's better (and more practical) to have the options in the package call. – egreg Dec 8 '13 at 19:01
  • @egreg Thanks. Can you give an example of when it will make sense to load package options later in the preamble? I can't think of any. – Svend Tveskæg Dec 8 '13 at 19:09
  • 5
    @SvendTveskæg Sometimes packages are loaded with options by the documentclass or a package, which might lead to an option clash. Setting options with \...setup can prevent this. – Johannes_B Dec 8 '13 at 19:32
  • @SvendTveskæg The main examples are caption and siunitx; also quoting has a mixed set of options. – egreg Dec 8 '13 at 19:58
6

This mostly depends on what the options do. Let's look at some cases.

Package babel

The options are basically the languages used. The main language is the last specified option (or the one given with main=<language> from babel 3.9). While the language list could in principle be specified later in the preamble, there no point in being able to say \babelsetup{<languages>}, because this must necessarily go in the preamble, since they act “globally” on the document.

Package geometry

One can use \usepackage[<options>]{geometry} and zero or more \geometry{<options>} commands. This is useful because one can add options when they become necessary; if an option is specified more than once, the last specification wins. However, I don't recommend using more than one \geometry command, because this makes the preamble difficult to manage. The most recent versions of geometry have a \newgeometry command that's similar to \geometry, which is not really necessary.

Package footmisc

The options redefine internal commands. The redefinitions are based on the specified options and are performed when the package code is processed. It would be almost impossible to have a \footmiscsetup command.

Package hyperref

One can specify package options or give one or more \hypersetup commands. This works because the relative code is executed at begin document; some of them can also be changed mid document.

Package caption

All options can be changed mid document, so a \captionsetup command is welcome in order to locally customize the captions. One can give "global” options as package options and then use \captionsetup at the relevant spots.

Package siunitx

The same considerations as for caption hold.

Package imakeidx

One can specify global options (say texindy for using Xindy as the sorting engine), but one can override the global options for a specific index, by giving options to \makeindex. An \imakeidxsetup command might make sense, to give options that are implicitly used by the subsequently defined indices. But cases where more than three or four indices are rare and defining a complex infrastructure for a few use cases would only make the code more difficult to maintain.

Final words

If options to a package are inherently global, there's no point in providing a \...setup command. Options that process different package code can only be given as package options, or code maintenance becomes really difficult and conflict prone, because the only way to manage the \...setup code is to overload \AtBeginDocument, which only slows starting up document processing.

If options can be set locally in the document, a \...setup command is what's needed.

1
  • Thanks for the list and the great, simple explanation on why this seems like a missing feature but is really a necessity of the design in the software. – user59034 Jun 17 '15 at 16:17

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.