1

When writing the restriction of some function, sometimes the restriction area (the subscript) goes under the bottom of the vertical line (especially for the font package kpfont-otf I'm using).

enter image description here

Is there some way to ensure the subscript not to be lower than the bottom of the vertical line, or at lease raise it up a little bit?

Below is a MWE.

\documentclass{article}
\usepackage{kpfonts-otf}

% https://tex.stackexchange.com/questions/22252/ \newcommand\restr[2]{{% we make the whole thing an ordinary symbol \left.\kern-\nulldelimiterspace % automatically resize the bar with \right #1 % the function \littletaller % pretend it's a little taller at normal size \right|_{#2} % this is the delimiter }}

\newcommand{\littletaller}{\mathchoice{\vphantom{\big|}}{}{}{}}

\begin{document}

[ \restr{f}{U}=\frac{\restr{g}{U}}{\restr{h}{U}} ]

[ \restr{\frac{\partial}{\partial X_i}}{P} ]

\end{document}

Jinwen
  • 8,518
  • Subscripts are supposed to go below whatever they are subscripts for. You could use \raisebox to raise the subscript by \depth. Note that this will depend on the current style (\displaystyle, \textstyle, \scriptstyle or \scriptscriptstyle). – John Kormylo Oct 07 '22 at 14:39
  • @JohnKormylo Thank you for the suggestions. However I don't quite understand your meaning: 1) \raisebox would make the content in it in text style, so did you mean that one should manually add the $...$ and add \scriptstyle here? 2) Regarding \depth, what did you mean by "raise it by \depth"? – Jinwen Oct 07 '22 at 15:20
  • @JohnKormylo If I use \raisebox to raise the subscript, then there would still be some (now empty) vertical space under the subscript, which would lead to extra space in the upper part of \frac. – Jinwen Oct 07 '22 at 15:33

1 Answers1

1

If U is a subscript to the entire \left...\right group, it will be lowered below the vertical line, as explained by John Kormylo. But you can append another invisible math atom with the same depth as your formula and make U a subscript of that, then it will be lowered less.

The other math atom must be of type Close, because there is no space between a \left...\right group and a Close atom:

\newcommand\restr[2]{{% we make the whole thing an ordinary symbol
  \left.\kern-\nulldelimiterspace % automatically resize the bar with \right
  #1 % the function
  \littletaller % pretend it's a little taller at normal size
  \right|\mathclose{\vphantom{#1}}_{#2} % this is the delimiter
  }}

enter image description here

In kpfonts-otf the delimiters seem too small relative to the formula they enclose. You can force bigger delimiters with \delimiterfactor=1100 after the \begin{document}:

enter image description here

But this feels like a hack.

Further analysis

In the math formula \left.g\right| (without the \delimiterfactor hack), the vertical bar in kpfonts-otf is 1.25pt shorter than the one in Computer Modern. Moreover the Computer Modern bar is already centered w.r.t. to the math axis, whereas the kpfonts-otf bar must be raised by 1.925pt, amplifying the effect that it does not go low enough.

kpfonts-otf

\TU/KpMath-Regular.otf(1)/m/n/10 
\vbox(8.85+0.0)x3.09, shifted 1.925, direction TLT
.\hbox(7.13+1.72)x3.09, direction TLT
..\TU/KpMath-Regular.otf(1)/m/n/10 |

Computer Modern

\OML/cmm/m/it/10 g
\kern0.35878 (italic)
\hbox(7.5+2.5)x2.77779, direction TLT
.\OMS/cmsy/m/n/10 j
  • Thank you for this. However, it works fine for ComputerModern but strangely for kpfonts-otf it doesn't make any difference. – Jinwen Oct 07 '22 at 16:01
  • The right delimiter (the vertical bar) after the g seems not big enough in kpfonts-otf. According to rule 19 in appendix G of The TeXbook, it should be roughly twice as big as the depth of g below the math axis. – Heiko Theißen Oct 07 '22 at 16:47
  • See https://tex.stackexchange.com/a/660965/255231 – Heiko Theißen Oct 08 '22 at 15:30