1

I currently have a problem with the mdframed shadow color. If I set the shadowcolor parameter to black, the shadow will actually be grey (I guess because it is not fully opaque...), as seen on the picture.

How can I make a fully black (or any color) shadow with the mdframed?

Here is the code I used:

\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{shadows}

\begin{mdframed}[backgroundcolor=white, shadow=true, shadowcolor=black, linewidth=1pt, linecolor=red, shadowsize=5.5pt]
text

\end{mdframed}
1

By default, TiKZ shadows use opacity=.5 and mdframed uses default settings. The problem is that mdframed doesn't offer any option to change anything from shadows except their color, so we must go to TiKZ to change opacity, something like \tikzset{every shadow/.style={opacity=1}} seems to work, but it will change opacity for all mdframed boxes.

enter image description here

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

\begin{document}
\tikzset{every shadow/.style={opacity=1}}

\begin{mdframed}[backgroundcolor=white, shadow=true, shadowcolor=black, 
          linewidth=1pt, linecolor=red, shadowsize=5.5pt]
text

\end{mdframed}

\end{document}

An alternative solution could be to change from mdframed to tcolorbox which offers easily customizable shadows:

\documentclass{article}
\usepackage[most]{tcolorbox}   

\begin{document}

\begin{tcolorbox}[notitle, sharp corners, colframe=red, colback=white, 
       boxrule=1pt, boxsep=0pt, enhanced, 
       shadow={3pt}{-3pt}{0pt}{opacity=1,black}]
text
\end{tcolorbox}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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