# Transparent background for mdframed environment?

Is it possible to specify a transparent background colour for the mdframed environment, so that anything which might be underneath will be visible?

-
mdframed can use TikZ and with the tikzsetting option you can pass arguments to tikzset. This way you should be able to change the opacity. I can't test this right now, but you can give it a try. –  Roelof Spijker Dec 14 '11 at 16:04
I only want the background to be transparent, not the borders or text. Is this possible using 'tikzset' ? –  Dan Dec 14 '11 at 16:43
Like I said, I can't test this right now. But there is a fill opacity in TikZ that should only affect the background. –  Roelof Spijker Dec 14 '11 at 17:04

You must set the opacity to the whole environment.

\documentclass{article}
\usepackage{tikz}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\usepackage{background}
\SetBgContents{top secret}
\SetBgColor{red}
%  \tikzset{mdfbackground/.style={fill=red,opacity=0.1,draw=green}}%
\newmdenv[tikzsetting={draw=blue,fill=red,},settings={\tikzset{every picture/.style={opacity=0.6}}}]{myenvironment}
\begin{document}
\BgThispage

\begin{tikzpicture}
\draw[blue,fill] (0,0) rectangle (8,4);
\node[text width=8cm] {\lipsum[1]};
\end{tikzpicture}

\begin{myenvironment}
\lipsum[1]
\end{myenvironment}
\end{document}


-
That makers the text and the frame also transparent. But the solution suggested by Philippe Goutet in a comment to another answer seems to work. –  Jan Hlavacek Dec 18 '11 at 20:58

As mentioned in the comments, you can set mdframed to use TikZ. Here is a MWE that sets the fill opacity to 0.5; you can tweak it to whatever you would like between 0 (fully transparent, or invisible) and 1 (fully opaque, or solid)

\documentclass{article}
\usepackage{tikz}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}

\newmdenv[tikzsetting={draw=blue,fill=red,fill opacity=0.5}]{myenvironment}

\begin{document}

\begin{myenvironment}
\lipsum[1]
\end{myenvironment}
\end{document}


Following @PhilippeGoutet's comment, you can use

\newmdenv[tikzsetting={draw=blue,fill=red,fill opacity=0.5},backgroundcolor=none]{myenvironment}


which gives

-
Thanks, but that doesn't give me what I want. If this box overlays any other text, I want to be able to see it. eg. \documentclass{article} \usepackage{tikz} \usepackage[framemethod=tikz]{mdframed} \usepackage{lipsum} \newmdenv[tikzsetting={draw=blue,fill=red,fill opacity=0.5}]{myenvironment} \begin{document} \vtop to 0pt{\LARGE Some text underneath} \begin{myenvironment} \lipsum[1] \end{myenvironment} \end{document}  –  Dan Dec 16 '11 at 14:23
@Dan I see the problem now- note that this wasn't completely obvious in your original question; this would have been a good place for a MWE. I'll work on your updated problem :) –  cmhughes Dec 16 '11 at 16:56
Yes, my apologies, you are right, I should have provided an example, but I had no idea how to achieve the effect. I very much appreciate your efforts to help. –  Dan Dec 17 '11 at 19:01
@Dan: use \newmdenv[tikzsetting={fill=red,fill opacity=0.5},backgroundcolor=none]{myenvironment} –  Philippe Goutet Dec 18 '11 at 18:47
@PhilippeGoutet Thank you very much, see my edit :) –  cmhughes Dec 18 '11 at 21:23