# Tag Info

## Hot answers tagged package-options

98

Once you get the error message: ! LaTeX Error: Option clash for package xcolor. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.17 type "h" (without the quotation marks, for help) in the output console and you get ? h The package xcolor has already ...

58

Load xcolor before tikz: \usepackage[table]{xcolor} \usepackage{tikz} The problem is that pgf/tikz already loads xcolor so loading it again with a new package option triggers the error message. Another option is to pass the table option to the class and not to the xcolor package. Then the packages can be loaded in any order: \documentclass[table]{article}...

49

If a package is loaded, the option setting code in the package is already processed and gone. Thus in general you cannot change package options later. \PassOptionsToPackage But you can specify options earlier, before loading the package. Apart from a global option (with side effects for other packages) \PassOptionsToPackage can be even used before \...

30

The tikz package already loaded the graphicx package, so you can't load it again. Trying to load it with different options will cause the "Option clash" error. You can use \PassOptionsToPackage{<options>}{graphicx} before loading tikz to pass any additional options to the internally loaded graphicx. However, you do not need and should not use the ...

26

a4paper specified in document class will be passed to geometry. So there is no difference in your case if you specify the option in \documentclass{article} or \usepackage{geometry}. However if other packages need to know document format, you need to specify a4paper in the document class.

25

You have to load fullpage after \ProcessOptions, first of all. Here's the scheme: \ProvidesPackage{mypackage} \newif\ifmypackage@fullpage \DeclareOption{fullpage}{\mypackage@fullpagetrue} \DeclareOption{nofullpage}{\mypackage@fullpagefalse} \ExecuteOptions{fullpage} % default is fullpage \ProcessOptions\relax \ifmypackage@fullpage \RequirePackage{...

23

At the moment you use \DeclareOption, your style file is divided into three parts: Pre-options Section (above first \DeclareOption); Options Section (between first \DeclareOption and \ProcessOptions); and Post-options Section (after \ProcessOptions). Whatever is contained within the pre-options section has already been processed. So, the only problem ...

22

In so far as the top level LaTeX3 code isn't written, I'm sure it will improve "freedom of package ordering", "freedom of speech" and generally move the world towards peace and harmony. To answer your implied comment about LaTeX2e (the main point of this answer:) Might it be possible, for example, to suppress option clash checks It is easy to suppress ...

21

Basically the package is only loaded once, with the options specified at that point. Any later uses of \RequirePackage or \usepackage are silently ignored if the options specified were specified earlier, or generate an error otherwise. Normally it works to put options on \documentclass, so they are global options seen by all packages. The help text for the ...

19

From source2e.pdf, page 479 (CTAN page or texdoc source2e in a terminal):

18

In general I would claim that there is no good point in suppressing option clashes by default --- at least not if they indicate incompatible requests. If one load request says behave like "X" and the next one behave like "Y" and the two behaviors are incompatible then this needs to be resolved. And even if they are compatible (i.e., can be used together) it ...

17

The first version of the pkgloader package has been released! Based on all of the useful comments above, and my own (re)search, I feel safe to answer my own individual questions as follows: Is there already another package that does (something like) this? No. The closest that has been suggested is scrlfile, and, frankly, it's not all that close. Also, ...

17

Use \PassOptionsToPackage{demo}{graphicx} before the line with \documentclass

15

Both David and Frank have provided good views on this, but there are few points I think are worth covering, both on the LaTeX3 possibilities and the current expl3 use of color and graphicx. On the possibilities for a 'native' LaTeX3 mechanism, there are both technical and conceptual changes that I think we will go for. Frank has outlined some general areas ...

15

It is best to set things up using a \foosetup command and then (possibly) also make those options available as package options using kvoptions or similar packages. the advantage of having a separate setup command is that it can be run more than once which avoids many issues with option clashes and also the package option list is somewhat aggressively ...

14

In common with many keyval methods, the default value is the one which will be used if only the key name is given at point of use. Thus with \DeclareStringOption{foo}[bar] giving foo with no value/= sign in the option list is equivalent to giving foo = bar. In contrast, the initial value is used to ensure that some value has been stored before option ...

14

The mechanism used by \PassOptionsToClass (or indeed \PassOptionsToPackage) targets just that file: it's therefore equivalent to \LoadClass[<options>]{<name>} and very similar to \RequirePackage[<options>]{<name>} \usepackage[<options>]{<name>} In contrast, the options given as part of the \documentclass line are ...

13

If you want all the options to your package to be passed to hyperref then you can just do \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{hyperref} \ProcessOptions\relax \RequirePackage{hyperref} see clsguide.tex documentation in the LaTeX base. I just read clsguide:-) and if this is all you want to do, it points out that there is a more efficient ...

13

The LaTeX2e kernel defines usepackage to be exactly the same as RequirePackage in the ltclass.dtx. \if@compatibility\else\let\usepackage\RequirePackage\fi So the fact that you use RequirePackage makes no difference and you still get an error. If the same package is requested more than once, nothing happens, unless the package has been requested with ...

11

Loading a package several times with different (i.e. potentially conflicting) options easily results in an option clash. Fortunately, many options of the hyperref package need not be set at load time. You can use \hypersetup to set them: \hypersetup{linkbordercolor={0 0 1}}

11

Files can be tested via \IfFileExists{file}{yes}{no}. The following snipset uses a switch \if@mysty@lineno that remembers the option setting lineno for package mysty. Package lineno and \linenumbers are only executed, if the option lineno was given. This way, the package lineno is not loaded unnecessarily if it is not needed. Packages cannot be loaded during ...

11

Of the many options available for biblatex, there are only very few that have to be set at loading time in the square brackets, all others can also be used with \ExecuteBibliographyOptions later in the preamble. These exceptions are listed in §3.1.1 Load-time Options, p. 44-45 of the biblatex documentation. They are backend, style, bibstyle and citestyle, ...

11

Phelype Oleinik pointed you at the LaTeX sources but there is also a user guide called usrguide.pdf texdoc usrguide will open the document in texlive. Section 3.2 on preamble commands has the syntax for \usepackage. This argument was extended with new syntax last year so you may also want to look at LaTeX News 28 in texdoc ltnews which points you at ...

10

If you are using geometry you are overwriting the settings from typearea so the class doesn't need the option (btw a4paper or more precisely the option paper=a4 is the default anyway). I personally don't use global options if possible to avoid unwanted side effects on packages. With local options it is easier to control which package gets which option.

10

Under most operating systems, texdoc <packagename> will open up the TeX documentation (in your default PDF browser) associated with the package. Alternatively, CTAN contains all the packages that form part of both the MiKTeX and TeX Live distributions, from where you can follow the links to their documentation.

10

While I don't know how to conditionally invoke package options at load time, in the case of biblatex most options (except style specifications, compatibility options and choosing the backend) can also bet set afterwards using \ExecuteBibliographyOptions. For example, the url option (which was introduced in biblatex v0.9) could be conditionally disabled using ...

10

pstricks defines a \clipbox command which clashes with adjustbox you can arrange to avoid that, but do you really need to load all those packages? it looks like there are lots of packages loaded that you do not need. epsfig should never be loaded, fixltx2e should always be loaded first you reference it twice, neither at the beginning, you load inputenc ...

10

You may define two macros to switch the OS style: \makeatletter \def\setmenukeyswin{\def\tw@mk@os{win}} \def\setmenukeysmac{\def\tw@mk@os{mac}} \makeatother Example: \documentclass{article} \usepackage{menukeys} \makeatletter \def\setmenukeyswin{\def\tw@mk@os{win}} \def\setmenukeysmac{\def\tw@mk@os{mac}} \makeatother \begin{document} \setmenukeyswin \...

Only top voted, non community-wiki answers of a minimum length are eligible