5

I want to draw rounded colored text box using mdframed. I'm trying to set background color to green or blue, used in example and theorem environments using \usebeamercolor:

\begin{mdframed}[roundcorner=5pt, backgroundcolor=\usebeamercolor[fg]
{block title example}, align=center, userdefinedwidth=4cm, fontcolor=white]
Sequential consistency
\end{mdframed}

I got the following error:

! Argument of \tikz@swap@args has an
 extra }.

Seems like I can't use commands inside []. How could I fix it? When I use just blue!50!black everything works just fine.

MWE:

\documentclass{beamer}

\usepackage{beamerthemesplit}
\usepackage[framemethod=TikZ]{mdframed}


\begin{document}
\begin{frame}[fragile]

\begin{mdframed}[roundcorner=5pt, backgroundcolor=\usebeamercolor[fg]{block title example}, align=center, userdefinedwidth=4cm, fontcolor=white]   %\usebeamercolor[fg]{block title example}
Sequential consistency
\end{mdframed}

\end{frame}
\end{document}
damluar
  • 679

1 Answers1

7

Similarly to On using beamer's colors in a Tikz picture one could proceed as follows:

  • first declare the desired color with \usebeamercolor{block title example}
  • then use it with block title example.fg (or with .bg for the background).

The code:

\documentclass{beamer}
\usepackage{beamerthemesplit}
\usepackage[framemethod=TikZ]{mdframed}


\begin{document}
\begin{frame}[fragile]
\usebeamercolor{block title example}
\begin{mdframed}[roundcorner=5pt, backgroundcolor=block title example.fg, align=center, userdefinedwidth=4cm, fontcolor=white]  
Sequential consistency
\end{mdframed}
\end{frame}
\end{document}

The result:

enter image description here

  • 1
    Or backgroundcolor=fg which has the same effect. – bloodworks Feb 04 '13 at 18:56
  • Sorry for repetition, I searched for mdframed and beamer, should have searched for an error. Thanks! – damluar Feb 04 '13 at 19:19
  • 1
    @bloodworks: yes it works too, but I prefer this syntax for future readability (when I came back to old documents just reading fg says almost nothing in case you use several different colors). – Claudio Fiandrino Feb 04 '13 at 19:34