我正在定义一个新的箭头。我通读了文档,并决定进行一些小改动,将现有的 foo 定义移至我的自定义箭头定义。
但是,我遇到了一个问题。当我尝试编译手册中的代码(3.0.1a 手册的第 1004 节、第 1020 页)时,出现以下错误:
Missing number, treated as zero.
我希望得到帮助以了解错误的原因,并获得一些关于如何自行解决此类错误的建议。
MWE 如下:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\pgfdeclarearrow{
name = foo,
parameters = { \the\pgfarrowlength },
setup code = {
% The different end values:
\pgfarrowssettipend{.25\pgfarrowlength}
\pgfarrowssetlineend{-.25\pgfarrowlength}
\pgfarrowssetvisualbackend{-.5\pgfarrowlength}
\pgfarrowssetbackend{-.75\pgfarrowlength}
% The hull
\pgfarrowshullpoint{.25\pgfarrowlength}{0pt} \pgfarrowshullpoint{-.75\pgfarrowlength}{.5\pgfarrowlength} \pgfarrowshullpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength} % Saves: Only the length:
\pgfarrowssavethe\pgfarrowlength
},
drawing code = {
\pgfpathmoveto{.25\pgfarrowlength}{0pt}
\pgfpathlineto{-.75\pgfarrowlength}{.5\pgfarrowlength}
\pgfpathlineto{-.5\pgfarrowlength}{0pt}
\pgfpathlineto{-.75\pgfarrowlength}{-.5\pgfarrowlength}
\pgfpathclose
\pgfusepathqfill
},
defaults = { length = 4cm }
}
\begin{document}
\begin{tikzpicture}
\draw [-foo] (0,0) -- (8,0);
\end{tikzpicture}
\end{document}
答案1
我建议将此作为文档中的错误报告。我猜应该是这样的:
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\pgfdeclarearrow{%
name=foo,
parameters={%
\the\pgfarrowlength
},
setup code={%
% The different end values:
\pgfarrowssettipend{.25\pgfarrowlength}
\pgfarrowssetlineend{-.25\pgfarrowlength}
\pgfarrowssetvisualbackend{-.5\pgfarrowlength}
\pgfarrowssetbackend{-.75\pgfarrowlength}
% The hull
\pgfarrowshullpoint{.25\pgfarrowlength}{0pt}
\pgfarrowshullpoint{-.75\pgfarrowlength}{.5\pgfarrowlength}
\pgfarrowshullpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength}
% Saves: Only the length:
\pgfarrowssavethe\pgfarrowlength
},
drawing code={%
\pgfpathmoveto{\pgfqpoint{.25\pgfarrowlength}{0pt}}
\pgfpathlineto{\pgfqpoint{-.75\pgfarrowlength}{.5\pgfarrowlength}}
\pgfpathlineto{\pgfqpoint{-.5\pgfarrowlength}{0pt}}
\pgfpathlineto{\pgfqpoint{-.75\pgfarrowlength}{-.5\pgfarrowlength}}
\pgfpathclose
\pgfusepathqfill
},
defaults={%
length=4cm,
},
}
\begin{document}
\begin{tikzpicture}
\draw [-foo] (0,0) -- (8,0);
\end{tikzpicture}
\end{document}