5

Is it possible to change the optional argument from <option 1> to <option 2> (given to a loaded package <package> via \usepackage[<option x>]{<package>}) at an arbitrary point in the document, so that until this point option 1 applies and after that point option 2 does?

I want to illustrate my question with an example:

Let's say the ´footmisc´-package (providing layouting-options etc. for footnotes) is loaded and I want to use the side-option (which causes footnotes to appear in the margin as "\marginpars") for, let's say, chapter 2 only.

Is there a way to realise such "option changes" or are workarounds needed for such a case? (In this particular example custom commands adding marginpars instead of "normal footnotes")?

  • 1
    Welcome to TeX.sx! Feel free to visit our TeX.SX starter guide to get the most out of this site. – Peter Jansson May 15 '13 at 18:31
  • Most packages allow this. The package footmisc not. You have to do the definition manual. – Marco Daniel May 15 '13 at 18:42
  • 3
    There is no general way. It really depends on what is done by the specific package when you set the specific option if and how you can revert/undo the option. – clemens May 15 '13 at 19:30
  • @PeterJansson: Thanks, I already went through the guide. :) @MarcoDaniel: Haha, a good choice, so to speak. Okay, I'll be looking for a manual solution... @cgnieder: Packages which allow that would be geometry or fancyhdr for example - am I right? – LCsa May 15 '13 at 19:42
  • @LCsa there are quite a number of packages which provide a setup command that can be used anywhere to change the options, for example siunitx. I'm not that familiar with geometry and fancyhdr so I can't comment on them. It really depends: maybe an option just sets a boolean switch which could be reversed manually, maybe an option includes some kind of config file which could not be undone... – clemens May 15 '13 at 21:38
4

If a package option can be reverted/unset and how that may be done is a per-case question. It depends on what exactly the package in question does if the specific option in question is set. Package options generally don't have anything in common except that they're given as package options.

An option may simply set a boolean flag...

% somewhere in mypackage.sty
\newif\ifmypackage@myoption
\DeclareOption{myoption}{\mypackage@myoptiontrue}

... which could be reverted by saying \mypackage@myoptionfalse and could give the desired effect. But if that actually has the desired effect depends on what is done with that flag by the package. If the flag has only been used in an \edef for example setting the flag to false may have no effect at all.

An option may also load an additional file, some configuration or definition file, say. If that's the case there is no way to “unload” the file and hence no way to revert the option. Although one may be able to revert what ever is done in that file. It depends...

And there loads of other possibilities...

Some packages provide setup commands which allow to set their options anywhere in the document, though. But even then this might not work for every option the package has. Maybe some of them are load-time options only...

Long story short: unless you have a specific package and a specific option in mind the answer is: definitely maybe.

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.