# Correct spacing rules for functions in math mode

I have a question about spacing in math mode. Suppose you have a document that contains many times the nabla symbol. I have read in different answers in this website that it is advisable to write

\newcommand{\grad}{\mathop{}\!\nabla}


in the preamble in order to improve the spacing for expressions like c\nabla_{X}X. In other words, now the spacing rules for \nabla_{X}X become the same as those for \sin(x). (Please correct me if I am wrong.) The same rule applies to the letter d when used in differentials as dx or dy.

I generally follow this advice, but now I am a bit confused. If I implement this spacing correction, what is then the rationale for not doing the same for an expression like cf(t), where now f is a function of the variable t, and c a constant? What about cf, again with f a function and c a constant?

What is the most logical approach I should follow?

• if you want \grad to have the same spacing as \sin use \mathop{\nabla}the construction that you show makes it have the same space to the left but no space to the right. compare \grad x and \sin x Commented Jul 17, 2020 at 12:45

Note that this is typesetting not mathematics so logic isn't always the primary concern, "what looks right", or "what are the historic conventions in your field" also play a part.

If f is a function then f x might be considered the same as \sin x and f(x) the same as \sin(x) (as could x f and (x)f if you have functions acting on the right)

But sin is usually set in a Roman text font with tight spacing and inter-letter kerns to make it seem like a single identifier. This means that \sin x really needs a thin space between sin and x not to look strange. That space isn't needed if you have an opening delimiter as in \sin(x). That is exactly the rule that \mathop implements, sin is \mathop{\mathrm{sin}} and gets a thin space before x but not before (x).

However f while mathematically also a function is set in the math italic font, that font (unlike the text italic used for \mathit) already has wide side-bearings so that adjacent letters do not look like a word but as an implied operation (multiplication or function application or whatever the context implies) so fx can normally be set with both characters having the default mathord class and no additional space.

\mathop{}\!\nabla means that there is never a space added after the nabla (presumably on the grounds that it is sufficiently "symbol like" that it will never "run in" to a following letter) but it does allow the \mathop spacing to the left which will cause some additional space in some cases (such as after a closing delimiter )

• Thanks a lot for your reply. In particular, \mathop{}\!\nabla adds a thin space on the left whenever I have some object multiplying it, like in c \nabla. Correct? I agree with you that there is no rule which is valid for all cases, but do you think that it makes sense to employ \mathop{}\!\nabla or \mathop{}\!\d while leaving the standard spacing for expressions like c f? Commented Jul 17, 2020 at 14:53
• @MK7 yes the \mathop{}\! idiom works well for "single letter" prefix functions that don't need a space on the right. Commented Jul 17, 2020 at 15:16
• You've ignored the vertical effect of \mathop. This is the mechanism used to vertically align a single symbol on the math axis (like \sum or \inf). Try $x \nabla \mathop{\nabla} \nabla \mathop{{}\nabla} \nabla x$ to see what I mean. \mathop{{}\nabla}` avoids this problem. Commented Jul 18, 2020 at 19:32