# Displaying vectors in picture environment

I wanted to graph three vectors in the picture environment of LaTeX. One vector $x$ is from the origin to the point (1,2), another vector $y$ is from the origin to the point (3,1), and the sum $x + y$ is from the origin to (4,3). The length of $x$ is \sqrt{5}, the length of $y$ is \sqrt{10}, and the length of $x + y$ is 5. So, the length of $x + y$ should be more than 2.2 times longer than the length of $x$ and the length of $x + y$ should be more than 1.5 times longer than the length of $y$. This is not depicted in the graph. The lengths of $x$ and $x + y$ appear to be the same.

I thought that maybe the horizontal axis may be scaled differently than the vertical axis. You can see that the length of the x-axis is the same as the length of the y-axis, and I set both the width and height to 100 (units). Does anybody have any comments about this? (I have used the TikZ package to display these vectors properly.) Is the picture environment in LaTeX really that bad?

Here is the code. (I multiplied the lengths of all three vectors by 10. So, the length of $x$ is not 2.236068, which is about \sqrt{5}, it is 22.36068, which is about 10\sqrt{5}.)

\setlength{\unitlength}{1mm}

\begin{picture}(100,100)

\put(0,10){\vector(1,0){100}}

\put(102,8){$x$}

\put(10,0){\vector(0,1){100}}

\put(12,98){$y$}

\put(10,10){\vector(1,2){22.36068}}

\put(10,10){\vector(3,1){31.622777}}

\put(10,10){\vector(4,3){50}}

\end{picture}
• \usepackage{pict2e} to allow any length
– user2478
Jul 3, 2014 at 18:33

The syntax of \vector and \line specifies that the length argument must be the horizontal distance, except for vertical lines, where it means the vertical distance. Thus, your picture should be:

\setlength{\unitlength}{1mm}

\begin{picture}(100,100)
\put(0,10){\vector(1,0){100}}
\put(102,8){$x$}
\put(10,0){\vector(0,1){100}}
\put(12,98){$y$}

\put(10,10){\vector(1,2){10}}% 10 by 20
\put(10,10){\vector(3,1){30}}% 30 by 10
\put(10,10){\vector(4,3){40}}% 40 by 30

\end{picture}

The use of package pict2e doesn't change this, but it does allow arbitrary length and arbitrary slopes.