I would like to create an environment like this:
which I have created with this code:
%
% Boxed environment with semi-transparent shadow.
%
\newlength{\boxw}
\newlength{\boxh}
\newlength{\shadowsize}
\newlength{\boxroundness}
\newlength{\tmpa}
\newsavebox{\shadowblockbox}
\setlength{\shadowsize}{6pt}
\setlength{\boxroundness}{3pt}
\newenvironment{shadowblock}[1]%
{\begin{lrbox}{\shadowblockbox}\begin{minipage}{#1}}%
{\end{minipage}\end{lrbox}%
\settowidth{\boxw}{\usebox{\shadowblockbox}}%
\settodepth{\tmpa}{\usebox{\shadowblockbox}}%
\settoheight{\boxh}{\usebox{\shadowblockbox}}%
\addtolength{\boxh}{\tmpa}%
\begin{tikzpicture}
\addtolength{\boxw}{\boxroundness * 2}
\addtolength{\boxh}{\boxroundness * 2}
\foreach \x in {0,.05,...,1}
{
\setlength{\tmpa}{\shadowsize * \real{\x}}
\fill[xshift=\shadowsize - 1pt,yshift=-\shadowsize +
1pt,black,opacity=.04,rounded corners=\boxroundness]
(\tmpa, \tmpa) rectangle +(\boxw - \tmpa - \tmpa, \boxh - \tmpa -
\tmpa);
}
\filldraw[fill=yellow!50, draw=black!50, rounded corners=\boxroundness] (0,
0) rectangle (\boxw, \boxh);
\draw node[xshift=\boxroundness,yshift=\boxroundness,inner sep=0pt,outer
sep=0pt,anchor=south west] (0,0) {\usebox{\shadowblockbox}};
\end{tikzpicture}}
As you can see if you compile it has a fading shadow, however, as it uses \minipage
in case the text is very long it doesn't split into 2 pages. I have though that this could be achieved with the environment mdframed
, however, although it has shadows it doesn't have any fading effect. I have tried for example:
\begin{mdframed}[backgroundcolor=yellow!50,linecolor=black!50,roundcorner=10pt, % shadow=true,
tikzsetting={shade,
top color=yellow!50,
bottom color=yellow!10,
rounded corners=1pt,
blur shadow={shadow blur steps=5,shadow blur extra rounding=1.3pt,shadow yshift=-0.5cm}
}]
\lipsum[4-5]
\end{mdframed}
but when you compile it doesn't correcty draw the shadow:
Any ideas?