# Lifted or curved drop shadow

Does anyone know if it is possible to create a "lifted corner" or curved drop shadow effect for a text box?

Something similar to this drop shadow effect

• – Ignasi May 26 '14 at 16:23
• @Ignasi You are right! I had voted for your answer half a year ago but forgot about it ... I like the lifted shadow feature and added it to version 3.05 of tcolorbox now. – Thomas F. Sturm May 28 '14 at 14:52

## 3 Answers

Here's another approach using tcolorbox with version 3.05 (2014/05/28) or newer. The lifted shadow of the old answer below has become an integrated feature (with different implementation) and is available by the option drop lifted shadow, drop small lifted shadow, or drop large lifted shadow:

\documentclass{article}

\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\begin{document}

\tcbox[enhanced,size=fbox,arc=0pt,outer arc=0pt,colback=blue!5!white,
before=\centering,colframe=blue!15!white,drop small lifted shadow]
{A small box with a small shadow}

\bigskip

\begin{tcolorbox}[enhanced,colback=white,colframe=black!50!white,boxrule=1pt,
arc=0pt,outer arc=0pt,drop lifted shadow]
\lipsum[2]
\end{tcolorbox}

\bigskip

\begin{tcolorbox}[enhanced,colback=yellow!5!white,colframe=black!50!yellow,boxrule=1pt,
drop lifted shadow]
\lipsum[2]
\end{tcolorbox}

\bigskip

\begin{tcolorbox}[enhanced,colback=red!5!white,colframe=black!50!red,boxrule=1pt,
arc=0pt,outer arc=0pt,drop large lifted shadow]
\lipsum[2]
\end{tcolorbox}

\end{document}


Old version of the answer (valid for tcolorbox older than version 3.05):

The following code adds some new shadow features drop lifted shadow and drop heavy lifted shadow to tcolorbox.

\documentclass{article}

\usepackage[many]{tcolorbox}% until version 3.04
\usepackage{lipsum}

\makeatletter

\def\tcb@shadow@lifted#1#2#3#4{%
\path[fill,rounded corners=\tcb@outer@arc,#4]
([xshift=#1+#3,yshift=#2+#3]frame.south west)
.. controls ([yshift=\dimexpr#3]frame.south) ..
([xshift=-#1-#3,yshift=#2+#3]frame.south east)
-- ([xshift=-#1-#3,yshift=#2-#3]frame.north east)
-- ([xshift=#1+#3,yshift=#2-#3]frame.north west)
-- cycle;
}

\tcbset{
lifted shadow/.style args={#1#2#3#4}{shad@w app={%
\begin{scope}[#4]%
\tcb@shadow@lifted{#1}{#2}{\dimexpr-4\dimexpr#3}{opacity=0.01}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr-3\dimexpr#3}{opacity=0.02}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr-2\dimexpr#3}{opacity=0.04}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr-#3}{opacity=0.07}%
\tcb@shadow@lifted{#1}{#2}{0pt}{opacity=0.11}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr+#3}{opacity=0.11}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr+2\dimexpr#3}{opacity=0.07}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr+3\dimexpr#3}{opacity=0.04}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr+4\dimexpr#3}{opacity=0.02}%
\tcb@shadow@lifted{#1}{#2}{\dimexpr+5\dimexpr#3}{opacity=0.01}%
\end{scope}}},%
drop lifted shadow/.style={lifted shadow={1.5mm}{-1.5mm}{0.12mm}{#1}},
drop lifted shadow/.default={black!50!white},%
drop heavy lifted shadow/.style={lifted shadow={2mm}{-3mm}{0.16mm}{#1}},
drop heavy lifted shadow/.default={black!50!white},%
}

\makeatother

\begin{document}

\begin{tcolorbox}[enhanced,colback=white,colframe=black!50!white,boxrule=1pt,
arc=0pt,outer arc=0pt,drop lifted shadow]
\lipsum[2]
\end{tcolorbox}

\bigskip

\begin{tcolorbox}[enhanced,colback=yellow!5!white,colframe=black!50!yellow,boxrule=1pt,
drop lifted shadow]
\lipsum[2]
\end{tcolorbox}

\bigskip

\begin{tcolorbox}[enhanced,colback=red!5!white,colframe=black!50!red,boxrule=1pt,
arc=0pt,outer arc=0pt,drop heavy lifted shadow]
\lipsum[2]
\end{tcolorbox}

\end{document}


• This seems like a nice option as well although having a lot of trouble getting it to compile using TeXLive (MacTeX). On first attempt, got error re. 'many' not valid option for tcolorbox so updated from 2012 to 2013. Now getting issue with the following error which I don't have much of a clue on: "Undefined control sequence. \pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ l.43 \end{tcolorbox}" – user52465 May 26 '14 at 17:42
• @user52465 see How do I update my TeX distribution? – cmhughes May 27 '14 at 3:08
• @user52465 The tcolorbox version of TeXLive 2013 is too old. You can get the recent version from CTAN by mirrors.ctan.org/install/macros/latex/contrib/tcolorbox.tds.zip For the further steps, see the link cmhughes has provided. – Thomas F. Sturm May 27 '14 at 5:25
• Thanks Thomas. I updated all of the reported out of date packages which fixed the problem. – user52465 May 28 '14 at 1:05
• great that it seems fixed. in the future to get an up-to-date version oftexlive, I suggest using homebrew + casks: github.com/meduz/dotfiles/blob/master/init/… – meduz May 28 '14 at 7:22

The following approach is a compromise between simple interface and code complexity. The result looks good imho.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds, calc, shadows, shadows.blur}

\newcommand\addcurlyshadow[2][]{
% #1: Optional aditional tikz options
% #2: Name of the node to "decorate"
\begin{pgfonlayer}{background}
\path[blur shadow={shadow xshift=0pt, shadow yshift=0pt, shadow blur steps=6}, #1]
($(#2.north west)+(.3ex,-.5ex)$)
-- ($(#2.south west)+(.5ex,-.7ex)$)
.. controls ($(#2.south)!.3!(#2.south west)$) .. (#2.south)
.. controls ($(#2.south)!.3!(#2.south east)$) .. ($(#2.south east)+(-.5ex,-.7ex)$)
-- ($(#2.north east)+(-.3ex, -.5ex)$)
-- cycle;
\end{pgfonlayer}
}

\begin{document}
\begin{tikzpicture}
\node[draw=black!40, fill=white, rectangle, minimum width=3cm, minimum height=1cm]
(example) {Test};
\addcurlyshadow{example}
\end{tikzpicture}\end{document}


Results in:

For fun, I ported @Thomas's solution to Metapost + ConTeXt. To use it, download t-backgrounds and put it in a place where ConTeXt can find it (either the local directory or somewhere in \$TEXMF/tex/context/ directory.

The module provides two overlays liftedshadow:medim and liftedshadow:big, which can be used a background in any command that accepts background key (for example, \framed or \startframedtext). Here is an example usage:

\usemodule[backgrounds]

\definecolor[darkred][r=0.75]
\definecolor[lightred][r=1,g=0.95,b=0.95]
\definecolor[lightblue][r=0.95,g=0.95,b=1]

\defineframedtext
[shadowedtext]
[
framecolor=darkred,
background={liftedshadow:big,color},
backgroundcolor=lightred,
rulethickness=1pt,
width=broad,
]

\defineframed
[shadowed]
[
frame=off,
background={liftedshadow:medium,color},
backgroundcolor=lightblue,
width=fit,
]

\usemodule[visual]

\starttext

\midaligned{\shadowed{\fakewords{4}{6}}}

\startshadowedtext
\fakewords{40}{50}
\stopshadowedtext

\stoptext


which gives

More details on how to change the shadow color and shadow size are explained in this blog post.