5
$\sigma_{ij} = \rho\sigma_{i}\sigma_{j}$

enter image description here

Is it just me, or does the spacing look wrong on the right-hand side? The subscripts seem to be too far to the right.

Is there a way to move the subscripts closer, like they are on the left side? Or maybe the spacing looks fine and my eyes play a trick on me? I'm using LuaLaTeX with the Lucida Bright fonts.

Thanks for helping!

  • I have give an answer with nice results in similar problem here: tex.stackexchange.com/questions/396528/…. If it solves your problem tell us to mark the question as a duplicate... – koleygr Jul 5 '18 at 14:42
  • It looks like you're using a Times Roman math font. If this impression is correct, which math font do you employ? – Mico Jul 5 '18 at 14:43
  • @Mico I'm using LucidaBrightMathOT, I got the font from TUG a while ago: tug.org/store/lucida/opentype.html – Florian Jul 5 '18 at 14:47
  • opentypemath setting is still very experimental luatex has some settings.. try values of \mathoption noitaliccompensation` I don't have the font to test – David Carlisle Jul 5 '18 at 14:57
  • With XeLaTeX the output is correct. – egreg Jul 5 '18 at 20:40
6

I think this is a bug in LuaTeX. Curiously, if you add an empty atom to the subscript, the kerning is correct.

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}

\setmainfont{Lucida Bright OT}
\setmathfont{Lucida Bright Math OT}

\begin{document}

$\sigma_{ij}=\sigma_{i}\sigma_{j}$ (original)

$\sigma_{ij}=\sigma_{i{}}\sigma_{j{}}$ (with phantoms)

\end{document}

enter image description here

For comparison, this is the output with XeLaTeX

enter image description here

Note: apparently LuaTeX 1.09 has fixed the issue, but TeX Live 2018 is bound to LuaTeX 1.07.

  • I see a similar spacing issue for \[ T_{\text{feed}} \] under LuaLaTeX + Lucida, but not under XeLaTeX + Lucida (nor under pdfTeX). However, it is not corrected by phantoms as for the above. Is it known whether LuaTeX 1.09 covers this issue also? – John Jul 5 '18 at 22:18
  • 1
    @John Sorry, no idea. I can't run 1.09; it was Ulrike Fischer who did the experiments. – egreg Jul 5 '18 at 22:21
4

You can add a small negative mu space (f.y.i., a thinspace: \, is 3mu):

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[ \sigma_{ij} = \rho\sigma_{\mkern-1 mu i}\sigma_{\mkern-1mu j}
 \]%

\end{document} 

enter image description here

  • Thanks, that looks better, I'll use that if there is no way to correct the spacing document wide. – Florian Jul 5 '18 at 14:49
2

This is a problem of kerning. You could borrow the subscriptcorrection code from the newtxmath package, which I believe is inspired by that from the mtpro2 package.

Edited: The following code makes the kerning automatic, so you don’t need to add negative spaces each time a “bad-looking” subscript occurs. Since the code is taken from newtxmath, the kerning instructions are designed for Times. You might need to make adjustments for Lucida.

\makeatletter
% Enable subscript correction
\AtBeginDocument{\mathcode`\_=\string"8000 \catcode`\_=12\relax}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subscript correction code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begingroup
 \catcode`\_=13
 \gdef_{\futurelet\next\s@@b}
\endgroup
\def\s@@b{\ifcat\relax\noexpand\next\expandafter\sb\else
 \expandafter\s@@b@\fi}
\def\s@@b@#1{\sb{\futurelet\next\sb@#1}}
\def\sb@{%
 \ifx\next\space@\def\next@. {\futurelet\next\sb@}\else
  \def\next@.{%
   \ifx\next f\mkern-\tw@ mu\else
   \ifx\next j\mkern-\tw@ mu\else
   \ifx\next p\mkern-\@ne mu\else
   %\ifx\next t\mkern\@ne mu\else
   \ifx\next y\mkern-\@ne mu\else
   \ifx\next A\mkern-\tw@ mu\else
   \ifx\next B\mkern-\@ne mu\else
   \ifx\next D\mkern-\@ne mu\else
   \ifx\next H\mkern-\@ne mu\else
   \ifx\next I\mkern-\@ne mu\else
   \ifx\next K\mkern-\@ne mu\else
   \ifx\next L\mkern-\@ne mu\else
   \ifx\next M\mkern-\@ne mu\else
   \ifx\next N\mkern-0.5mu\else
   \ifx\next P\mkern-\@ne mu\else
   \ifx\next X\mkern-\@ne mu\else
   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}%
 \fi
 \next@.} 
\makeatother

You may adjust the \@ne, \tw@ and 0.5 to your use of font for LucidaBrightMathOT, which are completely subjective as they are problems of graphic design.

Added: If you wish to add new kerning instruction, for instance for $\sigma_i$, then insert \ifx\next i\mkern-<number>mu\else before the \ifx\next j\mkern-\tw@ mu\else line, and add one more \fi to that sequence of repeated \fi’s. Common choices for <number> are 1, 2 and 3.

Also, notice that newtxmath commented out the kerning instruction for $_t$: %\ifx\next t\mkern\@ne mu\else.

  • Thanks! This improves the j subscript, I'll try adjusting the parameters to get the i right. – Florian Jul 5 '18 at 19:18
  • @Florian I added some instructions to help with the kerning of $_i$. :) – Ruixi Zhang Jul 5 '18 at 20:28

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.