6

I want to typeset '+1', as we would write here on TeX-LaTeX Stack Exchange.

Now, as I see it, the '+' is a binary operator here. I am actually adding 1 to something. I'm not using it to denote the positivity of 1, I'm using it to denote the operation of addition. However, what I'm adding 1 to isn't stated. (It is an upvote on the post, but we do not write 'post + 1', we just write '+1').

If I, then, type +1 I get

enter image description here

Which is the unary operation spacing. I tried $\mathbin{+} 1$, but that didn't do anything:

enter image description here

Next I tried {} + 1 which did use the correct binary operation spacing, but added the spacing before the '+' sign, giving me a small leading space. I don't actually really want this, since I'm not stating what I'm adding 1 to. I want the space after the '+' sign, but not before, which I think is correct. I could add manual, visual correction, but I'm not sure what values to use and would prefer a less quick and dirty solution if one exists.

enter image description here

Code for above image:

${} +1$ \\
$+1$
1
  • 1
    Personally, I think the $+1$ is just fine, but what about $+\,1$ or $+\;1$?
    – jak123
    Oct 25, 2015 at 4:53

2 Answers 2

4

You have a couple of options:

enter image description here

\documentclass{article}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
${} +1$

${}\mkern-\medmuskip+1$

$+\:1$

$+1$
\end{document}
6
  • Good answer +1 :P Is there any reason why you kern away \medmuskip in option 2 but add \: in option 3?
    – Au101
    Oct 25, 2015 at 5:00
  • 2
    @Au101: You can either consider the + as a binary operator and remove the one side's spacing (option 2) or consider it an ordinal symbol and add the appropriate spacing (option 3).
    – Werner
    Oct 25, 2015 at 5:42
  • Indeed yes :) I was wondering why you had used two different spacing commands, though, for what I assume (?) is the same amount of space. Are they equivalent here (or, indeed, always)?
    – Au101
    Oct 25, 2015 at 5:44
  • @Au101: They are here, since you've only used a unary +. Other places you may have to force a unary plus to get the appropriate spacing {+}\: (option 3).
    – Werner
    Oct 25, 2015 at 5:47
  • I see, thanks very much :) I'll accept in the morning if nobody's added anything else
    – Au101
    Oct 25, 2015 at 5:49
3

Here's it, implemented in plain TeX (just use \newcommand instead of \def for LaTeX and \mspace{-\medmuskip} instead of \mskip-\medmuskip if you also load amsmath).

\overfullrule=0pt % don't print the overfull rule

\def\addone{\mathord{}\mskip-\medmuskip+1}

%%% LaTeX+amsmath version
%%\newcommand{\addone}{\mathord{}\mspace{-\medmuskip}+1}

``$\addone$''

X\hbox to 0pt{$\addone$}\qquad X\hbox to 50pt{$\addone$}

\def\badaddone{{}\mkern-\medmuskip+1}

``$\badaddone$''

X\hbox to 0pt{$\badaddone$}\qquad X\hbox to 50pt{$\badaddone$}

\bye

In the first part I define the command: it inserts an ordinary symbol, then a math skip that counteracts the one automatically inserted by a binary atom, then + and finally 1. The three examples show the behavior at natural size, maximum shrink and exaggerated stretch.

The second part deals with the difference between \mskip and \mkern. Since \medmuskip usually holds a stretchable and shrinkable glue, it's important to distinguish between the two and the examples show why. With \mkern-\medmuskip the stretch and shrink components do not cancel and so they can act: and they do.

enter image description here

You must log in to answer this question.

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