撕纸问题编译

撕纸问题编译

我读本文关于如何制作撕纸效果。所以我尝试了下面的代码,但出现了一些错误。

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{lipsum}   % To generate test text
\usepackage{framed}
\usepackage{ifthen}
\usepackage{tikz}
\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,
    }
}
\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}
\noindent
\tornpaper{
\parbox{.9\textwidth}{\lipsum[11]}
}

\noindent
\tornpaper{
\parbox{.9\textwidth}{\lipsum[15]}
}

\noindent
\tornpaper{
\parbox{.9\textwidth}{\lipsum[5]}
}
\end{document}

报告如下:

  • 您不能在受限水平模式下使用“宏参数字符 #”。 \node[inner sep=1em] (A) {#
  • 软件包 pgfkeys 错误:选择键“/tikz/shade”中的选项“双线性插值”未知。我将忽略此键。\fill[paper]
  • 缺少 \begin{document}。\end{pgfonlayer}}
  • } 太多。}
  • 您不能在受限水平模式下使用“宏参数字符 #”。 \node[inner sep=1em] (A) {#
  • 软件包 pgfkeys 错误:选择键“/tikz/shade”中的选项“双线性插值”未知。我将忽略此键。\fill[paper]
  • } 太多。}}
  • 未定义控制序列。\tornpaper
  • 未定义控制序列。\tornpaper
  • 未定义控制序列。\tornpaper

问题是什么?

提前致谢!

相关内容