# Polyglossia and hookrightarrow

Can someone explain why there is a gap between the tail and the head of \hookrightarrow when I load polyglossia with French support ? I'm using LuaLaTeX for producing the .pdf.

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\begin{document}

\Huge $\hookrightarrow$
\end{document}


Here is the output:

Thank you.

• For me it works when using babel instead of polyglossia, so if that’s a compromise you’re willing to do, go for it. – user74027 Mar 22 '15 at 15:52
• french treats punctuation differently -- adds space(s) around some punctuation marks. \lhook (the leftmost piece of \hookrightarrow) has the misfortune to be defined (in fontmath.ltx) as \DeclareMathSymbol{\lhook}{\mathrel}{letters}{"2C}, and "2C is in the same location as a comma in a text font. how to fix it? don't know ... – barbara beeton Mar 22 '15 at 16:02
• @DavidCarlisle -- that may not be the cause (and egreg has just identified the actual cause), but the coincidence was just too great to ignore, and led to a truly delightfully devious workaround. so i'm not displeased with my conjecture. – barbara beeton Mar 22 '15 at 16:39
• @barbarabeeton yes I deleted my comment (and unfortunately had to vote for egreg:( – David Carlisle Mar 22 '15 at 16:41
• I opened an issue at GitHub: github.com/reutenauer/polyglossia/issues/92 – egreg Mar 22 '15 at 17:16

The callback used by LuaTeX for inserting the penalties and spaces after punctuation should be disabled in math mode, but apparently it isn't.

Workaround until a fix is shipped out:

\documentclass{article}
\usepackage{ifluatex}

\usepackage{polyglossia}
\setdefaultlanguage{french}

\ifluatex
\makeatletter
\let\latex@lhook\lhook
\renewrobustcmd{\lhook}{%
\mathrel{\mathpalette\do@lhook\relax}%
}
\newcommand{\do@lhook}[2]{%
\hbox{\directlua{polyglossia.desactivate_frpt()}$\m@th#1\latex@lhook$}%
}
\makeatother
\fi

\begin{document}

$\hookrightarrow$

\end{document}


Of course this won't be necessary if unicode-math is used.

The problem, as hinted by Barbara Beeton (but not getting the real problem), is that the right arrow happens to occupy the position of exclamation mark in the ASCII code, so LuaTeX blindly applies the penalty and spacing also before it as if it were in text.

The same problem could arise for other math symbols sharing their code point with punctuation symbols.

The characters involved for the OML encoding are

• \lhook in the position of ,
• \omega in the position of !
• the period in the position of :
• \star in the position of ?
• the comma, in the position of ;
• > in the same position as itself.

However, only \lhook and \omega seem to be affected; more tests with different character combinations should be performed.

In the OMS encoding we have

• \Leftrightarrow in the position of ,
• \rightarrow in the position of !
• \lnot in the position of :
• \bot in the position of ?
• \emptyset in the position of ;
• \top in the position of >

Curiously enough, here \rightarrow, \lnot, \bot and \emptyset are affected.

Here's the output of

X${\lhook}{\omega}{.}{\star}{,}{>} {\Leftrightarrow}{\rightarrow}{\lnot}{\bot}{\emptyset}{\top}$X

\selectlanguage{english}

X${\lhook}{\omega}{.}{\star}{,}{>} {\Leftrightarrow}{\rightarrow}{\lnot}{\bot}{\emptyset}{\top}$X


used for making the comparison

I'm quite afraid to see what happens with the OMX encoding: I guess that

• \mapsto is also problematic. – BigDawg Mar 22 '15 at 20:37
• @BigDawg I came to the conclusion that \rightarrow is the culprit in \hookrightarrow and not \lhook. But the principle is the same. And this explains \mapsto that has \rightarrow in it. – egreg Mar 22 '15 at 23:29
• I know this answer is years old, but I ran into this (actually for \mapsto), and this workaround seems to desactivate french spacing in all document. So, what I did is \renewcommand{\mapsto}{\mathrel{\mathord{\mapstochar}\mathord{\rightarrow}}}. But let us be honest: I have no idea what I'm doing and this is probably not the right way. – Armand Koenig Apr 4 at 15:17
• @ArmandKoenig Oh, that's possible. Support for French has changed quite a lot, in the past years. – egreg Apr 4 at 15:46

Here is a nasty fix following barbara beeton's comment, if someone has better...

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\setotherlanguage{english}
\begin{document}

\Huge \begin{english}$\hookrightarrow$\end{english}$\hookrightarrow$
\end{document}

• definitely evil! (good idea, though.) – barbara beeton Mar 22 '15 at 16:26