I use LyX and the math macros are compiled to LaTeX using \global\long\def\mymacro#1#2{body} (for a binary macro). This leads to me having to \robustify many of those macros.

I tried redefining \def and \global without much success, a priori because macros have different arities. Is there some (somewhat) simple way of automagically \robustifying all macros defined with \global\long\def?

  • 3
    Is there a reason you are not using \newcommand or \newrobustcmd here? That would work fine, other than the \global that seems a bit odd anyway. – Joseph Wright Jul 10 at 15:58
  • 3
    Can you please show an example of where you find macros defined via \global\long\def? Is LyX doing this way? If so, I have another reason for staying far from it. – egreg Jul 10 at 16:08
  • Never try to redefine \def! It is one of TeX's basic commands. – Peter Wilson Jul 10 at 17:40
  • @JosephWright @egreg I write stuff in the LyX editor because I find it very useful when editing big math formulas / tables etc. The LyX file is then transformed to LaTeX (that's where the \global\long\def appears), and then the LaTeX is compiled. I therefore have 3 solutions: (1) Add \robustify\mymacro everywhere by hand. (2) Write something in LaTeX that redefines one of those commands so that compiled macros are robust. (3) Edit the LyX source code. And I'd really prefer (2) if it's possible. – xavierm02 Jul 10 at 20:56
  • How do you define these macros that are translated to \global\long\def? Please add a small example of your LyX code and the translated .tex file to your question. – siracusa Jul 11 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.