7

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.

Reinder
  • 81
  • You can use \rotatebox from graphicx or a drawing package such as tikz. – Andrew Swann May 14 '13 at 10:25
  • 1
    Welcome to TeX.sx Reinder! Feel free to visit our TeX.SX starter guide to get the most out of theis site. – Peter Jansson 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! – Reinder Nov 19 '13 at 12:51

2 Answers2

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

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

\end{document}

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

enter image description here

  • 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. – Reinder May 14 '13 at 10:23
  • 2
    \rotatebox{45}{$\xrightarrow{\makebox[2cm]{}}$} –  May 14 '13 at 10:28
6

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

enter image description here

\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}