You can use \@gobble, for instance, to restrict the usage of a macro like:


\cmd{Hello World!}
\cmd{Again...}%not desirable

But, if you have a command with an optional argument, e.g. \newcommand{\cmd}[2][]{#1 #2}, there is no kernel macro that helps you. Sure, you could define something like

%\newcommand{\RG@gobble@opt}[2][]{}%alt: to avoid possible name clashes

Is this the usual way? Is it, generally speaking, absurd to gobble like this?

  • \let\cmd\@gobble is not really sufficient: you should add something more with \@bsphack and \@esphack.
    – egreg
    Nov 22, 2013 at 15:08

1 Answer 1

#1 #2%

I have another solution, simpler and without usepackage:

  • 1
    @cgnieder Not really important here since neither \\cmd will be needed nor \\gobblemyopt will be changed again. But it won’t hurt either. Nov 22, 2013 at 21:37
  • There is \GlobalLetLtxMacro. \global\LetLtxMacro won’t work. It might be helpful, if you also add that \usepackage{letltxmacro} is needed. Nov 22, 2013 at 21:39

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.