Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the added minimal example, I was expecting it to generate two parallel lines. The ending result however is that the second line start at the end of the first in what I assume is the relative angle. I have no idea how the length is determined. I've also attached a figure of my results. So, as the title ask. Why won't this two line be parallel?

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}

\begin{figure}
  \begin{tikzpicture}
    \draw  (-1.5,-0.1) -- (51:1.9);
    \draw  (1.5,-0.1) -- (51:1.9);
    \node at (-1.5,-0.1) {a};
  \end{tikzpicture}
\end{figure}


\end{document}

The output of the simple code

enter image description here

share|improve this question
    
The director vector is not the same so they are not parallel. –  Sigur Jul 21 '13 at 15:41
    
I'd need to read up on tikz' coordinate systems... going by the picture, is (51:1.9) polar w.r.t. origin? (It sounds like you want polar w.r.t. the current position.) –  Ulrich Schwarz Jul 21 '13 at 15:42
2  
Oh now I get it. You need to put a + sign before the end point to make it relative as in +(51:1.9) –  percusse Jul 21 '13 at 15:46
    
Be careful. Since the point a is not the origin, the vector (51:1.9) is not the director vector to the line. –  Sigur Jul 21 '13 at 15:48
    
@Sigur, I've placed point a just so we'll have an easy point to discuss. –  Yotam Jul 21 '13 at 19:52
add comment

1 Answer

up vote 9 down vote accepted

Remarks

Regrading your Question

Note the leading + in front of the target coordinates. To receive parallel lines you have to draw a line relative the the start point. Without the +-sign you specify absolute coordinates with respect to the origin (0,0).

Regarding Relative Coordinates

In a path you can specify relative coordinates in several manners. Let's draw a simple rectangle.

Using explicit coordinates

The simplest way using the rectangle macro.

\draw (0,0) rectangle (1,1);

Using a line to connect the edges:

\draw (0,0) -- (1,0) -- (1,1) -- (0,1) --cycle;

Using relative coordinates

With the rectangle macro:

\draw (0,0) rectangle +(1,1);

Using a line to connect the edges: Point preceeded by a single + are always relative to the previous declared point on the path and the pen is returned to the previous point

\draw (0,0) -- +(1,0) -- +(1,1) -- +(0,1) --cycle;

while points with two ++ are still relative the previous point on the path but the pen stays on the resulting point relative to the previous point

\draw (0,0) -- ++(1,0) -- ++(0,1) -- ++(0,-1) --cycle;

More about relative coordinates

If you want to learn more about relative coordinates, review section 2.15 of the current pgfmanual.

Implementation

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
        \draw (-1.5,-0.1) -- +(51:1.9);
        \draw (1.5,-0.1)  -- +(51:1.9);
        \node at (-1.5,-0.1) {a};
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
Nice answer. You may like to add some information about the ++ syntax ... –  Tobi Jul 21 '13 at 19:52
1  
included a small clarification, I hope you don't mind. –  percusse Jul 21 '13 at 20:29
    
@percusse Thanks for your improvements. You are always welcome! –  Henri Menke Jul 21 '13 at 20:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.