If the draft
option is specified with \documentclass
it will be passed to all packages that know such option. Conversely, if it's specified only along your package, it will not be passed to other packages.
\documentclass[<global options>]{<class>}
\usepackage[<local options>]{<package>}
The options in the <global options>
list will be tried by the class and any package loaded in the preamble, but won't show errors or warnings if not known by a package.
The options in the <local options>
list will be passed to <package>
(which might pass them to other packages loaded after it, via \PassOptionsToPackage
).
So with
\documentclass[draft,...]{article}
all packages will try to honor the draft
option, and nothing can be done about this with code in some package.
However, if your package is loaded immediately after the class and you know how to modify the global options list, then it's possible to do what you wish. Here's the "secret" code:
\def\@clearglobaloption#1{%
\def\@tempa{#1}%
\let\@tempb\@gobble
\@for\next:=\@classoptionslist\do
{\ifx\next\@tempa
\message{Cleared option \next\space from global list}%
\else
\edef\@tempb{\@tempb,\next}%
\fi}%
\let\@classoptionslist\@tempb
\ifx\@tempb\@gobble
\let\@classoptionslist\@empty
\fi}
\@clearglobaloption{draft}
I've made it generic: any option can be cleared in this way. Beware that some classes such as beamer do different things with the option list and so the trick might not work with them.
Update
With expl3
in the LaTeX kernel (which has been for a couple of years), we can simplify the business quite a lot.
\ExplSyntaxOn
\cs_new_protected:cpn { @clearglobaloption } #1
{
\clist_remove_all:cn { @classoptionslist } { #1 }
}
\ExplSyntaxOff
draft
option is specified with\documentclass
it will be passed to all packages that know such option. Conversely, if it's specified only to your package, it will not be passed to other packages.