1

From the answer to my other question " How can I define a math operator behaving like \lim or \sum with limits?", I tried:

\def\ext{\qopname\relax m{ext}}

and:

\newcommand{\ext}{\qopname\relax m{ext}}

In " What is the difference between \def and \newcommand?", it is said that they are basically the same and \newcommand is a bit more clever and does some extra checks. But it suggests that they should behave in just the same way.

But actually they do not. For the \def case, it seems to add extra spacing around \ext when I use it (just like \lim would). And \newcommand does not.

Why? What exactly is the different behavior for those more generally?

Albert
  • 2,707
  • 1
    They should behave the same way. Note that \def is more like \newcommand*. For the same behavior of \newcommand you would need \long\def, but this does only matter if you define macros with arguments. Could you add a minimal example that shows the space you mention. – Martin Scharrer Mar 16 '11 at 10:18
  • Can you post a screenshot? I just tried it, and I thought I could see the difference on one test but when I zoomed in then it disappeared. – Andrew Stacey Mar 16 '11 at 10:22
  • 3
    I think in general normal users should stay way from \def as it overwrites existing macros without question. Usually one should only overwrite a macro if on know what it does and one is certain it will be OK to overwrite it. The classical example is of course \span – daleif Mar 16 '11 at 10:27
  • @Martin: Hm, I just tried. But I don't seem to be able to reproduce this. Maybe it was something different and lead me to this wrong conclusion. – Albert Mar 16 '11 at 10:36
  • @albert: that happens to the best of us – daleif Mar 16 '11 at 10:49
  • @Albert: I would prefer if either you delete the question or that it is closed. It isn't a real question (anymore) after all. – Martin Scharrer Mar 16 '11 at 14:02
  • 2
    @Martin: I don't really want to delete it in the case that I stumble again upon it and when I am able to reproduce it. I would close it for now and reopen it later then. But I don't know how to do that. Maybe I lack enough reputation. – Albert Mar 16 '11 at 14:06
  • @Albert: I closed it for you. Just mark it for moderator attention if you want to have it reopened. – Martin Scharrer Mar 16 '11 at 14:08
  • There's no real reason to use \qopname. I don't know what Stefan suggested that. You should be using \DeclareMathOperator in the preamble, or for one-off, you should be using \operatorname. – TH. Mar 16 '11 at 19:13
  • @TH: Stefan explained in a comment to his answer why he used \qopname. Still I agree with your recommendations. – Hendrik Vogt Mar 17 '11 at 07:50
  • @Hendrik: Yes he did, but is isn't very compelling. \lim is defined that way for efficiency since they knew that lim didn't need any mathcode modifications. Granted ext doesn't either, but that's not really a good reason to use an undocumented macro rather than the standard interface. – TH. Mar 17 '11 at 14:52
  • @TH: It's not me you have to convince, I do already agree :-) – Hendrik Vogt Mar 17 '11 at 14:54

0 Answers0