Linie an der Schnittstelle mit Linie 2 brechen

Tabellen und Grafiken erstellen und anordnen


Trauminsel
Forum-Fortgeschrittener
Forum-Fortgeschrittener
Beiträge: 69
Registriert: Mi 13. Apr 2016, 10:21

Linie an der Schnittstelle mit Linie 2 brechen

Beitrag von Trauminsel »

Guten Tag

Ihr könnt dem Minimalbeispiel entnehmen wie ich die Linie gebrochen habe, so da der zweite Pfeil an dieser Stelle passieren kann.

Die Lösung die ich gewählt habe ist aber "handgelenk mal pi" und sobald ich etwas an der Linie verändere die gebrochen werden muss ich auch die Bruchstelle manuel verändern.

Habt ihr einen Lösungsvorschlag, dass die Bruchstelle ebenfalls mitwandert wenn ich etwas verändere?


\documentclass[a4paper,11pt]{report}
\usepackage{tikz} 

\begin{document}


\begin{tikzpicture}

  \tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
    \tikzset{edge/.style = {->,> = latex}}


   \node[vertex] (M) at  (-10,0) {M}; 
    \node[vertex] (N) at  (-6,0) {N};
    \node[vertex] (PN) at (0,11) {PN};
    \node[vertex] (Q) at  (0,6) {Q};

 \path (N) -- (PN) coordinate [pos=0.5] (NPN1) {}; 
    \path (N) -- (PN) coordinate [pos=0.6] (NPN2) {}; 

 \coordinate  (CENN) at (-10,6) ;

\draw (N) to node[pos=0.5,above, sloped] {Kartoffel}  (NPN1);
\draw[edge] (NPN2) -- (PN);

\draw (M) -- (CENN);
\draw[edge] (CENN) to node[midway,above, sloped] {Handball}  (Q);

\end{tikzpicture}

\end{document}


markusv
Forum-Meister
Forum-Meister
Beiträge: 947
Registriert: Do 3. Sep 2015, 17:20
Wohnort: Leipzig

Re: Linie an der Schnittstelle mit Linie 2 brechen

Beitrag von markusv »

Hallo .

Anbei mein Vorschlag mit Hilfe der TikZ-Bibliothek intersections. Die "Lücke" erstelle ich mit einem gefüllten Kreis auf der Schnittstelle. Die Nodes werden automatisch mittig zwischen Knick und Schnittstelle bzw. (N) und Schnittstelle gesetzt:

\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex}}

\node[vertex] (M) at  (-10,0) {M}; 
\node[vertex] (N) at  (-6,0) {N};
\node[vertex] (PN) at (0,11) {PN};
\node[vertex] (Q) at  (0,6) {Q};

\draw[edge,name path=L1] (N) -- (PN); 
\path[name path=L2] (M) |- (Q);
\fill [name intersections={of=L1 and L2,by=I},fill=white] (I) circle (.5cm); 
\draw[edge] (M) |- (Q);
\path (N) -- (I)  node[pos=.5,above,sloped] {Kartoffel};
\path (M) |- (I)  node[pos=.75,above] {Handball};
\end{tikzpicture}
\end{document}
Wäre Microsoft Word für das Schreiben von Büchern entwickelt worden,
würde es Microsoft Book heißen.

Unkomplizierte und schnelle LaTeX-Hilfe, bspw. Erstellung von Vorlagen und Bewerbungen:
Help-LaTeX@web.de

cis
Forum-Anfänger
Forum-Anfänger
Beiträge: 47
Registriert: Mi 22. Jul 2020, 20:14

Re: Linie an der Schnittstelle mit Linie 2 brechen

Beitrag von cis »

Übermalen gefällt mir meistens nicht so sehr, ich würde es hier mit shorten machen:

5555555.png
5555555.png (7.18 KiB) 1304 mal betrachtet
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex}}

\node[vertex] (M) at  (-10,0) {M}; 
\node[vertex] (N) at  (-6,0) {N};
\node[vertex] (PN) at (0,11) {PN};
\node[vertex] (Q) at  (0,6) {Q};

\path[edge,name path=L1] (N) -- (PN); 
\path[name path=L2] (M) |- (Q);

% Alt
%\fill [name intersections={of=L1 and L2,by=I},fill=red] (I) circle (.5cm); 

% Neu
\path[name intersections={of=L1 and L2,by=I},label=I]; 
\draw[red, shorten >=4mm] (N) -- (I); 
\draw[red, shorten <=4mm] (I) -- (PN); 

\draw[edge] (M) |- (Q);
\path (N) -- (I)  node[pos=.5,above,sloped] {Kartoffel};
\path (M) |- (I)  node[pos=.75,above] {Handball};
\end{tikzpicture}
\end{document}

PS: shorten kann mitunter auch problematisch sein, man kann auch echte Koordinaten vor und nach dem Schnittpunkt platzieren:

5555555.png
5555555.png (7.08 KiB) 1298 mal betrachtet
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex}}

\node[vertex] (M) at  (-10,0) {M}; 
\node[vertex] (N) at  (-6,0) {N};
\node[vertex] (PN) at (0,11) {PN};
\node[vertex] (Q) at  (0,6) {Q};

\path[edge,name path=L1] (N) -- (PN); 
\path[name path=L2] (M) |- (Q);

% Alt
%\fill [name intersections={of=L1 and L2,by=I},fill=red] (I) circle (.5cm); 

% Neu 2
\path[name intersections={of=L1 and L2,by=I},label=I]; 
\path[] (N) -- (I) coordinate[pos=0.9](Ivor); 
\path[] (I) -- (PN)  coordinate[pos=0.1](Inach); ; 
\draw[blue] (N) -- (Ivor); 
\draw[blue] (Inach) -- (PN); 

\draw[edge] (M) |- (Q);
\path (N) -- (I)  node[pos=.5,above,sloped] {Kartoffel};
\path (M) |- (I)  node[pos=.75,above] {Handball};
\end{tikzpicture}
\end{document}

Antworten