You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

\usepackage{calc}
\newlength{\boxw}
\newlength{\boxh}
\newlength{\boxroundness}
\newlength{\shadowsize}
\newlength{\tmpa}
\setlength{\shadowsize}{6pt}
\setlength{\boxroundness}{3pt}
\newsavebox{\shadowblockbox}
\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}
\addtolength{\boxw}{\boxroundness * 2}
\addtolength{\boxh}{\boxroundness * 2}
\begin{tikzpicture}
\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=gray!40, draw=black!10, 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}
}
%
% We prepare a transparent box first.
%
%\newsavebox{\mybox}
%\begin{lrbox}{\mybox}
%\begin{shadowblock}{5cm}
%This is a block of text with a transparent
%shadow!
%\end{shadowblock}
%\end{lrbox}
%\raisebox{0cm}[0pt][0pt]{\makebox[0pt]{\usebox{\mybox}}}
%{\usebox{\mybox}}
%\begin{textblock}{4}(2,5.2)
%\begin{shadowblock}{4cm}
%And a small one on top of it.
%\end{shadowblock}
%\end{textblock}