14

Is there a way to make very short arrows?

I have:

\documentclass{article}
\usepackage{stmaryrd}

\begin{document}
$x_{i\shortrightarrow j}$
\end{document}

arrow

I want:

arrow short

Thank's for all ideas and suggestions!

2

3 Answers 3

6

Here is a more light-weight approach. Two macros are defined, one for normal style, the other one for script style. In the latter case the \mathrel is dropped as it would have no effect. In the former case the \mathrel causes the thing to look a bit smallish compared to surrounding whitespace.

For the script thing, the optional parameter is the desired length before the ratio to normal size is taken into account, i.e. it should be normally the same as the one used for the normal size thing.

\documentclass{article}

\newcommand{\veryshortarrow}[1][3pt]{\mathrel{%
   \hbox{\rule[\dimexpr\fontdimen22\textfont2-.2pt\relax]{#1}{.4pt}}%
   \mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatletter

\setbox0\hbox{$\xdef\scriptratio{\strip@pt\dimexpr
    \numexpr(\sf@size*65536)/\f@size sp}$}

\newcommand{\scriptveryshortarrow}[1][3pt]{{%
    \hbox{\rule[\scriptratio\dimexpr\fontdimen22\textfont2-.2pt\relax]
               {\scriptratio\dimexpr#1\relax}{\scriptratio\dimexpr.4pt\relax}}%
   \mkern-4mu\hbox{\let\f@size\sf@size\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatother

\begin{document}

\[x-a\veryshortarrow b_{c\scriptveryshortarrow d-e}-f\]
\end{document}

enter image description here

The \mkern-4mu was obtained by trial and error.

Equivalent result is obtained via this little bit shorter code which employs \vcenter:

\documentclass{article}

\newcommand{\veryshortarrow}[1][3pt]{\mathrel{%
   \vcenter{\hbox{\rule[-.2pt]{#1}{.4pt}}}%
   \mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatletter

\setbox0\hbox{$\xdef\scriptratio{\strip@pt\dimexpr
    \numexpr(\sf@size*65536)/\f@size sp}$}

\newcommand{\scriptveryshortarrow}[1][3pt]{{%
    \vcenter{\hbox{\rule[\scriptratio\dimexpr-.2pt\relax]
               {\scriptratio\dimexpr#1\relax}{\scriptratio\dimexpr.4pt\relax}}}%
   \mkern-4mu\hbox{\let\f@size\sf@size\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatother

\begin{document}

\[x-a\veryshortarrow b_{c\scriptveryshortarrow d-e}-f\]
\end{document}

The \scriptveryshortarrow could use \mathrel. The sole effect (in script style for which it is destined) would be to suppress the small space separating from alarge symbol (\sum, \prod, ...) either immediately preceding or following.

The code for \scriptveryshortarrow can be simplified if one removes the two \scriptratio which scale the rule thickness and vertical shift for centering (the one scaling the width must stay).


A perhaps better choice for the thickness of the rule (rather than .4pt as above) is to use \fontdimen8 of the extension font.

\documentclass{article}

\newcommand{\veryshortarrow}[1][3pt]{\mathrel{%
   \vcenter{\hbox{\rule[-.5\fontdimen8\textfont3]{#1}{\fontdimen8\textfont3}}}%
   \mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatletter

\setbox0\hbox{$\xdef\scriptratio{\strip@pt\dimexpr
    \numexpr(\sf@size*65536)/\f@size sp}$}

\newcommand{\scriptveryshortarrow}[1][3pt]{\mathrel{%
    \vcenter{\hbox{\rule[-.5\fontdimen8\scriptfont3]
               {\scriptratio\dimexpr#1\relax}{\fontdimen8\scriptfont3}}}%
   \mkern-4mu\hbox{\let\f@size\sf@size\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatother

\begin{document}

\[x-a\veryshortarrow b_{c\scriptveryshortarrow\frac xy}-f\]
\end{document}

enter image description here

5
  • 1
    \mathrel doesn't add spaces in subscripts.
    – egreg
    Commented Oct 7, 2017 at 16:39
  • @egreg isn't it exactly what I say ?
    – user4686
    Commented Oct 7, 2017 at 18:02
  • 1
    What I say is that you don't need to drop \mathrel.
    – egreg
    Commented Oct 7, 2017 at 18:03
  • why would I not drop it if it serves nothing?
    – user4686
    Commented Oct 7, 2017 at 18:04
  • 2
    @egreg it does serve indeed to something if followed by a \mathop class object. A \mathrel followed by \mathop in scriptstyle will induce no spacing, but a \mathord followed by \mathop will. Omitting the \mathrel in the definition means it acts as \mathord in scriptstyle, hence some spacing. x_{a\myscriptarrow\sum b}. Both with \sum and \prod, I find the no spacing version a bit better. So perhaps indeed I should have left the \mathrel.
    – user4686
    Commented Oct 7, 2017 at 21:26
7

If you like the arrow in stmaryrd, you can clip it.

\documentclass{article}
\usepackage{stmaryrd}
\usepackage{trimclip}

\makeatletter
\DeclareRobustCommand{\shortto}{%
  \mathrel{\mathpalette\short@to\relax}%
}

\newcommand{\short@to}[2]{%
  \mkern2mu
  \clipbox{{.5\width} 0 0 0}{$\m@th#1\vphantom{+}{\shortrightarrow}$}%
  }
\makeatother

\begin{document}

$a\shortto b_{c\shortto d}$

\end{document}

enter image description here

2
  • My only thought is that the short arrow needs shorter sidebearings...looks way to spaced out in \textstyle. Commented Oct 7, 2017 at 22:10
  • @StevenB.Segletes That's something left to the OP's preference; but I believe the main usage is in subscripts anyway.
    – egreg
    Commented Oct 7, 2017 at 22:12
1

CarLaTeX' link provided the answer! Thanks a lot! I've modified the solution a bit, see the result below.

(Sorry to everybody who feels hurt by the crude way I've adapted spacing and scaling).

\documentclass{article}
\usepackage{pict2e,picture,graphicx}

\makeatletter
\DeclareRobustCommand{\Arrow}[1][]{%
\check@mathfonts
\if\relax\detokenize{#1}\relax
\settowidth{\dimen@}{$\m@th\rightarrow$}%
\else
\setlength{\dimen@}{#1}%
\fi
\sbox\z@{\usefont{U}{lasy}{m}{n}\symbol{41}}%
\begin{picture}(\dimen@,\ht\z@)
\roundcap
\put(\dimexpr\[email protected]\wd\z@,0){\usebox\z@}
\put(0,\fontdimen22\textfont2){\line(1,0){\dimen@}}
\end{picture}%
}
\makeatother
\newcommand{\veryshortrightarrow}{\hspace{.2mm}\scalebox{.8}{\Arrow[.1cm]}\hspace{.2mm}}

\begin{document}
    $x_{i\veryshortrightarrow j}$
\end{document}

enter image description here

2
  • 1
    +1 but this will be same size whether subscript or not
    – user4686
    Commented Oct 7, 2017 at 13:57
  • @jfbu Yes, can confirm that. It is no problem in my case. Certainly, it is not an elegant solution.
    – Felix
    Commented Oct 7, 2017 at 14:01

You must log in to answer this question.

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