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.

  • 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

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

        to path=%
        -- ($(\tikztotarget)!($(\tikztostart)!#1!90:(\tikztotarget)$)!90:(\tikztostart)$)


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

yielded the right result.

enter image description here

  • It is simpler to specify the end of the parallel path as ($(\tikztotarget)!#1!270:(\tikztostart)$) – Andrew Swann Jun 5 '13 at 12:11

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.