0

it's not really clear to me how to declare unary and binary math operators in a "good" way. At the very least, I'd like spacing to be correct. But I'd also like the defined macro to be used "as is" in text mode (with correct spacing here also).

For instance, I have operators called X and U, the former being unary while the latter is binary. As I want them to work both in math and text mode, with correct spacing, I define them the following way, as of now:

\newcommand{\U}{\ensuremath{\mathbin{\mathbf{U}}}\xspace}
\newcommand{\X}{\ensuremath{{\mathbf{X}}\xspace}

But I'm not really sure it's the best practice...

  • 1
    \DeclareMathOperator – user31729 Feb 15 at 9:54
  • 3
    I see no reason for wanting the commands to work in text mode. – egreg Feb 15 at 10:01
  • 2
    I agree with egreg here, you really should not mix text and math. Using $\U$ gives a really good semantic separation between what is suppose to be interpreted as text and what should be interpreted as math. – daleif Feb 15 at 10:10
  • @egreg @daleif Well, for instance, there are some cases where something is both an abbreviation and the name of a mathematical object. E.g. I could write \fol is first-order logic as well as $\phi \in \fol$, with \fol printed as FOL. – Grayswandyr Feb 15 at 10:30
  • @Grayswandyr I see no reason for not using $\fol$ is first-order logic. – egreg Feb 15 at 10:33

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.