6

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.

3
  • You can use \rotatebox from graphicx or a drawing package such as tikz. 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. 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
6
\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

2
  • 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]{}}$}
    – user2478
    May 14 '13 at 10:28
5

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

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.