Lets say you are writing a package, which has the usual pair of draft and final-mode.

But how should I handle, if this package gets the global option final and the local draft?

Consider the following ex.sty:

\ProvidesPackage{ex}[2014/07/26 v1.00 This is just an example]
    an example text, only visible in draft mode}

Using that in the following main.tex:

some example text and eventually some more text: \example.

Results in the output “some example text and eventually some more text: .”. If I swap the \DeclareOption (final first, then draft), then at least I have the output of \example. But then it wouldn't work if I swap the options in the main.tex…

So what is the LaTeX way to handle this?

  • Check if both options are set and then fire an error? (and how to check for both options?)
  • Check if both options are set and then fire a warning?
  • Prefer global option over local option? (how to check if a given option is global or local?)
  • Prefer local option over global option?
  • Just do it as I have and live with its problems? (how to decide which order might be more sens?)
  • Use a package that I haven't found yet but really helps with such stuff?
  • 2
    From a user's perspective I'd expect that local options win
    – cgnieder
    Jul 26, 2014 at 8:59
  • I think so too, but I really don't know how to check if an option was locally or globally set :(
    – NobbZ
    Jul 26, 2014 at 9:04
  • There is a package ifdraft. With it you can test the class option. ctan.org/pkg/ifdraft. Jul 26, 2014 at 9:49

1 Answer 1


From my perspective as a user I expect that local options take precedence over global options if they contradict each other. If you want your package to behave like this then here's what I would do:

I would define a conditional, \newif\ifex@draft, say, and let the options either set this conditional to true or false:


Then all that's left to do is to change \ProcessOptions\relax into \ProcessOptions*. The clsguide says about the starred version:

This is like \ProcessOptions but it executes the options in the order specified in the calling commands, rather than in the order of declaration in the class or package. For a package this means that the global options are processed first.

So a modified version of the example package could look like this:

\ProvidesPackage{ex}[2014/07/26 v0.0 This is just an example]
\newif\ifex@draft % implicitly false. Set to true if you want a different default behaviour


  \newcommand*\example{Package `ex' in draft mode}
  \newcommand*\example{Package `ex' in final mode}


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.