TikZ 代码不再编译

TikZ 代码不再编译

考虑以下代码:

\documentclass{article}

\usepackage{expl3}
\usepackage{tikz}

\usetikzlibrary{
  hobby,
  shapes.geometric,
  decorations,
  decorations.shapes,
  shapes.geometric,
  patterns
}

% http://www.guitex.org/home/it/forum/5-tex-e-latex/83195-la-libreria-hobby-tikz-non-funziona-piu#83203
\ExplSyntaxOn
  \cs_if_exist:NF \prg_stepwise_function:nnnN { \cs_gset_eq:NN \prg_stepwise_function:nnnN \int_step_function:nnnN }
  \cs_if_exist:NF \prg_stepwise_inline:nnnn { \cs_gset_eq:NN \prg_stepwise_inline:nnnn \int_step_inline:nnnn }
\ExplSyntaxOff

\makeatletter
\pgfdeclareradialshading[tikz@ball]{easter bg}{\pgfpoint{5bp}{25bp}}{%
  color(0cm)=(tikz@ball!20);
  color(0.15cm)=(tikz@ball!30);
  color(0.4cm)=(tikz@ball!60);
  color(0.9cm)=(tikz@ball)
}
\tikzoption{easter bg color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{easter bg}\tikz@addmode{\tikz@mode@shadetrue}}

\pgfkeys{/tikz/easter star/.code args={#1 and #2}{
  \pgfdeclareradialshading[tikz@ball]{easter star}{\pgfpoint{#1}{#2}}{%
  color(0cm)=(tikz@ball!20);
  color(0.3cm)=(tikz@ball!40);
  color(0.65cm)=(tikz@ball!60);
  color(1cm)=(tikz@ball)
  }
 }
 \tikzoption{easter star color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{easter star}\tikz@addmode{\tikz@mode@shadetrue}}
}
\makeatother

% original code by Paul Gaborit:
% tex.stackexchange.com/questions/72784/arrow-with-two-colors-with-tikz/#72793
\tikzset{
  double path/.style args = {#1 colored by #2 and #3}{
    -, line join = round, line cap = rect,
    shorten >= 0.1cm,
    shorten <= 0.1cm,
    line width = #1,#2, % first path
    postaction = {
      draw,-,
      #3,
      line width = (#1)/1.5,
      shorten <= (#1)/3,
      shorten >= (#1)/3
    } % second path
  }%
}

\tikzset{easter decoration 1/.style = {
    decorate,
    decoration = {
      shape backgrounds,
      shape = star,
      shape size = 7pt,
      shape sep = {0.5cm, between center}
    },
    inner color = yellow,
    outer color = yellow!50!orange,
    draw = red!20!orange
  }%
}

\pgfdeclarepatternformonly{fivepointed stars easter 2}{\pgfpointorigin}{\pgfpoint{10mm}{10mm}}{\pgfqpoint{10mm}{8mm}}%
{
  \pgftransformshift{\pgfqpoint{1mm}{1mm}}
  \pgfpathmoveto{\pgfqpointpolar{18}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{162}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{306}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{90}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{234}{1mm}}
  \pgfpathclose%
  \pgfusepath{fill}
}

\tikzset{easter decoration 3/.style={
    draw=green!17!yellow,
    line width=2pt,
    star
  }
}

\pgfdeclarepatternformonly{fivepointed stars easter 3}{\pgfpointorigin}{\pgfpoint{12mm}{12mm}}{\pgfqpoint{12mm}{11mm}}%
{
  \pgftransformshift{\pgfqpoint{1mm}{1mm}}
  \pgfpathmoveto{\pgfqpointpolar{18}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{162}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{306}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{90}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{234}{1mm}}
  \pgfpathclose%
  \pgfusepath{fill}
}


\begin{document}

\begin{tikzpicture}[use Hobby shortcut]
  \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Påskeæg~1};
  % Path clipping.
  \clip[scale=-6](0.5,0.1) to[closed,curve through={ (0.775,0.35) .. (0.5,1) .. (0.225,0.35)}] (0.5,0.1);
  % Shading.
  \shade[easter bg color=orange,scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  % Colored paths.
  \draw[double path=5pt colored by orange!80!yellow and yellow,scale=-6] (0.775,0.35) .. (0.735,0.35)  .. (0.65,0.3) .. (0.45,0.4) .. (0.235,0.355) .. (0.225,0.35);
  \draw[double path=5pt colored by orange!80!yellow and yellow,scale=-6] (0.9,0.5) .. (0.775,0.55)  .. (0.55,0.5) .. (0.45,0.6) .. (0.235,0.55) .. (0.1,0.5);
  \draw[double path=5pt colored by orange!80!yellow and yellow,scale=-6] (0.9,0.7) .. (0.775,0.75)  .. (0.55,0.7) .. (0.45,0.8) .. (0.235,0.75) .. (0.1,0.7);
  % Stars.
  \draw[easter decoration 1,scale=-6] (0.775,0.25) .. (0.735,0.25)  .. (0.65,0.2) .. (0.45,0.3) .. (0.235,0.255) .. (0.225,0.25);
  \draw[easter decoration 1,scale=-6] (0.9,0.4) .. (0.775,0.45)  .. (0.55,0.4) .. (0.45,0.5) .. (0.235,0.45) .. (0.1,0.4);
  \draw[easter decoration 1,scale=-6] (0.9,0.6) .. (0.775,0.65)  .. (0.55,0.6) .. (0.45,0.7) .. (0.235,0.65) .. (0.1,0.6);
  \draw[easter decoration 1,scale=-6] (0.9,0.8) .. (0.775,0.85)  .. (0.55,0.8) .. (0.45,0.9) .. (0.235,0.85) .. (0.1,0.8);
  % Draw the border again.
  \draw[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{tikzpicture}
% Easter Egg 2.
\begin{tikzpicture}[use Hobby shortcut]
  \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Påskeæg~2};
  % Path clipping.
  \clip[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  % Shading.
  \draw[easter bg color=blue!65!cyan,scale=-6,postaction={pattern=fivepointed stars easter 2,pattern color=blue}](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  \begin{scope}[transform canvas={shift={(-3.5,-3.5)}}]
   \node[star,scale=2.25,easter star=2bp and 10bp, easter star color=cyan!65!blue] at (0.35,0.75){};
   \node[star,scale=1.5,easter star=-2bp and 15bp, easter star color=cyan!85!blue,rotate=10] at (1.45,1.45){};
   \node[star,scale=1.5,easter star=5bp and 10bp, easter star color=cyan!75!blue,rotate=-10] at (-0.5,1.95){};
   \node[star,scale=1.65,easter star=5bp and 15bp, easter star color=cyan!45!blue,rotate=-5] at (-0.75,-0.85){};
   \node[star,scale=1.7,easter star=5bp and 15bp, easter star color=cyan!37!blue,rotate=-3] at (0,-1.65){};
   \node[star,scale=1.5,easter star=5bp and 10bp, easter star color=cyan!60!blue,rotate=2] at (0.85,-0.65){};
   \node[star,scale=1.75,easter star=-2bp and 2bp, easter star color=cyan!60!blue,rotate=14] at (2,0){};     
  \end{scope}
   % Draw the border again.
   \draw[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{tikzpicture}
% Easter Egg 3.
\begin{tikzpicture}[use Hobby shortcut]
  \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Påskeæg~3};
  % Path clipping.
  \clip[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  % Shading.
  \draw[easter bg color=green!77!blue,scale=-6,postaction={pattern=fivepointed stars easter 3,pattern color=green!20!yellow}](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  \begin{scope}[transform canvas={shift={(-3.5,-3.5)}}]
   \node[easter decoration 3,scale=2.25] at (0.55,0.65){};
   \node[easter decoration 3,scale=1.5,rotate=10] at (1.45,1.45){};
   \node[easter decoration 3,scale=1.5,rotate=-10] at (-0.5,1.95){};
   \node[easter decoration 3,scale=1.65,rotate=-5] at (-0.75,-0.70){};
   \node[easter decoration 3,scale=1.7,rotate=-3] at (0,-1.65){};
   \node[easter decoration 3,scale=1.5,rotate=2] at (0.85,-0.65){};
   \node[easter decoration 3,scale=1.75,rotate=14] at (2,0){};     
  \end{scope}
  % Draw the border again.
  \draw[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{tikzpicture}

\end{document}

之前,上面的代码已经生成了三颗复活节彩蛋的图片,但是现在我得到了以下错误:

! Undefined control sequence.
<argument> \fp_if_undefined:NTF 
                                \l_hobby_out_angle_fp {\array_put:Nnx \l_hob...
l.113 ... .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);

有人能帮我修改代码让它再次工作吗?

PS:我自己根本不使用 TikZ。

答案1

hobby软件包内部广泛使用 LaTeX3。因此,当 LaTeX3 函数更新时,hobby 软件包有时需要修复和更新自身。完成此操作后,需要将其上传到 CTAN。看来,尽管 hobby 已根据 LaTeX3 的最新修改进行了更新,但这些更新尚未上传到 CTAN,因此不在 TeXLive 附带的版本中。

与此同时,可以直接从TeX-SX 软件包存储库在 Launchpad 上(下载hobby.dtx,使用 生成文件tex hobby.dtx)。

因此,使用 TeX-SX Launchpad 的最新版本的 hobby 再试一次,我想你会发现它运行良好。

相关内容