这张图片中“尺寸太大”,为什么?

这张图片中“尺寸太大”,为什么?

当我运行以下代码时,出现“尺寸太大”错误:

\documentclass[tikz]{standalone}

\usetikzlibrary{decorations.markings}
\usetikzlibrary{hobby}

\definecolor{col1}{RGB}{24,127,127}
\definecolor{col2}{RGB}{240,240,240}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut]
    \clip (0,0) rectangle (1,1);
    \path[yshift=10,
    postaction={
        decorate,
        decoration={
            markings,
            mark=between positions 0 and \pgfdecoratedpathlength step .01cm with {
                \pgfmathsetmacro\myval{multiply(divide(
                    \pgfkeysvalueof{/pgf/decoration/mark info/distance from start}, \pgfdecoratedpathlength),100)};
                \pgfsetfillcolor{col2!\myval!col1};
                \pgfpathcircle{\pgfpointorigin}{1.5};
                \pgfusepath{fill};}
    }}] 
    ([closed].075,.2)..(.2,.4)..(.8,0)..(.925,.2)..(.8,.4)..(.2,0);
\end{tikzpicture}

\end{document}

我对这个问题进行了一些搜索,结果发现它既不是由长度>16384pt也不正确转移。当最后一行点的顺序改变时,错误有时会消失,但我不记得确切的顺序,而且我认为这与这个问题没有太大关系。

我该如何修复这个问题?

答案1

这是一个已知问题。在此网站的某处已经有人指出,使用库中的倒数可以避免大部分此类错误fpu。这也解决了您的问题。根据 Henri Menke 的要求,这里有一个适用于最新 pgf 版本 v3.1.6 的版本。您可以在第节中阅读有关此内容的内容50.2 处理“尺寸太大”错误pgfmanual v3.1.6。

\documentclass[tikz]{standalone}

\usetikzlibrary{decorations.markings}
\usetikzlibrary{hobby}
\usetikzlibrary{fpu}

\definecolor{col1}{RGB}{24,127,127}
\definecolor{col2}{RGB}{240,240,240}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut,/pgf/fpu/install only={reciprocal}]
    \clip (0,0) rectangle (1,1);
    \path[yshift=10,
    postaction={
        decorate,
        decoration={
            markings,
            mark=between positions 0 and \pgfdecoratedpathlength step .01cm with {
                \pgfmathsetmacro\myval{multiply(divide(
                    \pgfkeysvalueof{/pgf/decoration/mark info/distance from start}, \pgfdecoratedpathlength),100)};
                \pgfsetfillcolor{col2!\myval!col1};
                \pgfpathcircle{\pgfpointorigin}{1.5};
                \pgfusepath{fill};}
    }}] 
    ([closed].075,.2)..(.2,.4)..(.8,0)..(.925,.2)..(.8,.4)..(.2,0);
\end{tikzpicture}

\end{document}

如果你有较旧的 TeX 安装,请使用原始代码在将其添加到 pgf 之前,它出现在这里。

\documentclass[tikz]{standalone}

\usetikzlibrary{decorations.markings}
\usetikzlibrary{hobby}
\usetikzlibrary{fpu}
\makeatletter
\tikzset{use fpu reciprocal/.code={%
\def\pgfmathreciprocal@##1{%
    \begingroup
    \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}%
    \pgfmathparse{1/##1}%
    \pgfmath@smuggleone\pgfmathresult
    \endgroup
}}}%
\makeatother

\definecolor{col1}{RGB}{24,127,127}
\definecolor{col2}{RGB}{240,240,240}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut,use fpu reciprocal]
    \clip (0,0) rectangle (1,1);
    \path[yshift=10,
    postaction={
        decorate,
        decoration={
            markings,
            mark=between positions 0 and \pgfdecoratedpathlength step .01cm with {
                \pgfmathsetmacro\myval{multiply(divide(
                    \pgfkeysvalueof{/pgf/decoration/mark info/distance from start}, \pgfdecoratedpathlength),100)};
                \pgfsetfillcolor{col2!\myval!col1};
                \pgfpathcircle{\pgfpointorigin}{1.5};
                \pgfusepath{fill};}
    }}] 
    ([closed].075,.2)..(.2,.4)..(.8,0)..(.925,.2)..(.8,.4)..(.2,0);
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容