# Problem with drawing a straight line using the picture environment in LaTeX

I am new to learning LaTeX, and I am using WinEdt 10 as the editor. I have an encountered a problem when trying to draw a right angle triangle of sides 40,30 and 50.

I am using picture environment for this exercise. So, I start off at the origin, and make a straight line of length 40. From there (i.e. the point (40,0)) I construct another line, perpendicular to this, of length 30. Now, to join the origin with the point (40,30), I draw a line along the vector (4,3), of length 50. This is where the trouble comes. The line of length 50 is too long to make the hypotenuse, while it is perfect when I make the length 40. I can't seem to understand why that is.

Here is the syntax I use :

\documentclass{article}
\begin{document}
\begin{picture}(250,75)
\put(0,0){\line(1,0){40}}
\put(40,0){\line(0,1){30}}
\put(0,0){\line(4,3){40}}
\end{picture}
\end{document}


Here is the output when the length is put to 40.

Here is the output when I put the length as 50.

from info latex2e

Synopsis:

 \line(X_RUN,Y_RISE){TRAVEL}


Draw a line. It slopes such that it vertically rises Y_RISE for every horizontal X_RUN. The TRAVEL is the total horizontal change -- it is not the length of the vector, it is the change in x. In the special case of vertical lines, where (X_RUN,Y_RISE)=(0,1), the TRAVEL gives the change in y.

Also, you should consider what you are really getting, when using the LaTeX picture environment. Zoom in and examine the output. The slanted "line" is actually a sequence of overlapping LINE10 font characters, chosen to simulate the required slope.

You are better off using any of a number of other packages which can do line graphics in a much better way, based upon using PostScript or PDF graphic elements.

E.g. with \usepackage[pdf,graph,frame]{xy} look at each of these 1-liners:

\xygraph{ []="O" - [r(4)] - [u(3)] - "O" }

\xygraph{ !{/r5mm/:} []="O" - [r(4)] - [u(3)] - "O" }  % 1 unit = 5mm

\xygraph{ !{/r5mm/:} []="O" - [r(4)]_{40} - [u(3)]_{30} - "O"_{50} }

\xygraph{ !{/r5mm/:} []="O" *+!UR=0{A} - [r(4)]*+!UL=0{B} - [u(3)]*+!DL=0{C} - "O" }

\xygraph{ !{/r5mm/:} []="O" *+!UR[Fo]=0{A} : [r(4)]*+!UL[Fo]=0{B}_{40} : [u(3)]*+!DL[Fo]=0{C}_{30} : "O"_{50}
}

• A good compromise could be the pict2e package, that marries simplicity (you can use it without having to learn a new syntax, since it understands perfectly well code written for the picture environment) with accurate output that exploits PDF primitives, without recourse to superimposition of characters.
– GuM
Sep 1, 2019 at 1:03