Forum digitalis

3.3 Positionierung

Absolute Positionierung

Du platzierst Elemente direkt im kartesischen Koordinatensystem.

\begin{tikzpicture} \draw (0,0) -- (2,1); \node at (-0.1,-0.1) {Start}; \node at (2.1,1.2) {Ziel}; \end{tikzpicture}

Fazit

Relative Positionierung

Objekte werden relativ zu anderen platziert. Voraussetzung: \usetikzlibrary{positioning} (in der Präambel).

\begin{tikzpicture} \node (A) {Start}; \node[below=of A] (B) {Ende}; \draw (A) -- (B); \end{tikzpicture}

Fazit

Weitere Positionierung

Neben absoluten und relativen Positionierungen gibt es noch folgende Positionierung.

\begin{tikzpicture} \node (A) {Mitte}; \node[right=of A] (B) {Rechts}; \node[above=of A] (C) {Oben}; \node[left=of A] (D) {Links}; \node[below=2cm of A] (E) {Weiter unten}; \end{tikzpicture}

Kombinierte Positionierung

Dann gibt es noch eine Positionierungsmöglichkeit, die relative Positionierung und absolute Positionierung kombiniert.

\begin{tikzpicture} \node (A) {Start}; \node[below=of A, xshift=5mm] (B) {Versetzt}; \draw (A) -- (B); \end{tikzpicture}

Anker (Ausrichtung)

Ein Anchor bestimmt, welcher Punkt eines Knotens an einer gegebenen Position liegt. Standardmässig ist das der Mittelpunkt.
Syntax: \node[anchor=option] at (x,y) {Text};
Das sind die Optionen: center, north, south, east, west, north west, north east, south west, south east.

\begin{tikzpicture} \node[anchor=north] at (0,0) {Zentrum}; \node[anchor=north east] at (-5,-2) {Unten links}; \node[anchor=south west] at (2,2) {Oben rechts}; \draw (0,0) -- (2,2); \draw (2,2) -- (-5,-2); \end{tikzpicture}

Anwendungszwecke