2

Sometimes, one doesn't want whitespace between tokens of a math expression, and how can one remove the whitespace? For example, $ foo-bar $ displays as foo - bar, but foo-bar is prefered.

3
  • 2
    In this short example, the answer is straight-forward: - is interpreted as a binary operator, which has space around it. If you want to avoid such space, use {-}. But if you're using text in this way, why not just write foo-bar outside math mode? – Werner Oct 18 '13 at 18:03
  • @Werner: or \mathord{-} – Francis Oct 18 '13 at 18:09
  • Is your foo-bar the name of a variable? – egreg Oct 18 '13 at 20:52
2
\documentclass[border=12pt]{standalone}
\begin{document}
$a-b$ and $a{-}b$ and $a\!-\!b$ and $a\!\!-\!\!b$
\end{document}

enter image description here

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.