3

I want to crop \rightarrow so that the head remains but the tail is shorter. The reason I want a short-tailed rightarrow "\shortrightarrow" is because of my ultimate goal: to obtain a double headed arrow with the same width as the original.

In the source2e \rightarrow is defined as follows:

393 \DeclareMathSymbol{\rightarrow}{\mathrel}{symbols}{"21} 

RELATED: Arrow heads on \twoheadrightarrow

With a "\shortrightarrow" I can easily construct the desired double headed rightarrow with the same width as the original. (n.b. \twoheadrightarrow has too small arrow heads; the answer provided in the above RELATED link does not have the same width as the original \rightarrow)

I tried to investigate how \xrightarrow is defined in hopes of being able to modify the code so that I can obtain a short-tailed \rightarrow. Unfortunately I found that the code uses \cleaders to render multiple copies of \relbar, so my investigation ended.

Now I resort to asking the TeX community for advice. Is it possible to crop glyphs?

EDIT: I want to provide an example of how I managed to create a custom \hookrightarrow so that the width is the same as \rightarrow. My ultimate goal is motivated by my recent ability to define \inj. (inj is short for injection; the double headed arrow will be used for surjection 'surj')

\newcommand{\inj}{\mathrel{\mathpalette\inj@{}}}
\newcommand{\inj@}[2]{\sbox0{$\m@th#1\lhook$}\ooalign{%
  $\m@th#1\rightarrow$\cr
  \smash{\fboxrule=0pt\fboxsep=0pt\fcolorbox{red}{white}{$\m@th#1\lhook\kern-.333\wd0$}}}}
  • erh, what is wrong with \twoheadrightarrow (from amssymb)? Found it the comprehensive LaTeX symbol list – daleif Aug 28 at 10:36
  • 1
    @daleif The arrow heads are different. – egreg Aug 28 at 10:42
4

Use trimclip:

\documentclass{article}
\usepackage{amsmath,trimclip}

\makeatletter
\newcommand{\tworightarrow}{\mathrel{\text{\two@rightarrow}}}
\newcommand{\two@rightarrow}{%
  \sbox0{$\m@th\rightarrow$}%
  \smash{\rlap{\kern0.1\wd0 \clipbox{{.3\width} {-\height} 0pt {-\height}}{$\m@th\rightarrow$}}}%
  $\m@th\rightarrow$%
}

\setlength{\fboxsep}{0pt}\setlength{\fboxrule}{0.1pt}% just for the example

\begin{document}

\fbox{$\rightarrow$}

\fbox{$\tworightarrow$}

$a\rightarrow b$

$a\tworightarrow b$

$\tworightarrow \quad \scriptstyle \tworightarrow \quad \scriptscriptstyle \tworightarrow$

\end{document}

enter image description here

  • I recommend adjusting the clipbox's first argument to \clipbox{{.3\width} {-\height} 0pt {-\height}}. The difference is slight. – Alberto Takase Aug 28 at 12:04
  • @AlbertoTakase Thanks, you've eagle eye. – egreg Aug 28 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.