2

I would like the arrows created by \textleftarrow and \textrightarrow to be 50% and 75% shorter, while leaving the arrow head the same size. I'm using it in a non-math environment; just normal text.

I have consulted the following posts to no avail, because they all seem to be math-based:

AML
  • 2,265
  • What prevents you from using a math-based solution and wrapping it into \ensuremath{...}? –  Mar 04 '19 at 19:15
  • The arrow produced by \ensuremath{\rightarrow} looks the same as \textrightarrow. I don't see in those examples how to shorten it in combination with \ensuremath. – AML Mar 04 '19 at 19:41
  • What I meant is `\documentclass{article}

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

    \begin{document}

    a\veryshortarrow b \end{document}`

    –  Mar 04 '19 at 19:47
  • It's got potential. Thank you. Looking for the arrow head to be the same size and also a left arrow. – AML Mar 04 '19 at 19:59

1 Answers1

2

You can use the trimclip package for this.

enter image description here

The clipbox* command removes portions of your text outside the box specified by 4 coordinates:

\clipbox*{{.25\width} 0pt {\width} {\height}} \textrightarrow

will leave the right 75% of the arrow. Similarly,

\clipbox*{0pt 0pt {.75\width} {\height}} \textleftarrow

will leave the left 75% of the arrow. Adjust as desired.

Here's the code:

%XeLaTeX
\documentclass[11pt]{book}
\usepackage{polyglossia}
\usepackage{trimclip}

\newcommand{\shorttextrightarrow}{\clipbox*{{.25\width} 0pt {\width} {\height}} \textrightarrow}
\newcommand{\shorttextleftarrow}{\clipbox*{0pt 0pt {.75\width} {\height}} \textleftarrow}

\begin{document}

Why \textrightarrow\ can't I figure this out \textleftarrow ?

Why \shorttextrightarrow\ can't I figure this out \shorttextleftarrow ?

\end{document}
Sandy G
  • 42,558