I found this beautiful example making a fractal paper tear out text box, but I can't get it to work, when I open it in overleaf

http://www.texample.net/tikz/examples/torn-paper/
The code looks like this, please open the original from the link
Code: Select all
% Torn paper with matching torn edges
% Author: Jose Luis Diaz
\documentclass[a5paper]{article}
\usepackage{lipsum} % To generate test text
\usepackage{framed}
\usepackage{ifthen}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{center}
\setlength\PreviewBorder{10pt}%
%%%>
\begin{comment}
:Title: Torn paper with matching torn edges
:Tags: Styles;Fractals;Decorative drawings;Fun
:Author: Jose Luis Diaz
:Slug: torn-paper
This example is similar to: http://texample.net/tikz/examples/framed-tikz/
Fractal decorations are used to achieve a torn paper effect.
The bottom of one piece matched the top of the next one.
This is done by resetting the random seed before drawing each border.
However, you get the "same" random border in all your fragments,
which is not nice. You want randomness in each new bottom border,
but exactly the same randomness in the next top border. In order to get this,
you need a global counter which is increased in each "paper fragment",
and which is used as seed for the bottom border.
It is neccesary to use \pgfextra to be able of setting the seed in the middle
of the path (i.e: between top and bottom borders).
In addition, there is the problem that both paths (top and bottom) have to be
drawn in the same direction in order to get the same contour.
In order to fill the piece of paper with a background, it is not possible
to draw both top and bottom borders in the same direction (eg. left to right).
So the solution involves drawing one piece of paper visiting its corners in
clockwise direction, and the following one in counter-clockwise direction.
I use the counter mathseed and draw in one direction or the other based
on \isodd{mathseed}.
The algorithm that draws the fractal border tends to produce "spikes" towards
its right (in the advance direction), and "cloud borders" towards its left. So,
a box drawn in clockwise direction would have a "cloudy" aspect, while one
drawn in counterclockwise direction would have a "spiky" aspect.
The assymetry can be make less apparent if the bottom border is drawn with
a negative amplitude (which reverses the side towards the spikes appear).
This is easy to achieve by defining two irregular border styles,
which are used alternatively.
This code was written by Jose Luis Diaz and published on TeX.SE.
\end{comment}
\usepackage[margin=1cm]{geometry}% for screen preview
\usetikzlibrary{decorations.pathmorphing,calc,shadows.blur,shadings}
\newcounter{mathseed}
\setcounter{mathseed}{3}
\pgfmathsetseed{\arabic{mathseed}} % To have predictable results
% Define a background layer, in which the parchment shape is drawn
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
% This is the base for the fractal decoration. It takes a random point between the start and end, and
% raises it a random amount, thus transforming a segment into two, connected at that raised point
% This decoration can be applied again to each one of the resulting segments and so on, in a similar
% way of a Koch snowflake.
\pgfdeclaredecoration{irregular fractal line}{init}
{
\state{init}[width=\pgfdecoratedinputsegmentremainingdistance]
{
\pgfpathlineto{\pgfpoint{random*\pgfdecoratedinputsegmentremainingdistance}{(random*\pgfdecorationsegmentamplitude-0.02)*\pgfdecoratedinputsegmentremainingdistance}}
\pgfpathlineto{\pgfpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
}
}
% define some styles
\tikzset{
paper/.style={draw=black!10, blur shadow, every shadow/.style={opacity=1, black}, shade=bilinear interpolation,
lower left=black!10, upper left=black!5, upper right=white, lower right=black!5, fill=none},
irregular cloudy border/.style={decoration={irregular fractal line, amplitude=0.2},
decorate,
},
irregular spiky border/.style={decoration={irregular fractal line, amplitude=-0.2},
decorate,
},
ragged border/.style={ decoration={random steps, segment length=7mm, amplitude=2mm},
decorate,
}
}
\def\tornpaper#1{%
\ifthenelse{\isodd{\value{mathseed}}}{%
\tikz{
\node[inner sep=1em] (A) {#1}; % Draw the text of the node
\begin{pgfonlayer}{background} % Draw the shape behind
\fill[paper] % recursively decorate the bottom border
\pgfextra{\pgfmathsetseed{\arabic{mathseed}}\addtocounter{mathseed}{1}}%
{decorate[irregular cloudy border]{decorate{decorate{decorate{decorate[ragged border]{
(A.north west) -- (A.north east)
}}}}}}
-- (A.south east)
\pgfextra{\pgfmathsetseed{\arabic{mathseed}}}%
{decorate[irregular spiky border]{decorate{decorate{decorate{decorate[ragged border]{
-- (A.south west)
}}}}}}
-- (A.north west);
\end{pgfonlayer}}
}{%
\tikz{
\node[inner sep=1em] (A) {#1}; % Draw the text of the node
\begin{pgfonlayer}{background} % Draw the shape behind
\fill[paper] % recursively decorate the bottom border
\pgfextra{\pgfmathsetseed{\arabic{mathseed}}\addtocounter{mathseed}{1}}%
{decorate[irregular spiky border]{decorate{decorate{decorate{decorate[ragged border]{
(A.north east) -- (A.north west)
}}}}}}
-- (A.south west)
\pgfextra{\pgfmathsetseed{\arabic{mathseed}}}%
{decorate[irregular cloudy border]{decorate{decorate{decorate{decorate[ragged border]{
-- (A.south east)
}}}}}}
-- (A.north east);
\end{pgfonlayer}}
}}
\begin{document}
\begin{center}
\noindent
\tornpaper{
\parbox{.9\textwidth}{\lipsum[11]}
}
\noindent
\tornpaper{
\parbox{.9\textwidth}{\lipsum[15]}
}
\noindent
\tornpaper{
\parbox{.9\textwidth}{\lipsum[5]}
}
\end{center}
\end{document}

Overleaf throwing error:
Code: Select all
Package pgfkeys Error: Choice 'bilinear interpolation' unknown
in choice key '/tikz/shade'. I am going to ignore this key.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.146 }
As I am still quite a greenLaTeXhorn, I would be glad for a helping hand getting this example to work. Thank you.