I have drawn two shapes in the code below, a red curve, and a black rectangle. I have labeled four points, A, B, C and D. I would like to know how to draw a path along the black rectangle from A to B, along the red curve from B to C, and then back along the black rectangle from C to D back to A. I should mention that I would ultimately like to fill the region enclosed by this shape ABCD.




\draw[name path=p0] (0,.8) node[above left] {$D$} -- ++(3,0) |- (0,2) node[above left] {$A$} -- cycle;

\draw[red,name path=p2] (.2,3) .. controls (.5,3) and (3,.2) .. (3.5,.2);

\fill[name intersections={of=p0 and p2}] (intersection-1) circle (2pt) node[below left] {$C$} (intersection-2) circle (2pt) node[above left] {$B$};


  • 1
    Something like this: tex.stackexchange.com/questions/119809/… – dustin Aug 8 '13 at 16:58
  • I should clarify that I would like to draw the shape, and also fill it with a color. So, I'm not sure that would allow me to do that. I have changed the question slightly to reflect that. – profj Aug 8 '13 at 17:02

Standard solution would be using the let ... in syntax. But this is not suitable for the cases where the followed paths are more complicated. Then you need more esoteric options such decorating the path with nodes etc. that are not that simple to automate as the following.


\draw[name path=p0] (0,.8) coordinate (D) node[above left] {$D$} -- ++(3,0)
     |- (0,2) coordinate (A) node[above left] {$A$} -- cycle;
\draw[red,name path=p2] (2.5,2) circle (1.5cm);
\fill[name intersections={of=p0 and p2}] (intersection-1) circle (2pt) coordinate (C) 
     node[below left] {$C$} (intersection-2) circle (2pt) coordinate (B)  node[above left] {$B$};

\draw[ultra thick,red,fill=yellow] (A) -- (B) let 
\p1 = ($(B)-(2.5,2)$),
\p2 = ($(C)-(2.5,2)$),
\n1 = {atan2(\x1,\y1)},
\n2 = {atan2(\x2,\y2)} in
arc (\n1:\n2:1.5cm) -- (D) -- cycle;

enter image description here

  • Yes, you are correct. This works well for a circle. However, I think I would like to know if there is a solution for more complicated shapes, such as a parabola. – profj Aug 8 '13 at 17:32
  • @stanford202 Can you update your MWE for your actual use case? – percusse Aug 8 '13 at 18:16
  • I have updated the MWE. – profj Aug 9 '13 at 22:31

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.