4

The extensible arrows from amsmath/mathtools do not give proper spacing or symbols when used with kpfonts. Here's the correct behavior with Computer Modern.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{align*}
    X &\rightarrow Y & X &\hookrightarrow Y & X &\mapsto Y \\
    X &\xrightarrow{} Y & X &\xhookrightarrow{} Y & X &\xmapsto{} Y
\end{align*}

\end{document}

correct_computer-modern

The spacing and symbols of the extensible arrows with no label are identical to their non-extensible counterparts, as expected.

When kpfonts is loaded, the spacing and symbols change.

\documentclass{article}
\usepackage{mathtools,kpfonts}

\begin{document}

\begin{align*}
    X &\rightarrow Y & X &\hookrightarrow Y & X &\mapsto Y \\
    X &\xrightarrow{} Y & X &\xhookrightarrow{} Y & X &\xmapsto{} Y
\end{align*}

\end{document}

incorrect_kpfonts

All three arrows appear to shift to the left, which causes both the hook in \xhookrightarrow and the vertical bar in \xmapsto to be in the wrong spot.

Note also that \hookrightarrow looks bad to begin with. Not sure if this is new, or if this issue was never fixed.

Why is this happening, and is it an issue I should report to mathtools or to kpfonts?

2
  • 1
    The issue appears never to have been fixed, even though he sent a preliminary update to me which I was using for some years. The kpfonts package has received updates on CTAN several times since, so I assume that the developer must have simply forgotten about it.
    – Gaussler
    Commented Dec 5, 2022 at 18:47
  • @Gaussler From the change log it seems Herbert Voß is the new maintainer? Perhaps the fix for \hookrightarrow could be sent to him
    – mbert
    Commented Dec 5, 2022 at 18:52

1 Answer 1

2

There are two problems:

  1. amsmath makes a few assumptions on the math symbols, which don't hold for kpfonts;

  2. the \lhook symbol in kpfonts is badly designed.

For problem 1 we can patch \arrow@fill to reduce the negative kerns at either end. For problem 2, we can borrow the \lhook symbol from libertinust1math.

\documentclass[twocolumn]{article}
\usepackage{mathtools,kpfonts}

\makeatletter % change \mkern-7mu into \mkern-4mu
\def\arrowfill@#1#2#3#4{%
  $\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
   \relax#4#1\mkern-4mu%
   \cleaders\hbox{$#4\mkern-2mu#2\mkern-2mu$}\hfill
   \mkern-4mu#3$%
}
\makeatother

%%% borrow \lhook and \rhook from libertinust1math
\makeatletter
\DeclareFontEncoding{LS2}{}{\noaccents@}
\makeatother
\DeclareFontSubstitution{LS2}{libertinust1mathex}{m}{n}
\DeclareSymbolFont{libsymbols}{LS2}{libertinust1mathsym}{m}{n}
\DeclareMathSymbol{\lhook}{\mathrel}{libsymbols}{"41}
\DeclareMathSymbol{\rhook}{\mathrel}{libsymbols}{"42}

\begin{document}

\begin{align*}
  X &\rightarrow Y &\quad X &\hookrightarrow Y & X &\mapsto Y \\
  X &\xrightarrow{} Y & X &\xhookrightarrow{} Y & X &\xmapsto{} Y
\end{align*}

\begin{equation*}
X\xrightarrow{abcde}
X\xhookrightarrow{abcde}
X\xmapsto{abcde} X
\end{equation*}

\end{document}

Of course, \xrightarrow{} and the other arrows will not be as wide as the nonextensible companions. I don't think one can do much about this, apart from using the x arrows only when needed.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .