Forum digitalis

3.4 Graphical elements

Nodes

Represent points or text elements in a graphic.
Syntax:

\begin{tikzpicture} \node at (0,0) {Text}; % simple node \node[draw, rectangle] at (2,0) {Box}; % node in a rectangle \node[draw, circle, fill=red!40] at (4,0) {Circle}; % node in a circle \end{tikzpicture}

Options:

Lines and Arrows

Connect nodes or indicate directions.

\begin{tikzpicture} \node (A) {Center}; \node[right=of A] (B) {Right}; \node[above=of A] (C) {Top}; \node[left=of A] (D) {Left}; \node[below=of A] (E) {Bottom}; \draw[dotted] (A) -- (B); % dotted line \draw[->, ultra thick] (A) -- (C); % arrow \draw[<->, dashed, color=blue] (A) -- (D); % arrows in both directions \draw (A) -- (E) node[midway, right] {Label}; % line with label \end{tikzpicture}

Options:

Anchor Points

Define the reference point of a node to create precise connections.

\begin{tikzpicture} \node (A) {Left}; \node[right=of A] (B) {Right}; \draw (A.east) -- (B.west); \end{tikzpicture}

Available anchors: