[Tex/LaTex] How to explicitly set the color to transparent/nothing in the options of mdframed

colormdframed

Is it possible to explicitly set the backgroundcolor option in mdframed package, so that the background stays transparent (or, let's say "empty")?

It could be

\begin{mdframed}[backgrouncolor = ***]
Test
\end{mdframed}

with *** = no color, empty, {} but none of those work.

Is it possible to explicitly set the color to transparent/nothing in the options of mdframed?


edit

To say it more explicitly, is there a value *** such that

\begin{mdframed}[backgrouncolor = ***]
Test
\end{mdframed}

and

% assuming no global options have been set
\begin{mdframed}
Test
\end{mdframed}

are equivalent?

Best Answer

I am not sure I understand the question, so I present three possible answers:

First option:

You can use \mdfsetup to define global settings:

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

\mdfsetup{backgroundcolor=red!20}

\begin{document}

\begin{mdframed}
test
\end{mdframed}

\end{document}

enter image description here

Second option:

By default, in the initial configurations, mdframed sets the background color to white, so

\begin{mdframed}[backgroundcolor=white]
test
\end{mdframed}

and

\begin{mdframed}
test
\end{mdframed}

are equivalent; notice that the default background color isn't really transparent, it is white and there's no predefined key to set the opacity for the background color (for a solution to the transparency issue using tcolorbox see third option below).

An example:

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

\begin{document}

\begin{mdframed}[backgroundcolor=white]
test
\end{mdframed}

\begin{mdframed}
test
\end{mdframed}

\end{document}

enter image description here

are equivalent.

Third option:

I don't recall mdframed offers a way to set the background opacity (but I might be wrong). With tcolorbox you can control the background and/ot frame opacity using opacityframe=<value>, opacityback=<value> (0 means completely transparent, 1 means opaque); A little example (\pagecolor{cyan!10} was used only to make the opcity effect visible):

\documentclass{article}
\usepackage{tcolorbox}

\pagecolor{cyan!10}
\begin{document}

\begin{tcolorbox}[
  standard jigsaw,
  opacityframe=0.5,
  opacityback=0.2
]
test
\end{tcolorbox}

\end{document}

enter image description here