[Tex/LaTex] Gradient notation spacing


I'd like to notate 'gradient of L with respect to a_f' which I can do with \nabla_{\mathbf{a}_f} \mathcal{L} and it looks like this:


Look at all that space between the nabla and the L! Is there a way to get the a 'under' the nabla a little more without having to shrink its size too much? How would people suggest I make this look a little better?

Best Answer

It's better if you use a more semantic command, with the advantage that you can define it to do what you precisely want.

The approach here is to add a thin negative space to the subscript, if present, but without changing the input. I use the same trick as for the standard differential, so a thin space will precede the nabla when necessary, without user intervention.


  \mathop{}\!% \mathop for good spacing before \nabla
  \IfValueT{#1}{_{\!#1}}% tuck in the subscript
  \IfValueT{#2}{^{#2}}% possible superscript







enter image description here

Here's the picture of what you get from the previous input by just changing \!#1 into \mspace{-4mu}#1 (\! is the same as \mspace{-3mu}).

enter image description here