使用 MiKTeX 和 TeX Live 2022 时,TikZ DECORATE 错误地失败并显示“尺寸太大”。

使用 MiKTeX 和 TeX Live 2022 时,TikZ DECORATE 错误地失败并显示“尺寸太大”。

这里我记录了一个让我困惑的问题。我正在使用 TiZ 装饰可将文本放置在平缓倾斜的曲线上。有足够的空间放置文本,我只使用几个坐标,因为装饰文本不需要高精度。

99.9% 的时间里它都能完美运行。现在我遇到了一个! Dimension too large.错误,我认为这个错误是错误的,我会解释原因。这个错误是纯粹依赖数据因此我主张对此进行调查。我在这里列出了几个.tex文件:那些运行正常且没有错误的文件和那些失败的文件。Henri Menke 曾在这里评论过

装饰和平滑的路径效果不佳。

不管那是什么意思。我坚持我所做的事情应该 100% 有效……这意味着我看不出 TiZ 不应该能够像我的情况一样将一行简单的文本定位在平缓的曲线上(从最终用户的角度来看)。

我创建了 PDF 图表,并在 Windows 10 上使用最新的 MiKTeX 23.10.12 和 Ubuntu Desktop 22.04.3 LTS 以及基于 AMD 的相同硬件(得益于双启动系统)上的 Tex Live 2022 进行了测试。我还在一台配备 i7-6700HQ CPU 的旧 Windows 10 笔记本电脑上进行了测试。因此,我相信您将能够使用.tex我下面附加的文件重现此错误。

北纬 62.0° 的图表失效。如果数据略有改变,61.9°N 和 62.1°N 的图表完美无缺。此外,如果我使用 4 位小数而不是 3 位,那么 62.0°N 的图表也同样有效!62.0°N 的装饰代码部分失败如下(从 .tex 文件的第 1022 行开始):

% decorate PM dusk with text aligned left
\path [decorate,decoration={text along path,raise=-2.4ex,text align={left indent=1.112cm},text={|\PMstyle|D U S K~~~at latitude 62.0{°}N~~~(Sun 6{°} below horizon)}}]
plot[smooth,tension=0.5] coordinates{
(0.000, 10.982) (0.347, 11.067) (0.695, 11.170) (1.042, 11.287) (1.390, 11.417) 
(1.738, 11.555) (2.085, 11.699) (2.433, 11.848) (2.780, 11.999) (3.127, 12.152) 
(3.475, 12.306) (3.822, 12.461) (4.170, 12.616) (4.518, 12.771) (4.865, 12.927) 
(5.212, 13.085) (5.560, 13.244) (5.907, 13.406) (6.255, 13.572) (6.602, 13.741) 
(6.950, 13.915) (7.297, 14.096) (7.645, 14.283) (7.992, 14.478) (8.340, 14.683) 
(8.688, 14.898) (9.035, 15.126) (9.382, 15.371) (9.730, 15.641) (10.077, 15.958) 
(10.425, 16.477) };

61.9°N 的装饰代码完美运行:

% decorate PM dusk with text aligned left
\path [decorate,decoration={text along path,raise=-2.4ex,text align={left indent=1.112cm},text={|\PMstyle|D U S K~~~at latitude 61.9{°}N~~~(Sun 6{°} below horizon)}}]
plot[smooth,tension=0.5] coordinates{
(0.000, 10.990) (0.347, 11.075) (0.695, 11.177) (1.042, 11.294) (1.390, 11.423) 
(1.738, 11.560) (2.085, 11.704) (2.433, 11.852) (2.780, 12.002) (3.127, 12.155) 
(3.475, 12.308) (3.822, 12.462) (4.170, 12.616) (4.518, 12.771) (4.865, 12.927) 
(5.212, 13.083) (5.560, 13.242) (5.907, 13.403) (6.255, 13.568) (6.602, 13.736) 
(6.950, 13.910) (7.297, 14.089) (7.645, 14.275) (7.992, 14.469) (8.340, 14.671) 
(8.688, 14.884) (9.035, 15.109) (9.382, 15.351) (9.730, 15.615) (10.077, 15.919) 
(10.425, 16.358) (10.494, 16.557) };

62.1°N 的装饰代码运行完美:

% decorate PM dusk with text aligned left
\path [decorate,decoration={text along path,raise=-2.4ex,text align={left indent=1.112cm},text={|\PMstyle|D U S K~~~at latitude 62.1{°}N~~~(Sun 6{°} below horizon)}}]
plot[smooth,tension=0.5] coordinates{
(0.000, 10.973) (0.347, 11.059) (0.695, 11.162) (1.042, 11.280) (1.390, 11.410) 
(1.738, 11.549) (2.085, 11.694) (2.433, 11.843) (2.780, 11.996) (3.127, 12.149) 
(3.475, 12.304) (3.822, 12.459) (4.170, 12.615) (4.518, 12.771) (4.865, 12.928) 
(5.212, 13.086) (5.560, 13.247) (5.907, 13.409) (6.255, 13.576) (6.602, 13.746) 
(6.950, 13.921) (7.297, 14.103) (7.645, 14.291) (7.992, 14.488) (8.340, 14.694) 
(8.688, 14.911) (9.035, 15.142) (9.382, 15.392) (9.730, 15.668) (10.077, 16.000) 
(10.355, 16.415) };

原装饰代码为62.0°N正常工作如果我对坐标使用四位小数:

% decorate PM dusk with text aligned left
\path [decorate,decoration={text along path,raise=-2.4ex,text align={left indent=1.112cm},text={|\PMstyle|D U S K~~~at latitude 62.0{°}N~~~(Sun 6{°} below horizon)}}]
plot[smooth,tension=0.5] coordinates{
(0.0000, 10.9816) (0.3475, 11.0669) (0.6950, 11.1698) (1.0425, 11.2874) (1.3900, 11.4165) 
(1.7375, 11.5546) (2.0850, 11.6990) (2.4325, 11.8476) (2.7800, 11.9990) (3.1275, 12.1519) 
(3.4750, 12.3061) (3.8225, 12.4608) (4.1700, 12.6158) (4.5175, 12.7712) (4.8650, 12.9272) 
(5.2125, 13.0847) (5.5600, 13.2442) (5.9075, 13.4064) (6.2550, 13.5718) (6.6025, 13.7411) 
(6.9500, 13.9154) (7.2975, 14.0958) (7.6450, 14.2830) (7.9925, 14.4784) (8.3400, 14.6828) 
(8.6875, 14.8979) (9.0350, 15.1259) (9.3825, 15.3709) (9.7300, 15.6410) (10.0775, 15.9582) 
(10.4250, 16.4775) };

由于某种原因,我无法将四个测试用例作为 ZIP 文件上传。此报告的重点是,有人可以验证错误并确认它与数据有关。请联系我,以便我可以将这些.tex文件传递给某人以证明我遇到的问题。

更新 #1:

我已在 GitHub 上发布了此问题,并可以上传上述.tex文件:

https://github.com/pgf-tikz/pgf/issues/1297

再次...这是初始步骤,我请求专家能够重现我的问题;同意该错误是不正确的,并且需要进一步调查并最终修复。

更新 #2:

问候 David Carlisle!问候 Gott Ulrike Fischer!感谢 Qrrbrbirbel。感谢您过去给予我的所有支持。抱歉发布外部链接……这不是故意的,但我忘了您不能在此处上传任何内容。

我设法将其缩减为 MWE(最小工作示例)以及 MnWE(最小非工作示例)一种解决方法(我完全不明白)。

MWE 在这里(并使用 4 位小数作为坐标)任何不同的坐标也可以正常工作):

\pdfminorversion=4
\documentclass[10pt, a4paper,landscape]{report}
\usepackage[utf8]{inputenc}
\usepackage[top=5mm, bottom=5mm, left=2mm, right=2mm]{geometry}
\usepackage{tikz}               % for \draw  (load after 'graphicx')
\usetikzlibrary{decorations.text}   % to print text on a curve
\DeclareUnicodeCharacter{00B0}{\ensuremath{{}^\circ}}
\begin{document}
  \newcommand*{\PMstyle}{\sffamily\normalsize\color{blue}}
\begin{tikzpicture}
% decorate PM dusk with text aligned left
\path [decorate,decoration={text along path,raise=-2.4ex,text align={left indent=1.112cm},text={|\PMstyle|D U S K~~~at latitude 62.0{°}N~~~(Sun 6{°} below horizon)}}]
plot[smooth,tension=0.5] coordinates{
(0.0000, 10.9816) (0.3475, 11.0669) (0.6950, 11.1698) (1.0425, 11.2874) (1.3900, 11.4165) 
(1.7375, 11.5546) (2.0850, 11.6990) (2.4325, 11.8476) (2.7800, 11.9990) (3.1275, 12.1519) 
(3.4750, 12.3061) (3.8225, 12.4608) (4.1700, 12.6158) (4.5175, 12.7712) (4.8650, 12.9272) 
(5.2125, 13.0847) (5.5600, 13.2442) (5.9075, 13.4064) (6.2550, 13.5718) (6.6025, 13.7411) 
(6.9500, 13.9154) (7.2975, 14.0958) (7.6450, 14.2830) (7.9925, 14.4784) (8.3400, 14.6828) 
(8.6875, 14.8979) (9.0350, 15.1259) (9.3825, 15.3709) (9.7300, 15.6410) (10.0775, 15.9582) 
(10.4250, 16.4775) };
\end{tikzpicture}
\end{document}

失败的 MnWE 在此处(并使用了 3 位小数的坐标,这最初导致我! Dimension too large.从 Ti 中得到错误Z 修饰路径期间pdflatex <filename>.tex):

\pdfminorversion=4
\documentclass[10pt, a4paper,landscape]{report}
\usepackage[utf8]{inputenc}
\usepackage[top=5mm, bottom=5mm, left=2mm, right=2mm]{geometry}
\usepackage{tikz}               % for \draw  (load after 'graphicx')
\usetikzlibrary{decorations.text}   % to print text on a curve
\DeclareUnicodeCharacter{00B0}{\ensuremath{{}^\circ}}
\begin{document}
  \newcommand*{\PMstyle}{\sffamily\normalsize\color{blue}}
\begin{tikzpicture}
% decorate PM dusk with text aligned left
\path [decorate,decoration={text along path,raise=-2.4ex,text align={left indent=1.112cm},text={|\PMstyle|D U S K~~~at latitude 62.0{°}N~~~(Sun 6{°} below horizon)}}]
plot[smooth,tension=0.5] coordinates{
(0.000, 10.982) (0.347, 11.067) (0.695, 11.170) (1.042, 11.287) (1.390, 11.417) 
(1.738, 11.555) (2.085, 11.699) (2.433, 11.848) (2.780, 11.999) (3.127, 12.152) 
(3.475, 12.306) (3.822, 12.461) (4.170, 12.616) (4.518, 12.771) (4.865, 12.927) 
(5.212, 13.085) (5.560, 13.244) (5.907, 13.406) (6.255, 13.572) (6.602, 13.741) 
(6.950, 13.915) (7.297, 14.096) (7.645, 14.283) (7.992, 14.478) (8.340, 14.683) 
(8.688, 14.898) (9.035, 15.126) (9.382, 15.371) (9.730, 15.641) (10.077, 15.958) 
(10.425, 16.477) };
\end{tikzpicture}
\end{document}

当我在研究 MnWE 时,我发现如果注释掉以下行 [更正后的文本],错误就会消失!但是度数符号变小了,因为它不再是一个凸起的圆圈,也就是说,在图表上更难读。

\DeclareUnicodeCharacter{00B0}{\ensuremath{{}^\circ}}

我相信这会给你一些启发,但让我困惑的是,一个合理的DeclareUnicodeCharacter声明竟然会导致! Dimension too large.错误,这对最终用户来说是最令人困惑的。我很想听听你的反馈......不过我希望这是一个可以修复的错误。

为了符合要求,我还将在 Github 上发布 MnWE 和解决方法。

解决方法 v2:由于在我的用例中将该行完全注释掉是不切实际的,因此更好的解决方法是在装饰路径中用特定情况(2020 年火星,北纬 62°)\DeclareUnicodeCharacter{00B0}{\ensuremath{{}^\circ}}替换,其中错误消息导致 PDF 创建崩溃。{°}{\textdegree}! Dimension too large.

相关内容