I'm trying to use the pic-functionality of tikz to draw some figures into a tabular (inspired by this answer here) which I might need to reuse later. But I'm doing something wrong, since I get a error suggesting I forgot a semicolon. I've tested the individual parts that are defined in the tikzset and they work, so I'm a bit confused what exactly is going wrong here.
\documentclass[tikz, border=1pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usepackage{ifthen}
\newcommand{\drawlattice}{%
\clip (-2,-2) rectangle (2,2);
\begin{scope}[opacity=0.2, dashed]
\foreach \x in {-2,-1,0,1,2}{
\draw ($(-60:2) + (\x,0)$) -- ($(120:2)+(\x,0)$);
\draw ($(60:2) + (\x,0)$) -- ($(-120:2)+(\x,0)$);
\pgfmathsetmacro{\y}{{\x * sqrt(3)/2}}
\draw ($(-2,0) + (0,\y)$) -- ($(2,0)+(0,\y) $);
}
\end{scope}%
}
\tikzset{
A2/.pic={
\begin{tikzpicture}
\drawlattice
\node (alpha) at (1.2,0) {$\alpha$};
\node (beta) at (120:1.2) {$\beta$};
\node (ab) at (60:1.2) {$\alpha+\beta$};
\foreach \angle in {0, 60,120,180,240,300}{
\draw[->] (0,0) -- (\angle:1);
}
\end{tikzpicture}
},
B2/.pic={
\begin{tikzpicture}
\clip (-2,-2) rectangle (2,2);
\begin{scope}[opacity=0.2, dashed]
\foreach \x in {-2,-1,0,1,2}{
\draw ($(-45:2) + (\x,0)$) -- ($(135:2)+(\x,0)$);
\draw ($(45:2) + (\x,0)$) -- ($(-135:2)+(\x,0)$);
\draw ($(-2,0) + (0,\x)$) -- ($(2,0)+(0,\x) $);
}
\end{scope}
\node (alpha) at (1.2,0) {$\alpha$};
\node (beta) at (3/4*180:1.6) {$\beta$};
\foreach \angle in {0,45,90,135,180,225,270,315}{
\pgfmathsetmacro{\bigradius}{sqrt(2)}
\ifthenelse{\angle=45 \OR
\angle=135 \OR
\angle=225 \OR
\angle=315}{
\draw[->] (0,0) -- (\angle:\bigradius);
}{
\draw[->] (0,0) -- (\angle:1);
};
}
\end{tikzpicture}
},
G2/.pic={
\begin{tikzpicture}
\drawlattice
\node (alpha) at (1.2,0) {$\alpha$};
\node (beta) at (150:1.9) {$\beta$};
%\node (ab) at (120:1.2) {$\alpha+\beta$};
\foreach \angle in {0,30,60,90,120,150,180,210,240,270,300,330}{
\pgfmathsetmacro{\bigradius}{sqrt(3)}
\ifthenelse{\angle=30 \OR
\angle=90 \OR
\angle=150 \OR
\angle=210 \OR
\angle=270 \OR
\angle=330}{
\draw[->] (0,0) -- (\angle:\bigradius);
}{
\draw[->] (0,0) -- (\angle:1);
};
}
\end{tikzpicture}
}}
\begin{document}
\begin{tabular}{cc}
\tikz\pic{A2} & test \\
\tikz\pic{B2} & \tikz\pic{G2}
\end{tabular}
\end{document}

