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.

Assume that we have two coordinates (a) and (b). I want to draw a line which is a parallel translation of the line which connects (a) and (b).

I would like to have something like \drawparallel{a}{b}{dist} which will draw a line parallel to the one connecting (a) and (b) at (signed!) distance dist.

I tried many things both based on \newcommand and on \tikzset but could not make it work.

Edit: To make it clearer, I want the the four points (two of the original line segment, and two of its translated copy) will form a rectangle.

share|improve this question
    
What's parallel? Is \draw ([xshit=dist]a)--([xhsift=dist]b); enough? –  Ignasi May 31 '13 at 10:52
    
@Ignasi: Actually no. With your solution the four points (two of the original curve and two of the translated one) form (in general) a parallelogram. I want them to form a rectangle. –  Dror May 31 '13 at 11:35
2  
You can use this one but without the connecting lines tex.stackexchange.com/questions/55068/… –  percusse May 31 '13 at 11:57
add comment

1 Answer

up vote 3 down vote accepted

Indeed, as pointed out by @percusse, Jake's answer solved my problem. In particular, I added the following

\tikzset{
      ncbar/.style={
        to path=%
        ($(\tikztostart)!#1!90:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!90:(\tikztotarget)$)!90:(\tikztostart)$)
      },
      ncbar/.default=0.5cm,
    }

Then,

\draw (a) -- (b);
\draw (a) to[ncbar=1] (b);

yielded the right result.

enter image description here

share|improve this answer
    
It is simpler to specify the end of the parallel path as ($(\tikztotarget)!#1!270:(\tikztostart)$) –  Andrew Swann Jun 5 '13 at 12:11
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.