I would like to define commands with semantics similar to e.g. + in math mode. For instance,


produces an equation with some spacing around +, whereas


produces an equation with less (or no) spacing around +.

The reason is that I would like to write something like

$\token{repeat} \token{skip} \token{until} b$

Where tokens are follwed by a space in the first case, but are not in the second. In a way, I'd like something similar to xspace, in math mode.

Any suggestions?

  • + gets it space from being a \mathbin but \mathbin{\hbox{#1}} doesn't do what you want.... – David Carlisle Sep 7 '13 at 11:21

Perhaps mathop spacing is what you are looking for.

enter image description here


.$\token{repeat} \token{skip} \token{until} b$.



\DeclareMathOperator in amsmath package for LaTeX.

| improve this answer | |

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.