# Torn page effect

[See Torn paper: matching up the torn edges for more on this topic, as well as better illustrations of the final product.]

I have a document with a lot of short excerpts from another book scattered through it. Putting frames around them looks a little too 'clean'. How can I get a 'torn page' type effect, to make it look as if the excerpt has been physically torn out of a book? (I've occasionally seen this done in printed books, although I can't find an example right now.)

I'm not wedded to a very specific look here -- Googling 'torn page' gives plenty of examples. But just to give this some frame of reference, here are some of the nicer ones:

http://www.vectorstock.com/i/composite/84,79/white-paper-rip-edge-vector-198479.jpg

http://lh6.ggpht.com/-eO-uRyGeA_0/TUkzCMuwuJI/AAAAAAAAB6E/2och4rP0l88/386--x--277--torn-paper.jpg

(The strong colouration in this second example is a probably a little too distracting for actual use, although it might be interesting as an option. It's more the edge effect I'm interested in.)

Edit (again): I tried typesetting my text according to the updated versions of the answers below. Here are the results:

• I am quite sure some tikz answers will show up soon; I'd like to note that it seems to me that some fractal-based solution might be a good idea. Dec 8, 2012 at 20:14
• For clarification: Are you interested in actually cutting off text, or just framing it with ragged edges that look like a torn page? Dec 9, 2012 at 0:13
• @Charles Staats: just framing. Dec 9, 2012 at 0:24
• Relevant: mathematica.stackexchange.com/q/4148 (if someone's looking for ideas) Dec 9, 2012 at 4:44
• To insert a image sample which looks right, you can capture the screen when using the appropriate pdf viewer, and crop the relevant part. A good tool for this kind of things under Windows is irfanview. Dec 9, 2012 at 18:28

Not exactly the result you wanted, but it can be a starting point. It combines framed and tikz packages. The idea can lead to further improvements.

See http://www.texample.net/tikz/examples/framed-tikz/ (btw, I'm the author)

UPDATE: Playing with the idea of a fractal decoration, and also with shaded paper and blurred drop shadows, I got the following results. Currently the implementation still does not use framed, so it is restricted to the case in which the framed paragraph does not break among pages.

\documentclass[a5paper]{article}
\usepackage{lipsum}   % To generate test text
\usepackage{framed}
\usepackage{tikz}
\usepackage[margin=1cm]{geometry}% for screen preview
\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{
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}


NOTE Some pdf viewers (eg. Sumatra) have issues to display the interpolated shading used in the last examples.

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

• Even if it's not quite what I'm looking for, that's beautiful! I don't suppose you'd consider turning it into a package? Dec 8, 2012 at 20:20
• Regarding the update: the q. doesn't request multi-page excerpts, so I think you're safe! Dec 9, 2012 at 10:47
• Acrobat 9.4.1 displays correctly, some portability limintations: Evince 3.6.1 shows an artificial grid inside a the paper, qpdfview 0.4.1 shows the paper correctly but there are glitches in the shadow, xpdf 3.03 shows all black.
– alfC
May 6, 2013 at 22:17
• @JLDiaz, Also, is there any change one can use this frame around a lstlisting enviroment? I can't do it (\lst@next has an extra }). The error has to do with fragile issues.
– alfC
May 6, 2013 at 23:21
• Since version 3.0, shade=bilinear interpolation should be shading=bilinear interpolation. Feb 4, 2015 at 23:50

Here is an approach which builds on Marc van Dongen's answer to Simulating hand-drawn lines.

\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\definecolor{paper}{RGB}{239,227,157}
\usepackage{lipsum}
\begin{document}
\begin{tikzpicture}[pencildraw/.style={ %
decorate,
decoration={random steps,segment length=2pt,amplitude=1pt}
} %
]
\node[
preaction={fill=black,opacity=.5,transform canvas={xshift=1mm,yshift=-1mm}},
pencildraw,draw,fill=paper,text width=.8\textwidth,inner sep=5mm]
{\lipsum[1]};
\end{tikzpicture}
\end{document}


Output:

And yes, this does not really look like paper.

• Thanks! Is memoir a requirement? Dec 8, 2012 at 22:16
• No, memoir is not required. See also the question that I linked to. Dec 8, 2012 at 22:16
• By the way, is it possible to change the colour of the 'rectangle' enclosed by the line, or does the ragged edge make that difficult? Dec 8, 2012 at 22:53
• @Mohan, it's easy to change the color. Simply replace fill=white with another color. You could define a new color \definecolor{paper}{RGB}{239,227,157}, and use fill=paper Dec 8, 2012 at 23:05
• @Ipsen... I would say that this is also well worth making into a package. Dec 9, 2012 at 10:45

I think this would be a natural application of the tcolorbox package.

In the answer below, I've used part of Jesper's answer to decorate the tcolorbox environment; this approach permits an environment-based approach, so that you can use, for example,

\begin{tornpage}
\lipsum
\end{tornpage}


Furthermore, the tcolorbox allows page breaks.

Here's a complete MWE which can be built upon.

% arara: pdflatex
% !arara: indent: {overwrite: on}
\documentclass{article}
\usepackage[many]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}
\definecolor{paper}{RGB}{239,227,157}
\usepackage{lipsum}
\newtcolorbox{tornpage}{%
enhanced jigsaw, breakable, % allow page breaks
frame hidden, % hide the default frame
overlay={%
\draw [
fill=paper, % fill paper
draw=paper!50!black, % boundary colour
decorate, % decoration
decoration={random steps,segment length=2pt,amplitude=1pt},
]
% top line
(frame.north west)--(frame.north east)--
% right line
(frame.north east)--(frame.south east)--
% bottom line
(frame.south east)--(frame.south west)--
% left line
(frame.south west)--(frame.north west);
},
% paragraph skips obeyed within tcolorbox
parbox=false,
}
\begin{document}
\begin{tornpage}
\lipsum[1]
\end{tornpage}
\begin{tornpage}
\lipsum
\end{tornpage}
\end{document}