2

I would like to mimic the spacing behavior of DeclareMathOperator without using a macro. I would like there to be a space after Spec when I write (in math mode)

\mathrm{Spec} k.

But I would like there to be no space after Spec when I write

\mathrm{Spec} (k).

Is there a way to do this? Sort of like \xspace but not in a macro.

5
  • Without using any macro whatsoever, not even \mathrm? Aug 10, 2020 at 6:15
  • \mathrm is okay, I would like to avoid defining my own macros though (or at least only define one, rather than one for every operator) Aug 10, 2020 at 6:17
  • I guess \operatorname{Spec} would be the easy solution (assuming the ubiquitous amsmath), see tex.stackexchange.com/q/84302/35864
    – moewe
    Aug 10, 2020 at 6:25
  • 1
    What do you have against \DeclareMathOperator?
    – Bernard
    Aug 10, 2020 at 9:15
  • 1
    I've written something and learned that I'm not supposed to define my own macros, so I need to change all the \Spec's to something. Aug 10, 2020 at 15:02

1 Answer 1

9

With amsmath package loaded

\[ \operatorname{Spec} k - \operatorname{Spec} (k) \]

or without amsmath

\[ \mathop{\mathrm{Spec}} k - \mathop{\mathrm{Spec}} (k) \]

If you ever want superscripts or subscripts with the primitive \mathop, you should add \nolimits

\[ \mathop{\mathrm{Spec}}\nolimits^2 k - \mathop{\mathrm{Spec}} (k^2) \]
1
  • 2
    Punctuation *-/:' will also behave differently in \operatorname. Aug 10, 2020 at 7:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .