Skip to main content
Corrected the code according to Clément's comment that shade=bilinear interpolation should be shading (which I tested).
Source Link
Bruno Le Floch
  • 45.8k
  • 6
  • 141
  • 246
\documentclass[a5paper]{article} \usepackage{lipsum} % To generate test text \usepackage{framed} \usepackage{tikz} \usepackage[margin=1cm]{geometry}% for screen preview \usetikzlibrary{decorations.pathmorphing,calc,shadows.blur,shadings} \pgfmathsetseed{1} % 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, shade=bilinearshading=bilinear interpolation, lower left=black!20, upper left=black!15, upper right=white, lower right=black!10}, irregular border/.style={decoration={irregular fractal line, amplitude=0.2}, decorate, }, ragged border/.style={ decoration={random steps, segment length=7mm, amplitude=2mm}, decorate, } } % Macro to draw the shape behind the text, when it fits completly in the % page \def\tornpaper#1{ \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 decorate[irregular border]{decorate{decorate{decorate{decorate[ragged border]{ ($(A.south east) - (0, random*5mm)$) -- ($(A.south west) - (0, random*5mm)$) }}}}} -- (A.north west) -- (A.north east) -- cycle; \end{pgfonlayer}} } \begin{document} \noindent \tornpaper{ \parbox{.9\textwidth}{\lipsum[11]} } \bigskip \noindent \tornpaper{ \parbox{.9\textwidth}{\lipsum[15]} } \end{document} 
\documentclass[a5paper]{article} \usepackage{lipsum} % To generate test text \usepackage{framed} \usepackage{tikz} \usepackage[margin=1cm]{geometry}% for screen preview \usetikzlibrary{decorations.pathmorphing,calc,shadows.blur,shadings} \pgfmathsetseed{1} % 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, shade=bilinear interpolation, lower left=black!20, upper left=black!15, upper right=white, lower right=black!10}, irregular border/.style={decoration={irregular fractal line, amplitude=0.2}, decorate, }, ragged border/.style={ decoration={random steps, segment length=7mm, amplitude=2mm}, decorate, } } % Macro to draw the shape behind the text, when it fits completly in the % page \def\tornpaper#1{ \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 decorate[irregular border]{decorate{decorate{decorate{decorate[ragged border]{ ($(A.south east) - (0, random*5mm)$) -- ($(A.south west) - (0, random*5mm)$) }}}}} -- (A.north west) -- (A.north east) -- cycle; \end{pgfonlayer}} } \begin{document} \noindent \tornpaper{ \parbox{.9\textwidth}{\lipsum[11]} } \bigskip \noindent \tornpaper{ \parbox{.9\textwidth}{\lipsum[15]} } \end{document} 
\documentclass[a5paper]{article} \usepackage{lipsum} % To generate test text \usepackage{framed} \usepackage{tikz} \usepackage[margin=1cm]{geometry}% for screen preview \usetikzlibrary{decorations.pathmorphing,calc,shadows.blur,shadings} \pgfmathsetseed{1} % 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, shading=bilinear interpolation, lower left=black!20, upper left=black!15, upper right=white, lower right=black!10}, irregular border/.style={decoration={irregular fractal line, amplitude=0.2}, decorate, }, ragged border/.style={ decoration={random steps, segment length=7mm, amplitude=2mm}, decorate, } } % Macro to draw the shape behind the text, when it fits completly in the % page \def\tornpaper#1{ \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 decorate[irregular border]{decorate{decorate{decorate{decorate[ragged border]{ ($(A.south east) - (0, random*5mm)$) -- ($(A.south west) - (0, random*5mm)$) }}}}} -- (A.north west) -- (A.north east) -- cycle; \end{pgfonlayer}} } \begin{document} \noindent \tornpaper{ \parbox{.9\textwidth}{\lipsum[11]} } \bigskip \noindent \tornpaper{ \parbox{.9\textwidth}{\lipsum[15]} } \end{document} 
replaced http://tex.stackexchange.com/ with https://tex.stackexchange.com/
Source Link

UPDATE See also the related question Torn paper: matching up the torn edges

UPDATE See also the related question Torn paper: matching up the torn edges

Added link o a related question
Source Link
JLDiaz
  • 56.6k
  • 5
  • 159
  • 218

UPDATE See also the related question Torn paper: matching up the torn edges

UPDATE See also the related question Torn paper: matching up the torn edges

Bounty Awarded with 200 reputation awarded by Mohan
Added note about Sumatra
Source Link
JLDiaz
  • 56.6k
  • 5
  • 159
  • 218
Loading
New and nicer version
Source Link
JLDiaz
  • 56.6k
  • 5
  • 159
  • 218
Loading
Source Link
JLDiaz
  • 56.6k
  • 5
  • 159
  • 218
Loading