# How to draw a line?

Here is a page that is US letter size, in landscape orientation. There is a single line going from (0,0) to (11in, 7.5in).

Is this possible to do in TeX?

Here is what I have so far:

\documentclass{article}
\usepackage[paperheight=11in,paperwidth=8.5in,margin=0cm]{geometry}
\usepackage{pdfpages}

\begin{document}
\begin{picture}(0,0)
\put(0,0){\line(3,-0.35){4}} % <-- I have no idea how this works
\end{picture}
\end{document}


I have no idea how the noted code line above works. But it does draw a line and for some reason it add text. Can I get this working so that it draws the required line?

• Switch to tikz instead of the picture env is it quite outdated. Tikz even come with a "smallish" manual. It has many examples on this site or if you google tikz example – daleif Apr 9 '20 at 14:36
• @WilliamEntriken US letter size is not 11in by 7.5in, is it a typo? – frougon Apr 9 '20 at 15:43

Regarding the \put(0,0){\line(3,-0.35){4}} inside the picture environment of your example, it is a failed attempt to draw a line of length 4 (expressed in terms of \unitlength) starting from point (0,0) and going in direction (3,-0.35). This can't work well, because:

• you haven't specified the value of \unitlength, thus you get the default of 1pt (combined with the other data, the line would be very short);

• the a and b used in \line(a,b){length} are limited to integers in the range [-6,6], so -0.35 is clearly out of question.

You can find more information about the picture environment on www.dickimaw-books.com, but you should already have realized that it is rather limited in features (it's a very old environment). Just before closing this chapter, the following example gives more sensible output:

\documentclass{article}

\begin{document}

\begin{picture}(0,0)
\setlength{\unitlength}{1cm}
\put(0,0){\line(5,-3){4}}
\end{picture}

\end{document}


Due to the limitations of the picture environment (the lines it can draw have a very limited number of slopes, as they come from glyphs of a special font), it is better here to use TikZ, as daleif suggested. Doing what you want is very easy using the current page node. See section Referencing the Current Page Node – Absolute Positioning in the TikZ and PGF manual for more details.

\documentclass[letterpaper,landscape]{article}
\usepackage{tikz}

\pagestyle{empty}               % don't print the page number

\begin{document}

\begin{tikzpicture}[remember picture, overlay]
\draw (current page.north west) -- (current page.south east);
\end{tikzpicture}

\end{document}


You need not to use large TikZ package for such trivial task. One \pdfliteral is sufficient. For example in OpTeX format:

\useoptex % OpTeX format

\margins/1 (11,7.5) (1,1,1,1)in % letter landscape, 1in margins
\pgbackground={\pdfliteral{q 1 w 0 0 m \_bp{\pdfpagewidth} -\_bp{\pdfpageheight} l S Q}}

\nopagenumbers \null % nothing to print

\bye