Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

$(x+y)$

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$
$\token{skip}$

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?

share|improve this question
    
+ 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
add comment

1 Answer

up vote 3 down vote accepted

Perhaps mathop spacing is what you are looking for.

enter image description here

\def\token#1{\mathop{\hbox{#1}}}

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


.$\token{skip}$.

\bye

\DeclareMathOperator in amsmath package for LaTeX.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.