[Tex/LaTex] Drawing a line between two points

diagrams

The LaTeX line requirements are too restrictive (coprime and mag < 6). Is there any package that lets me just draw a line between two points?

Basically

\line(a,b)(c,d)

or something similar

I went through all the trouble of calculating the points for my lines using the fp package and now I can't draw the lines I need?

I'm looking for a smooth line that uses the unit length and some way to set its thickness.

Best Answer

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (-3,-3) grid (3,3);
\draw (-2,2) -- (2,-3);
\end{tikzpicture}
\end{document}

Explanation

  1. Define a canvas. (-3,-3) is the bottom left corner and (3,3) is the top right corner.
  2. \draw (-2,2) -- (2,-3); draws a line from (-2,2) to (2,-3).
  3. Compile the code with pdflatex or xelatex or latex-dvips-ps2pdf.
  4. Done.

You can use \tikz{\draw (-2,2) -- (2,-3);} or \tikz\draw (-2,2) -- (2,-3); if you don't need tikzpicture.

Use the following to change the unit, put it anywhere before the \tikz or tikzpicture.

\tikzset
{
    x=2cm,% default value is 1cm.
    y=3cm,% default value is 1cm.
}

The last attempt:

\documentclass{article}
\usepackage{tikz}
\begin{document}
I want to draw a red line of thickness 1 mm, one unit in horizontal direction must be equal to 1.1 cm, and
one unit in vertical direction must be equal to 1.2 cm. Here is the line,
 \tikz[x=1.1cm,y=1.2cm]{\draw[line width=1mm,red](-1,1)--(1,-1);}, is it nice?
\end{document}

enter image description here