I'm doing a step-by-step tutorial, and need to repeat the base tikz picture while adding new paths. I'm trying to avoid copy/paste. I've looked around, tried using macros, saveboxes and tikz pic command but I can't make it work (or even compile).
I'm using subcaptions in the original, but removed here since I don't think it's relevant.
(Edit: maybe something like what it is used in beamer would be ideal?)
With savebox:
\documentclass[10pt,a4paper,twoside]{report}
%---------------------------------- tikz ---------------------------------------
\usepackage{tikz}
\usetikzlibrary{positioning,chains,fit,shapes,calc,arrows,patterns,external,shapes.callouts,graphs,decorations.pathreplacing}
\usepackage{fixltx2e}
\newsavebox{\myborder}
\savebox{\myborder}{%
\begin{tikzpicture}
\matrix[row sep=10mm,column sep=10mm] {
% First row:
\node (a) {a}; & \node (e) {e}\\
% Second row:
\node (b) {b}; & \node (d) {d} \\
% Third row:
\node (c) {c}; & \node (z) {z} \\
};
\end{tikzpicture}}
\begin{document}
% align edges
\begin{tikzpicture}
{\usebox{\myborder}}
\path
(1) edge (b);
\end{tikzpicture}
\begin{tikzpicture}
{\usebox{\myborder}}
\path
(a) edge (b)
(a) edge (c);
\end{tikzpicture}
\end{document}
With tikz pic
\documentclass[10pt,a4paper,twoside]{report}
%---------------------------------- tikz ---------------------------------------
\usepackage{tikz}
\usetikzlibrary{positioning,chains,fit,shapes,calc,arrows,patterns,external,shapes.callouts,graphs,decorations.pathreplacing}
\usepackage{fixltx2e}
\tikzset{radiation/.style={{decorate,decoration={expanding waves,angle=90,segment length=4pt}}},
antenna/.pic={
code={\tikzset{scale=5/10}
\matrix[row sep=10mm,column sep=10mm] {
% First row:
\node (a) {a}; & \node (e) {e}\\
% Second row:
\node (b) {b}; & \node (d) {d} \\
% Third row:
\node (c) {c}; & \node (z) {z} \\
};
}}
}
\begin{document}
\begin{tikzpicture}
\path (0,0) pic[scale=0.5,] {antenna};
\path
(1) edge (b);
\path (4,0) pic[scale=0.5,rotate=45] {antenna};
\path
(a) edge (b)
(a) edge (c);
\path (8,0) pic[scale=0.5,rotate=90] {antenna};
\end{tikzpicture}
\end{document}
