5

While trying to use the torn page effect in a beamer document, I was confronted to an unexpected problem.

If you just take the the code of this answer and compile it, you get:

Screenshot of the torn effect on article

If you just change the class to beamer (and comment the geometry package), you get:

Screenshot of the torn effect on beamer

A thin (ugly) line just appeared at the end of the shadow (which is not quite the same either). I tried a lot of options and modification of the code, looked at the beamer documentation (ouch), but could not find any clue on how to remove this thin line (or at least, makes it white).

  • 3
    The option in version 3.0 should be shading=bilinear interpolation. – Gonzalo Medina Feb 4 '15 at 23:49
  • 1
    The output looks fine on my machine after correcting the TikZ option mentioned by @GonzaloMedina. See: i.stack.imgur.com/mEnJ0.png – Herr K. Feb 5 '15 at 0:00
  • 2
    This is a viewer issue. I can confirm the problem using Okular and the TeXworks viewer, but the problem disappears using Acrobat Reader. – Gonzalo Medina Feb 5 '15 at 0:01
  • 3
    Most viewers can't handle PS based shadings. So test everything on Acrobat. – percusse Feb 5 '15 at 0:03
  • 3
    @cfr If it doesn't work in Acrobat then you can think of a TeX problem otherwise almost always it is a viewer issue. Especially with fadings XeTeX is another smoking gun. Makes life easier for debugging. – percusse Feb 5 '15 at 0:56
1

This question gets some votes but the answer is somehow hidden in the comments. To sum up: this difference is due to the pdf viewer.

Everything works fine with Adobe Reader, which should always be the reference.

The reason why most viewers can display the effect when the class article is used, and not when the class beamer is used remains a mystery.

For the record, the code tested was

\documentclass[a5paper]{beamer}
\usepackage{lipsum}   % To generate test text 
\usepackage{framed}
\usepackage{tikz}
\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.