In the listings package, they note that "a global \documentclass-option draft is recognized, so you don’t need to repeat it as a package option"

I tried looking into its source to see how it accomplishes this, but I wasn't able to find the magic bit. How does one detect the global \documentclass options from within an independent style/package?

2 Answers 2


This is done automatically for all packages by LaTeX's \ProcessOptions. It checks if any of the global class options are defined by the package and executes the ones which are. You do not need to do anything special in your package.

This is explained in clsguide, page 18. The source code which implements it can be seen in source2e, page 370.


I think the story is more subtle than Martin has had the time to explain. It is the starred form of \ProcessOptions, when issued in packages, that copies and processes global options (submitted via \documentclass) in the order in which they were submitted via \documentclass. The unstarred variant of \ProcessOptions doesn’t copy global options from \documentclass (except when issued in a class file – where, in the LaTeX2e kernel approach, \@curroptions come from \@classoptionslist) and processes the options in the order in which they were declared.

  • 1
    Thanks Ahmed for explaining it further. I didn't do it in that detail on purpose, but pointed him to the clsguide where this details are explained. IMO he has to read that document anyway. Feb 15, 2011 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .