I am trying to draw some knots side by side with tikz, the label them, but it just doesn't work with my code. I use the package: caption, subcaption, tikz (knots).
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{matrix, arrows, knots}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\resizebox{\linewidth}{!}{
\begin{tikzpicture}
\foreach \brk in {0,1,2} {
\begin{scope}[rotate=\brk * 120]
\node[knot crossing, transform shape,
inner sep=1.5pt] (k\brk) at (0,-1) {};
\end{scope}
}
\foreach \brk in {0,1,2} {
\pgfmathparse{int(Mod(\brk - 1,3))}
\edef\brl{\pgfmathresult}
\draw[thick,red] (k\brk) .. controls (
k\brk.4 north west) and (k\brl.4 north east) .. (k\brl.center);
\draw[thick,red] (k\brk.center) .. controls (k\brk.16 south west) and (k\brl.16 south east) .. (k\brl);
}
\end{tikzpicture}
}
\caption{Trefoil}
\label{a}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\resizebox{\linewidth}{!}{
\begin{tikzpicture}
\def\foil{3}
\foreach \brk in {1,...,\foil} {
\begin{scope}[rotate=\brk * 360/\foil]
\node[transform shape, knot crossing, inner sep=1.5pt] (k\brk) at (0,-1) {};
\end{scope}
}
\draw[thick,red] (0,0) \foreach \brk in {1,...,\foil} {let \na=\brk, \nb={int(Mod(\brk,\foil)+1)}, \nc={int(Mod(\brk+1,\foil)+1)} in (k\na) .. controls (k\na.16 south east) and (k\nb.16 south west) .. (k\nb.center) .. controls (k\nb.4 north east) and (k\nc.4 north west) .. (k\nc)};
\end{tikzpicture}
}
\caption{Cinquefoil}
\label{b}
\end{subfigure}
\end{figure}
\caption{Examples of knots}
\end{figure}
\end{document}
k
in front of\brk
incontrols (\brk.4 north west) and (k\brl.4 north east)
.\documentclass
, two\end{figure}
. Also, replace\na
,\nb
and\nc
with\n0
,\n1
and\n2
respectively.