add tag
I am writing a package which needs an option disabling a global command. Let's say the package option is `xyz`. If the package is loaded with option `xyz` one global command from the package will be disabled. `DeclareOption` allows me to have a specific command if a particular option is loaded, but how to code something like "disable command `abc` if `xyz` option is loaded?"
Top Answer
Disabling is actually possible, you could `\let` your command to something which is guaranteed to be undefined, or you could redefine it to throw some meaningful error.


\newcommand\mytestcmd[1]{\typeout{Test was given #1.}}

          {The command \noexpand\mytestcmd was disabled}{}%

Answer #2
**Disclaimer:** This does *not* answer the original question. Rather it is a suggestion for a better practice (IMO) which is "too long for a comment".


As I mentioned in the chat, I think using a key=val interface is a better practice. For example, this is how I would implement `baseline`:



  marathi/.is family,marathi/.cd,


Now in the document I can choose different values for `baseline`:

|Preamble|Value of `\baselinestretch`|

This is a generalization of the way you want it to work. It makes your package more customizable.

Also, the user can *change* the value in the middle of the document. This is not something you can do easily if you use `\DeclareOption` without the star. The following works:


Answer #3
Instead of disabling a command, one could define it only if the package option xyz is not present:





Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.