I am familiar with graphs in tikz and I feel like I can do some work already. But how would one reproduce extended edges? I know how to create a simple graph with edges between its nodes, but how would one create a line that goes through some nodes?

Below I present what I am trying to achieve:

enter image description here

  • 2
    Depends. The left side looks different than the right side. You can do a lot with out and in. You could draw an arc at the end of straight lines. You could use straight edges with rounded corners. How should these lines look exactly? Can you provide the rest of the diagram? Nov 17, 2022 at 23:14
  • @Qrrbrbirlbel This is the diagram I want (there is no rest of it). I am sorry about my drawing skills! The left side and the right side looking different is not relevant (they can look the same). Ideally, the left side looks prettier than the right one, thus I believe both of the sides should look like the left one!
    – Rodrigo
    Nov 17, 2022 at 23:16
  • @Qrrbrbirlbel As for the lines, The blue ones must be straight (ideally of the same size on each side) and the gray ones must be curved! I am familiar with out and in but I have no idea how to apply it here (?)
    – Rodrigo
    Nov 17, 2022 at 23:17
  • Look into the calc library: \documentclass[tikz]{standalone} \usetikzlibrary{calc} \begin{document}\tikz{ \node[circle,fill] (A) at (0,0) {}; \node[circle,fill] (B) at (2,2) {}; \draw ($(A)!-1!(B)$) -- ($(A)!2!(B)$); }\end{document}. Explanation: ($(A)!0!(B)$) means "0% on the way from (A) to (B)" (which is at (A)), but you can also say "at 200% on the way from (A) to (B)" or even "at -100% on the way from (A) to (B)" to define coordinates that lie outside but are still on the thought line that goes through (A) and (B). Nov 17, 2022 at 23:18

2 Answers 2


Something like this perhaps:

\documentclass[tikz, border=10pt]{standalone}
\usetikzlibrary{calc, intersections}
            circle, fill, inner sep=2pt

\coordinate[coordinate, label={60:$p_1$}] (P1) at (-2.5,0.75);
\coordinate[coordinate, label={60:$p_2$}] (P2) at (-1.5,-0.75);
\coordinate[coordinate, label={120:$q_1$}] (Q1) at (2.5,0.75);
\coordinate[coordinate, label={120:$q_2$}] (Q2) at (1.5,-0.75);

\draw[name path=L1] ($(P1)!-0.5!(P2)$) node[above] {$l$} -- ($(P1)!3!(P2)$); 
\draw[name path=L2] ($(Q1)!-0.5!(Q2)$) node[above] {$l'$} -- ($(Q1)!3!(Q2)$); 

\coordinate[coordinate, gray, label={[gray]0:$z$}] (Z1) at ($(P1)!0.5!(P2)$);
\coordinate[coordinate, gray, label={[gray]180:$z$}] (Z2) at ($(Q1)!0.5!(Q2)$);

\node[name intersections={of=L1 and L2, by=Y}, coordinate, label={270:$y$}] at (Y) {};

\draw ($(P1)!-0.25!(Q1)$) -- ($(P1)!1.25!(Q1)$) node[above] {$\overline{p_{1}q_{1}}$}
      ($(P2)!-0.5!(Q2)$) -- ($(P2)!1.5!(Q2)$) node[below] {$\overline{p_{2}q_{2}}$};
\draw[gray] ($(P1)!1.25!(Q1)$) to[out=0, in=0] (Z2) to[out=0, in=0] ($(P2)!1.5!(Q2)$)
      ($(P2)!-0.5!(Q2)$) to[out=180, in=180] (Z1) to[out=180, in=180] ($(P1)!-0.25!(Q1)$);


enter image description here


Here is an alternative done with Metapost for comparison.

enter image description here

This was produced by compiling the following source with lualatex. I have included comments to try to explain the approach.

    % start with the two lines
    path ell, ell';
    ell = (20 down -- 144 up) rotated 32;
    ell' = ell reflectedabout(up, down);

    % draw them and label the intersection at the origin
    draw ell; draw ell';
    dotlabel.rt("$y$", origin);
    label.top("$\ell$", point 1 of ell);
    label.top("$\ell'$", point 1 of ell');

    % now define two sets of points along each line
    pair p[], q[];
    p1 = point 3/4 of ell;
    q1 = point 3/4 of ell';
    p2 = point 3/8 of ell;
    q2 = point 3/8 of ell';

    % p3, q3 are the midpoints
    p3 = 1/2[p1, p2];
    q3 = 1/2[q1, q2];

    % and now some points shifted off to the sides..
    p11 = p1 shifted 30 left;
    p12 = (xpart p11, ypart p2);
    p13 = (xpart p11, ypart p3);
    q11 = q1 shifted 40 right;
    q12 = (xpart q11, ypart q2);
    q13 = (xpart q11, ypart q3);

    % draw the loop through all these points using the "Hobby" syntax
    draw q12 {right} .. {left} q13 -- q3 -- q13 {right} .. {left} q11 --
         p11 {left} .. {right} p13 -- p3 -- p13 {left} .. {right} p12 --

    % note that drawing `q11 -- p11` goes through q1 and p1 
    % because of the way they were defined above, 

    % add the remaining labels
    label.ulft("$\overline{p_1 q_1}$", q11);
    label.ulft("$\overline{p_2 q_2}$", q12);
    dotlabel.llft("$p_1$", p1);
    dotlabel.llft("$p_2$", p2);
    dotlabel.lrt("$q_1$", q1);
    dotlabel.lrt("$q_2$", q2);
    dotlabel.rt("$z$", p3);
    dotlabel.lft("$z$", q3);


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .