Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

1 Answer 1

up vote 6 down vote accepted

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

share|improve this answer
1  
Or backgroundcolor=fg which has the same effect. –  bloodworks Feb 4 '13 at 18:56
    
Sorry for repetition, I searched for mdframed and beamer, should have searched for an error. Thanks! –  damluar Feb 4 '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 4 '13 at 19:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.