Is there a way to make very short arrows?
I have:
\documentclass{article}
\usepackage{stmaryrd}
\begin{document}
$x_{i\shortrightarrow j}$
\end{document}
I want:
Thank's for all ideas and suggestions!
Is there a way to make very short arrows?
I have:
\documentclass{article}
\usepackage{stmaryrd}
\begin{document}
$x_{i\shortrightarrow j}$
\end{document}
I want:
Thank's for all ideas and suggestions!
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}
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}
\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
.
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}
\textstyle
.
Commented
Oct 7, 2017 at 22:10
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}