Seite 1 von 1

Pfeilspitzen mit arc in TikZ

Verfasst: So 17. Jul 2022, 15:17
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

Re: Pfeilspitzen mit arc in TikZ

Verfasst: So 17. Jul 2022, 16:42
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}

Re: Pfeilspitzen mit arc in TikZ

Verfasst: Mi 27. Jul 2022, 10:31
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

Re: Pfeilspitzen mit arc in TikZ

Verfasst: Mi 27. Jul 2022, 11:42
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

Re: Pfeilspitzen mit arc in TikZ

Verfasst: Mi 27. Jul 2022, 13:49
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.

Re: Pfeilspitzen mit arc in TikZ

Verfasst: Mi 27. Jul 2022, 17:18
von Schimmelpilz
Ah okay, cool. Gibt es damit auch eine Möglichkeit, Zeilenumbrüche zu setzen?