# Can I make an arrow of length x in latex?

I was making a quick graph in TexStudio, but I founnd I can not make an arrow of a length X. The only way I found to do what I want is this: Minimum length for \xrightarrow

In my opinion this is a workaround and it probably can be done neater/faster with a package of sort.

EDIT: The reason the quoted answer does not work for me is because I also need a diagonal arrow with length x.

• You can use \rotatebox from graphicx or a drawing package such as tikz. May 14 '13 at 10:25
• Welcome to TeX.sx Reinder! Feel free to visit our TeX.SX starter guide to get the most out of theis site. May 14 '13 at 10:26
• In conclusion: Can you make an arrow of length x in latex? Yes but it is not without restrictions and there is no special package or option to make it possible. For some things it is better to switch to a drawing program and use a picture. Thanks for the usefull help and comments! Nov 19 '13 at 12:51

\documentclass{article}
\usepackage{mathtools}
\begin{document}

$\xrightarrow{\makebox[2cm]{1}}$

\end{document}


change the fonts style for the 1 if you need it smaller.

• Your awnser does produce what I asked for, but in the same way as the answer I linked to. One of the problems is that it only works with the horizontal arrow and not a diagonal one. May 14 '13 at 10:23
• \rotatebox{45}{$\xrightarrow{\makebox[2cm]{}}$}
– user2478
May 14 '13 at 10:28

Something that someone regards as overkill may be regarded by other people as useful.

\documentclass[preview,border=12pt]{standalone}

\def\arrow#1{\pspicture[shift=2pt](#1,0)\psline{->}(#1,0)\endpspicture}

\usepackage{pstricks}
\begin{document}
$f:x \arrow{2} x^2$
\end{document}

• Very nice, this more or less what I meant. What about diagonal lines? May 15 '13 at 8:11
• Unfortunatly I get: Undefined control sequence \$f:x \arrow{2} May 15 '13 at 9:57