1

I was learning to draw a picture with tikz package.

When I view the dvi file the output is different. The horizontal lines are appearing slanted.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[step=1cm,gray,very thin] (-2,-2) grid (6,6);
\end{tikzpicture}
\begin{tikzpicture}
\draw[gray, thick] (-1,2) -- (2,-4);
\draw[gray, thick] (-1,-1) -- (2,2);
\filldraw[black] (0,0) circle (2pt) node[anchor=west] {Intersection point};
\end{tikzpicture}
\end{document}
1

What do you intend for slanted ?

Your lines go straight from the initial points to the end ones you indicated in the coordinates.

If you want vertical or horizontal lines, just change the coordinates, see the red lines below.

Moreover, put the grid and the lines in the same tikzpicture if you want they overlap.

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
    \draw[step=1cm,gray,very thin] (-2,-2) grid (6,6);
    \draw[gray, thick] (-1,2) -- (2,-4);
    \draw[gray, thick] (-1,-1) -- (2,2);
    \filldraw[black] (0,0) circle (2pt) node[anchor=west] {Intersection point};
    \draw[red, very thick] (-1,0) -- (4,0);
    \draw[red, very thick] (0,-1) -- (0,4);
    \filldraw[red] (0,0) circle (2pt) node[above right] {Intersection point};
    \end{tikzpicture}
\end{document}

enter image description here

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.