10

With the command \nabla_x f(x, y), I have enter image description here

I think this is not aesthetic. Is there a way to get the subscript closer to the tip of nabla symbol? Something looks like enter image description here

Thank you so much for your elaboration!

Akira
  • 1,215

2 Answers2

14

Define a new command that nudges in the subscript (when present).

\documentclass{article}
\usepackage{amsmath}

\NewDocumentCommand{\Nabla}{e{^}}{% \nabla \IfValueT{#1}{{!#1}}% \IfValueT{#2}{^{#2}}% }

\begin{document}

[ \Nabla_{x} f(x,y) ]

[ \Nabla f\quad \Nabla^{2} f \quad \Nabla^{2}_{x} f ]

\end{document}

enter image description here

egreg
  • 1,121,712
  • When using both subscript and superscript, the subscript is pulled down further. Can we keep its height as in the case there is only subscript? – Akira Jan 04 '24 at 10:19
  • @Akira So to have them clashing? – egreg Jan 04 '24 at 10:36
  • It seems to me only the superscript does not move and the subscript is pulled down. It would be great if we have both of them moved so that we have a balance. I meant the position of the superscript is unchanged no matter the subscript is present or not. – Akira Jan 04 '24 at 10:40
  • 1
    @Akira That's how TeX does. – egreg Jan 04 '24 at 10:41
  • 1
    @Akira If you can use luatex, you can try \mathscriptsmode4 (or some other value). See section 7.5.7 in the luatex manual. – mickep Jan 04 '24 at 17:20
  • @mickep I can't find \mathscriptmode in the luatex documentation. Do you mean \mathscriptcharmode instead? If so, what are the valid arguments, the corresponding table lists 0, 1, 2, and bizarrely 2, presumably the latter should be 3. 4 is not given as possible value. – Andrew Swann Jan 10 '24 at 08:20
  • @AndrewSwann See section 7.5.7 in the manual. – mickep Jan 10 '24 at 08:55
  • @mickep Thanks, but it is not in that section; section 7.5.6 lists the commands I mention. Also trying the luatex I have (which reports itself as luahbtex 1.17.0) it does not recognise the macro you give. – Andrew Swann Jan 11 '24 at 14:12
  • Yes, it is. Follow the link. This is what I get in ConTeXt with luatex. – mickep Jan 11 '24 at 14:20
7

Simply using \! a negative space.

enter image description here

\documentclass{article}
\usepackage{mathtools}

\begin{document}

[ \boldsymbol{\nabla}_{!x}^{2} f(x, y) ]

\end{document}

Sebastiano
  • 54,118