# 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

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,
{A small box with a small shadow}

\bigskip

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

\bigskip

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

\bigskip

\begin{tcolorbox}[enhanced,colback=red!5!white,colframe=black!50!red,boxrule=1pt,
\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

\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{
\begin{scope}[#4]%
\end{scope}}},%
}

\makeatother

\begin{document}

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

\bigskip

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

\bigskip

\begin{tcolorbox}[enhanced,colback=red!5!white,colframe=black!50!red,boxrule=1pt,
\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}

% #1: Optional aditional tikz options
% #2: Name of the node to "decorate"
\begin{pgfonlayer}{background}
($(#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};
\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
[
framecolor=darkred,
backgroundcolor=lightred,
rulethickness=1pt,
]

\defineframed
[
frame=off,
backgroundcolor=lightblue,
width=fit,
]

\usemodule[visual]

\starttext