PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : TikZ - Text über Verbindungslinie



Firefox
05-10-2012, 10:47
Moin Gemeinde,

ich hab bereits die Suche ausgekundschaftet aber noch nichts passendes bzw. funktionierendes gefunden.

Folgendes Problem: In meiner Bachelorarbeit habe ein TikZ Bild erstellt und möchte auf auf den Verbindungspfeilen eine Text plazieren, der passend zu den Pfeilen etwas gedreht ist. Das gedrehte funktioniert auch. Aber der Text bleibt auf Pos (0,0) hängen.

Nachfolgend mein minimal Beispiel.


\documentclass[a4paper, 12pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[cp1252]{inputenc}
\usepackage[english, ngerman]{babel}
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{arrows,automata,backgrounds,calend ar}
\begin{document}


\tikzstyle{int}=[draw, fill = blue!20, minimum size=1.3cm]
\begin{figure}[H]
\centering
\fbox{
\begin{tikzpicture}[node distance=3cm, auto]
\node (a) [int] {a};
%\node (b)[left of=a, node distance=4cm, coordinate] {a};
\node (c) [int] at (4,3) {b};
\node (d) [int] at (8,3) {\parbox{3cm}{sehr langes\\ wort}};
\node (e) [int] at (4,-3) {c};
\node (f) [int] at (8,0) {d};
\node (g) [circle, fill=gray!30] at (8,-3) {e};
% \node (h) [int] at (4,6) {f};
\node (i) [int] at (8,6) {g};
\node (j) [circle, fill=gray!30] at (12,6) {h};

\draw [<->, blue, very thick] (a) to (f) node [midway] {int. Profibus};
\draw [<->, magenta, very thick] (a) to [out=45, in=225] (c) node [rotate=28, pos=0.3, below right] {Profibus};
\draw [<->, magenta, very thick] (c) to [out=315, in=225] (d);
\draw [<->, magenta, very thick] (a) to [out=315, in=135] (e) node [rotate=-28, pos=0.3, above right] {Profibus};
\draw [<->, magenta, very thick] (e) to [out=43, in=135] (g);
\draw [<->, green, very thick] (a) to [out=90, in=180] (i) node [rotate=45, pos=0.3, above right] {DRIVE-CLiQ};
\draw [<->, green, very thick] (i) to [out=315, in=225] (j);
\draw [<->, orange, very thick] (i) to [out=45, in=135] (j) node [pos=0.5, above] {Leistungskabel};
\end{tikzpicture}
}
\caption{Verkabelung}
\label{fig:Profibus_1}
\end{figure}
\end{document}

Ich danke euch, wenn mir jmd. die passende Hilfestellung geben kann!

MfG

hakaze
05-10-2012, 12:12
Du hast da einen Dreher in der Syntax drin: die Zielkoordinate gehört ans Zeilenende. Dann wird auch das Label am Pfeil und nicht an der Startkoordinate platziert.

Außerdem kannst du die Ausrichtung auch automagisch über das Keyword sloped bestimmen lassen.


\documentclass[a4paper, 12pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{tikz}

\usetikzlibrary{arrows}
\begin{document}


\tikzstyle{int}=[draw, fill = blue!20, minimum size=1.3cm]
\begin{figure}[H]
\centering
\fbox{
\begin{tikzpicture}[node distance=3cm, auto]
\node (a) [int] {a};
%\node (b)[left of=a, node distance=4cm, coordinate] {a};
\node (c) [int] at (4,3) {b};
\node (d) [int] at (8,3) {\parbox{3cm}{sehr langes\\ wort}};
\node (e) [int] at (4,-3) {c};
\node (f) [int] at (8,0) {d};
\node (g) [circle, fill=gray!30] at (8,-3) {e};
% \node (h) [int] at (4,6) {f};
\node (i) [int] at (8,6) {g};
\node (j) [circle, fill=gray!30] at (12,6) {h};

\draw [<->, blue, very thick] (a) to node [above,midway] {int. Profibus} (f) ;
\draw [<->, magenta, very thick] (a) to [out=45, in=225] node [sloped,midway, below] {Profibus} (c);
\draw [<->, magenta, very thick] (c) to [out=315, in=225] (d);
\draw [<->, magenta, very thick] (a) to [out=315, in=135] node [sloped,midway, above] {Profibus} (e) ;
\draw [<->, magenta, very thick] (e) to [out=43, in=135] (g);
\draw [<->, green, very thick, out=90, in=180] (a) to node [above,sloped,midway] {DRIVE-CLiQ} (i);
\draw [<->, green, very thick] (i) to [out=315, in=225] (j);
\draw [<->, orange, very thick] (i) to [out=45, in=135] node [midway, above] {Leistungskabel} (j);
\end{tikzpicture}
}
\caption{Verkabelung}
\label{fig:Profibus_1}
\end{figure}
\end{document}PS: Bitte benutze die Code-Umgebung zum Posten von Latex-Code (#-Button). Die HTML-Formatierung wirft sonst einiges durcheinander.

Firefox
05-10-2012, 12:16
Super! Danke dir.

Danke für den Tipp, jetzt weiß ich auch wo ich das finde!

Danke!!!:)