# Gradient symbols and letter f mtpro2

So I notice that the spacing between \nabla and f in math mode when using mtpro2 is really wide (for me, at least). Here is the result of typing \nabla f with mtpro2.

I wonder if there is a way we can adjust the symbol \nabla based on the next non-space letter, say:

1. If the next non-space letter is f, then execute \kern -0.2 em f,
2. else, stay at usual.

I have been looking around, but could not find a satisfying solution. Any help is highly appreciated.

• Can I ask a question please? – Sebastiano Sep 9 '18 at 8:21

Here's a LuaLaTeX-based solution. It sets up a Lua function called nabla_f that does most of the work, and it assigns this function to the process_input_buffer callback, making it operate on all inputs before TeX starts is usual processing.

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{times,mtpro2} % text and math fonts
\usepackage{luacode}
\begin{luacode}
function nabla_f ( s )
return ( s:gsub ( "\\nabla%s*f" , "\\nabla\\mkern-4mu f" ) )
end
\end{luacode}

\begin{document}
$\nabla{}f$ $\nabla f$ $\nabla h$ $\nabla k$
\end{document}


Addendum: If you also want to change the amount of whitespace between \partial and f, while keeping the instruction to change the distance between \nabla and f, I suggest you replace

   return ( s:gsub ( "\\nabla%s*f" , "\\nabla\\mkern-4mu f" ) )


with

   s = s:gsub ( "\\nabla%s*f" ,  "\\nabla\\mkern-4mu f" )
s = s:gsub ( "\\partial%s*f", "\\partial\\mkern-4mu f" )
return s


Of course, you can (and should) change the new instance of -4mu to whatever the optimal adjustment amount may be.

• so I guess this works for other things like \partial f by replacing nabla with partial? I am excited about this :) – weirdo Sep 8 '18 at 23:51
• @weirdo - Indeed, the code can be modified to allow further types of adjustments. I posted an addendum to show how this might be done for the case of \partial and f. – Mico Sep 9 '18 at 4:52
• works like a charm for me :) – weirdo Sep 9 '18 at 16:25