2

I'd like to create a command which solves ''globally'' the following question: as shown in the picture below, when the glyph ''f'' appears in math-mode, though the horizontal position of the supscripts is cool, the subscipts' one is not. So, I'd like to use either something as \ifx\first (et al.) commands or changing the fontdimen's in order to get the horizontal position of the subscript closer to the ''f''.

Notice that the italic correction already applies, and mostly I want to get this result only for the glyph ''f''. ''Globally'' means that I want to get the result when I write e.g. $f^\ast_\ast$ without other commands. For this latter topic, I saw that in the mtpro2 package a similar solution has been applied for sub and supscripts in general, i.e., globally, but I'm not able to adapt it to the present case.

enter image description here

  • Please tell us which math font family you use. E.g., is it Computer Modern, Latin Modern, or something else? (The screenshot doesn't suggest either Computer Modern or Latin Modern.) If you were using the newtxmath math font package, you probably wouldn't need any further subscript correction. Also, just how closely do you want to "snug up" the subscript asterisk to the letter f? – Mico Sep 3 '18 at 15:32
  • Please also advise if you're free to use LuaLaTeX. – Mico Sep 3 '18 at 16:08
  • @Mico Deat Mico, too badly I'm a... plainTeX user (btw I shall use the font also in LaTeX)! The font I've shown is home-made in the sense that it comes from the times and has been built with FontForge. Its encoding is the one of the computer modern. The tfm's parameters contain also the italic correction, as announced above. – Martino Sep 4 '18 at 8:15
1

If you're free to use LuaLaTeX, the following solution should be of interest to you.

Note that the kerning adjustment between f and the subscript-* depends importantly on the math font that's in use. For instance, if you use Computer Modern Math, Latin Modern Math, or XITS Math, a kerning adjustment of -3mu -- equivalent to a negative thinspace -- look about right for asterisks, while -2mu looks about right for lowercase-letter subscripts. But if you use newtxmath font package, a kerning adjustment of just -1.5mu (or half a negative thinspace) suffices.

enter image description here

% !TEX TS-program = lualatex
\documentclass{article}

%% Uncomment one or the other of the next two lines to get a Times Roman clone math font
%\usepackage{newtxmath}\usepackage[no-math]{fontspec}
%\usepackage{unicode-math}\setmathfont{XITS Math}

\usepackage{luacode}
\begin{luacode}
function f_sub ( s )
  s = s:gsub ("(f.-)_{(.*)}"  ,"%1_{\\mkern-3mu %2}")
  s = s:gsub ("(f.-)_(\\ast)" ,"%1_{\\mkern-3mu %2}")
  return s
end
\end{luacode}

%% Two LaTeX macros to switch Lua function on and off:
\newcommand\fsubOn{\directlua{luatexbase.add_to_callback
    ( "process_input_buffer", f_sub , "f_sub" )}}
\newcommand\fsubOff{\directlua{luatexbase.remove_from_callback
    ( "process_input_buffer", "f_sub" )}}

\begin{document}
\fsubOn  % switch on the Lua function

$f^\ast_\ast$ $f_\ast$ $f_{n}$ --- with kerning adjustment

\fsubOff % switch off the Lua function

$f^\ast_\ast$ $f_\ast$ $f_{n}$ --- without kerning adjustment
\end{document} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.