Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to load some package from a .sty file only if some option is selected?

(Naive approach \DeclareOption{something}{\RequirePackage{something}} doesn't work.)

share|improve this question

1 Answer 1

up vote 12 down vote accepted

Use \if... switches, I do something like

\newif\if@loadsomething\@loadsomethingfalse
\DeclareOption{something}{\@loadsomethingtrue}
...
\ProcessOptions\relax

\if@loadsomething
  \RequirePackage{something}
\fi

I haven't myself completely figured out how the "options" mechanism works, or why your example doesn't, but I guess it has to do with the precise moment when the options are being executed and the state of TeX's context when that happens.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.