LaTeX Tikz
Date: 2022-12-28Last modified: 2023-03-07
Table of contents
Editors and converters
$ apt-cache search tikz editor
ktikz - editor para a linguagem de desenho TikZ - versão KDE
qtikz - editor for the TikZ drawing language - Qt version
prerex - course prerequisite chart editor for LaTeX/TikZ
texlive-pictures - TeX Live: Graphics, pictures, diagrams
texlive-latex-extra - TeX Live: LaTeX additional packages
tikzit - visual PGF/TikZ graph editor
$ apt-cache search pdf2svg
pdf2svg - converte documentos PDF para arquivos SVG (um por página)
Line thickness
Relative positioning
The positioning
library allows you to place nodes at a specified direction and
distance from other nodes. To load the library, include in your preamble:
\usetikzlibrary{backgrounds}
\usetikzlibrary{positioning}
\begin{tikzpicture}[
background rectangle/.append style={draw=cyan, fill=white},
show background rectangle,
text=cyan,
]
\draw[help lines] (-2,-2) grid (2,2);
\node [red] (0) {$\bullet$};
\node{origin};
\node[right=of 0] {right};
\node[below right=of 0] {below right};
\node[below=of 0] {below};
\node[below left=of 0] {below left};
\node[left=of 0] {left};
\node[above left=of 0] {above left};
\node[above=of 0] {above};
\node[above right=of 0] {above right};
\end{tikzpicture}
Example - Linked list
\usetikzlibrary{calc,shapes.multipart,chains,arrows,backgrounds}
\begin{tikzpicture}[
background rectangle/.style={draw=cyan, fill=white},
show background rectangle,
text=cyan,
draw=cyan,
list/.style={rectangle split, rectangle split parts=2, draw, rectangle split horizontal},
>=stealth,
start chain
]
\node[list,on chain] (A) {12};
\node[list,on chain] (B) {99};
\node[list,on chain] (C) {37};
\node[color=red, on chain,draw,inner sep=6pt] (D) {};
\draw[color=red] (D.north east) -- (D.south west);
\draw[color=red] (D.north west) -- (D.south east);
\draw[*->] let \p1 = (A.two), \p2 = (A.center) in (\x1,\y2) -- (B);
\draw[*->] let \p1 = (B.two), \p2 = (B.center) in (\x1,\y2) -- (C);
\draw[*->] let \p1 = (C.two), \p2 = (C.center) in (\x1,\y2) -- (D);
\end{tikzpicture}
Circle
\usetikzlibrary{backgrounds}
\begin{tikzpicture}[
scale=2,
background rectangle/.append style={draw=cyan, fill=white},
show background rectangle,
draw=cyan,
text=cyan,
]
\draw [thick] (0,0) circle (1);
\draw [dashed] (0,0) -- (0,1);
\draw [dotted] (0,0) -- (1,0);
\draw (0,0) node[below]{$O$} ;
\draw (1,0) node[right]{$A$} ;
\draw (0,1) node[above]{$B$} ;
\draw [dashdotdotted, thick] (0.9,0) arc (0:90:0.9);
\draw (0,0) node {$\bullet$};
\end{tikzpicture}
Package intersections
\usetikzlibrary{intersections}
\usetikzlibrary{backgrounds}
\begin{tikzpicture}[
background rectangle/.style={draw=cyan,fill=white},
show background rectangle,
text=cyan,
draw=cyan,
]
% Draw to path and give a name to them
\draw [red, thin, name path={red line}] (0,0) -- (4,3);
\draw [cyan, name path={blue curve}] (1,-0.5) to[out=80, in=100] (3,2);
% use the intersections on a path to giv them coordinates
% and draw a line between them
\draw [green, thick, name intersections={of=red line and blue curve,
by={first intersect, second intersect}}]
(first intersect) -- (second intersect);
% one can use the coordinates furtheron
\node [above] at (first intersect) {A};
\node [below] at (second intersect) {B};
\end{tikzpicture}
References
- tikz.net
- How the inner separation for nodes works and how to use it: Part 2
- TikZ arrows
- TikZBlog
- Drawing Neural Networks in TikZ: Short Guide
- How should I draw a singly/double linked list?
- LaTeX Graph Paper
- crash course to tikz [2 · positioning]
- Github awesome-TikZ
- Github Examples for the usage of LaTeX
- Github Galley of Tikz drawings