# How to use beamer colors in beamerarticle?

I would like to use beamer defined colors into beamerarticle's version of my document. This way I can change beamer theme (or color theme) and colors change according it.

Here you have a MWE. A frame with a tikz figure using beamer colors fg and bg.

\documentclass[ignorenonframetext]{beamer}

%\documentclass{article}
%\usepackage{beamerarticle}

\usepackage{tikz}
\usecolortheme{beaver}

\begin{document}
This is some text outside any frame.

\begin{frame}{Frame}
\usebeamercolor[fg]{example text}
\begin{tikzpicture}
\filldraw[color=fg, fill=bg!50!white] (0,0) rectangle (5,3);
\draw[line width=5mm] (1,1)--(2,2);
\end{tikzpicture}
\end{frame}
\end{document}

As soon as I try article with beamerarticle package, pdflatex complains with

! Package xcolor Error: Undefined color `fg'.

See the xcolor package documentation for explanation.
Type  H <return>  for immediate help.
...

l.16 ..., fill=bg!50!white] (0,0) rectangle (5,3);

The example contains a tikz figure but my question want to be more general, something like declaring sections (or any other text) with a beamer color and keeping this color in article mode.

-

Having just wanted to do this in answer to another question, I can tell you that this is Not Intended To Be Done! A lot of the theming and colour commands are simply set to "do nothing" when the article version of beamer is used. However, using a bit of trickery we can reload the commands and so make the colours available. This should be used with Extreme Caution as it might break something that I haven't tested (which is about everything).

Here's a picture based on a slightly modified version of your example:

And here's the code:

\documentclass{standalone}
%\url{http://tex.stackexchange.com/q/22768/86}
\PassOptionsToPackage{svgnames}{xcolor}
\usepackage{beamerarticle}
\usepackage{tikz}

\makeatletter

\def\beamer@currentmode{beamer}
\def\beamer@colorhook{}
\newskip\beamer@lastskip
\let\beamercolorbox=\relax
\let\endbeamercolorbox=\relax
\let\usetheme=\relax
\let\usecolortheme=\relax
\let\usefonttheme=\relax
\let\useoutertheme=\relax
\let\useinnertheme=\relax

\input{beamerbasethemes.sty}
\input{beamerbasecolor.sty}
\usecolortheme{default}
\usecolortheme{beaver}
\makeatother

\setbeamercolor{example text}{bg=Maroon}

\begin{document}

This is some text outside any frame.

\begin{frame}{Frame}