# Long arrow composed of line segment and shorter arrow

Consider the following code from egreg:

\documentclass{article}

\newcommand{\strutarrow}[2]{%
\vrule width 0pt height 2\fontdimen22
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi 2
{#2}%
}
\newcommand{\srightarrow}{%
\mathrel{\mathpalette\strutarrow\longrightarrow}%
}

\begin{document}

\fbox{$\srightarrow$}

\end{document}


As can be seen, the long arrow is composed of line segment and shorter arrow.

How do I "fix" this so that there isn't a dent in the arrow?

• the default overlap is \DeclareRobustCommand\joinrel{\mathrel{\mkern-3mu}} you could redefine it to be -4mu and have more overlap and a slightly shorter arrow or use a font that has long arrows that don't need building up like: → ⟶ – David Carlisle Jan 17 '18 at 18:56
• The code for the strut has nothing to do with this. Try with just \longrightarrow, but it's only a question of font hinting. – egreg Jan 17 '18 at 21:09

The \longrightarrow is defined as

\def\longrightarrow{\relbar\joinrel\rightarrow}


You can correct the flaw mentioned above for example by this:

\def\longrightarrow{\relbar\joinrel\mkern-1mu\rightarrow}


Note that the problem has nothing in common with the code mentioned in your question. The code only adds the invisible strut (depending on the math style).

You can add a small negative space using the \! macro. Inserting it before #2 seems to fix the issue:

\documentclass{article}

\newcommand{\strutarrow}[2]{%
\vrule width 0pt height 2\fontdimen22
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi 2
\!{#2}%
}
\newcommand{\srightarrow}{%
\mathrel{\mathpalette\strutarrow\longrightarrow}%
}

\begin{document}
\fbox{$\srightarrow$}
\end{document}

• This cannot help because \! is inserted between strut and \longrightarrow. But the problem is in \longrightarrow. – wipet Jan 17 '18 at 19:55