10

I want my diagram to show that two intersecting lines are not actually connected, but one passes above the other.

The best result I would like to achieve would be a small semicircle as used in electrical circuits. Is this possible? There is something similar at TeXample but it only handles horizontal and vertical lines.

I have this code that makes one of the lines stop a bit before the intersection by creating an empty node. This produces the expected result but I don't think it is the neatest way to do what I want:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (A) at (0,1) {A};
\node (B) at (1,-1) {B};
\node (C) at (1,1) {C};
\node (D) at (-1,-1) {D};
\node (i) at (intersection of A--B and D--C) {}; 
\draw (A) -- (B);
\draw (D) -- (i);
\draw (i) -- (C);
\end{tikzpicture}
\end{document}

enter image description here

6
  • Hi Pincopallino, could you post the contents of a small compilable .tex file, starting with \documentclass and ending with \end{document}? Then I can paste it into my editor, reproduce your situation on my machine, and start thinking about a solution. Commented Jun 8, 2013 at 10:44
  • 2
    Possibly helpful: texample.net/tikz/examples/line-junctions Commented Jun 8, 2013 at 11:15
  • 1
    Maybe also helpfuL: tex.stackexchange.com/questions/115923/…
    – Josef
    Commented Jun 8, 2013 at 11:26
  • @JohnWickerson here you are! Commented Jun 8, 2013 at 13:09
  • @Pincopallino I think this question would be a more useful and general reference for future visitors if the stuff about Feynman diagrams is removed. I would like to edit your question so that it reads simply: how can I draw two lines, with a little semicircle on one of them where they cross? Would that be ok with you? Commented Jun 9, 2013 at 17:08

1 Answer 1

9

Et voila.

  • I define an \intersect command. If you call \intersect{p1}{p2}{q1}{q2}, it will draw the line p1--p2 with a little semicircle where it intersects the line q1--q2.

  • It draws the p1--p2 line in three segments: a straight line from p1 until 0.75mm before the intersection point, and then a semicircle of diameter 1.5mm, and finally the remainder of the straight line to p2.

  • The code relies on TikZ's "distance modifiers", which are defined in Section 13.5.4 of the TikZ/PGF manual.

Does anybody know how to make the "loop" into a proper semicircle? I think that would look slightly better.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

% \intersect{<p1>}{<p2>}{<q1>}{<q2>}
% draws the line p1--p2, showing a little semicircle
% where it intersects the line q1--q2.
\newcommand\intersect[4]{
  \draw let \p{c} = (intersection of #1--#2 and #3--#4) in
    (#1) -- ($(\p{c})!0.75mm!(#1)$) 
    to[bend right=90] ($(\p{c})!0.75mm!(#2)$) -- (#2)
}

\begin{document}
\begin{tikzpicture}
\node (A) at (0,1) {A};
\node (B) at (1,-1) {B};
\node (C) at (1,1) {C};
\node (D) at (-1,-1) {D};
\draw (A) -- (B);
\intersect{C}{D}{A}{B};
\end{tikzpicture}
\end{document}
1

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