Pfeilspitzen mit arc in TikZ Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


Schimmelpilz
Forum-Century
Forum-Century
Beiträge: 133
Registriert: Sa 3. Aug 2013, 20:08

Pfeilspitzen mit arc in TikZ

Beitrag von Schimmelpilz »

Hallo,

ich habe ein Problemchen mit dem Zeichnen bogenförmiger Pfeile. Es entsteht immer eine Lücke vor der Pfeilspitze, die Spitze scheint irgendwie vom Bogen entkoppelt zu sein.
Hat jemand eine Idee, woran es liegen und was man da am dümmsten tun könnte?
\documentclass[tikz, border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,arrows.meta,arrows,angles,decorations.pathreplacing, decorations.shapes, decorations.markings} 
\usepackage[version=3]{mhchem}

\begin{document}
	\begin{tikzpicture}
		\node(H2O) at (0:2cm) {\ce{H2O}};
		\node(H2) at (180:2cm) {\ce{H2}};
		\draw[->, >=stealth] (H2O.north) arc [start angle=5, end angle=175, radius = 2] (H2.north);
		\draw[->, >=stealth] (H2.south) arc [start angle=-175, end angle=-5, radius = 2] (H2O.south);
	\end{tikzpicture}
\end{document}
Beste Grüße,
SchiPi

Bartman
Forum-Meister
Forum-Meister
Beiträge: 2456
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Re: Pfeilspitzen mit arc in TikZ

Beitrag von Bartman »

Im Abschnitt 14.7 The Arc Operation wird der Vorgang erklärt. Das Ziel des Pfades wird aus den optionalen Argumenten der arc-Operation berechnet und die Pfeile stehen dort, wo sie sein sollten.
\documentclass[tikz, border=1mm]{standalone}
\usepackage[version=4]{mhchem}

\usetikzlibrary{arrows.meta} 

\begin{document}
	\begin{tikzpicture}[>=Stealth, delta angle=170, radius=2]
		\node(H2) {\ce{H2}};
		\node(H2O) at (4,0) {\ce{H2O}};
		\draw[->] (H2.south) arc [end angle=-5];
		\draw[->] (H2O.north) arc [start angle=5];
	\end{tikzpicture}
\end{document}

Schimmelpilz
Forum-Century
Forum-Century
Beiträge: 133
Registriert: Sa 3. Aug 2013, 20:08

Re: Pfeilspitzen mit arc in TikZ

Beitrag von Schimmelpilz »

Ja, cool, klappt so, danke!
Hat jemand vielleicht noch eine schnelle Antwort parat, wie ich die gebogenen Pfeile (gebogen) beschriften kann?
Grüße,
SchiPi

Schimmelpilz
Forum-Century
Forum-Century
Beiträge: 133
Registriert: Sa 3. Aug 2013, 20:08

Re: Pfeilspitzen mit arc in TikZ

Beitrag von Schimmelpilz »

Also ich bin inzwischen hier angekommen, aber die Beschriftung wirft zwei Probleme auf:

1) Die Schriftgröße kann nicht geändert werden, wenn man z.B. \large vor "Release" setzt, konvergiert die Kompilierung nicht.
2) Die Schrift wird vom der standalone-Umgebung abgeschnitten.

btw.: Gibt es eine Möglichkeit, das direkt als .png ausguzeben? Mit der convert option in der documentclass habe ich im Projektordner in Win10 keine .png bekommen.
\documentclass[tikz, border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,arrows.meta,arrows,angles,decorations.pathreplacing, decorations.shapes, decorations.markings, decorations.text} 
\usepackage[version=3]{mhchem}

\begin{document}
	\begin{tikzpicture}[>=Stealth]
		\node[gray](O2) at (1,0) {\ce{O2}};
		\node(H2) {\textbf{{\large \ce{2 H2}}}};
		\node(H2O) at (4,0) {{\large \textbf{\ce{2 H2O}}}};
		
		\draw[very thick, ->, gray] (H2O.north) arc [radius=1.5, delta angle=170, start angle=5];
		\draw[very thick, gray] (O2.south) arc [radius=1.5, delta angle=170, end angle=-7];
		
		\draw[very thick, ->, postaction={decorate,decoration={raise=-2ex,text along path,text align=center,text={Release}}}] (H2.south) arc [radius=2, delta angle=170, end angle=-5];
		
		\draw[very thick, ->, postaction={decorate,decoration={raise=1.5ex,text along path,reverse path, text align=center,text={Storage}}}] (H2O.north) arc [radius=2, delta angle=170, start angle=5];
	\end{tikzpicture}
\end{document}
Beste Grüße,
SchiPi

gast.

Re: Pfeilspitzen mit arc in TikZ

Beitrag von gast. »

Die postaction hat keinen Einfluss auf die BoundingBox. Diese muss man ggf. selbst anpassen.

Beachte außerdem die Hinweise zur Formatierung von Text in Abschnitt "50.7 Text Decorations" der pgf-Anleitung:
\documentclass[tikz, border=10mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns,arrows.meta,arrows,angles,decorations.pathreplacing, decorations.shapes, decorations.markings, decorations.text} 
\usepackage[version=3]{mhchem}

\begin{document}
	\begin{tikzpicture}[>=Stealth]
		\node[gray](O2) at (1,0) {\ce{O2}};
		\node(H2) {\textbf{{\large \ce{2 H2}}}};
		\node(H2O) at (4,0) {{\large \textbf{\ce{2 H2O}}}};
		
		\draw[very thick, ->, gray] (H2O.north) arc [radius=1.5, delta angle=170, start angle=5];
		\draw[very thick, gray] (O2.south) arc [radius=1.5, delta angle=170, end angle=-7];
		
		\draw[very thick, ->, postaction={decorate,decoration={raise=-2ex,text along path,text align=center,text={|\Large\color{blue}|Release||}}}] (H2.south) arc [radius=2, delta angle=170, end angle=-5];
		
		\draw[very thick, ->, postaction={decorate,decoration={raise=1.5ex,text along path,reverse path, text align=center,text={Storage}}}] (H2O.north) arc [radius=2, delta angle=170, start angle=5];
	\end{tikzpicture}
\end{document}
Außerdem ist es sinnvoll, einzelne Fragen auch wirklich einzeln zu stellen. Das erleichtert die Übersicht und ermöglicht dir jeweils ein passendes Minimalbeispiel zur Frage anzugeben.

Schimmelpilz
Forum-Century
Forum-Century
Beiträge: 133
Registriert: Sa 3. Aug 2013, 20:08

Re: Pfeilspitzen mit arc in TikZ

Beitrag von Schimmelpilz »

Ah okay, cool. Gibt es damit auch eine Möglichkeit, Zeilenumbrüche zu setzen?

Antworten