I would like to put a pgf object, \pgfuseshading{}, inside the caption of a figure or table. The below code creates this pgf object which can be created in in the text (\pgfuseshading{CyanToBlue}) of the document but causes errors when put inside the caption (\caption {\pgfuseshading{spectrumRedToBlue}}).
Any help putting this pgf object in the caption of the table would be hugely appreciated.
Thank you
\RequirePackage[l2tabu, orthodox]{nag}
\documentclass[a4paper,10pt]{report}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,x11names]{xcolor}
\usepackage{pgf}
\pgfdeclarehorizontalshading{CyanToBlue}{0.25cm}{color(0cm)=(Cyan); color(0.6cm)=(Blue)}
\pgfdeclarehorizontalshading{spectrumRedToBlue}{0.25cm}{color(0cm)=(Red);
color(0.15cm)=(Orange);
color(0.25cm)=(Yellow);
color(0.35cm)=(SpringGreen);
color(0.45cm)=(Cyan);
color(0.65cm)=(Blue)}
\begin{document}
\pgfuseshading{CyanToBlue}
\begin{table}
\caption {Geometry \pgfuseshading{spectrumRedToBlue} }
\begin{center}
\begin{tabular}{l c c c }
\hline\hline
Atom & x ($\AA{}$) & y ($\AA{}$) & z ($\AA{}$) \\ \hline
C & -0.32 & -0.878 & -0.7512 \\
\hline\hline
\end{tabular}
\end{center}
\label{tab:}
\end{table}
\end{document}
