以下代码块包含一个最小工作示例。它显示一组 2 行 3 列的圆圈,顶部有一个箭头(见下图中的结果)。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}
% Row no. 1
\coordinate(center11) at (0,0);
\draw[clockwise, red] (center11) circle (0.1);
\coordinate[right = 1 of center11] (center12);
\draw[clockwise, red] (center12) circle (0.1);
\coordinate[right = 1 of center12] (center13);
\draw[clockwise, red] (center13) circle (0.1);
% Row no. 2
\coordinate[below = 1 of center11] (center21);
\draw[clockwise, blue] (center21) circle (0.1);
\coordinate[below = 1 of center12] (center22);
\draw[clockwise, blue] (center22) circle (0.1);
\coordinate[below = 1 of center13] (center23);
\draw[clockwise, blue] (center23) circle (0.1);
\end{tikzpicture}
\end{document}
我现在尝试显示一组 3 行 3 列的相同圆圈,但Dimension too large.
在尝试绘制第三行中的第一个节点时出现错误。下面的第一个代码块显示了我的尝试。下面的第二个代码块显示了错误的最后几行。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}
% Row no. 1
\coordinate(center11) at (0,0);
\draw[clockwise, red] (center11) circle (0.1);
\coordinate[right = 1 of center11] (center12);
\draw[clockwise, red] (center12) circle (0.1);
\coordinate[right = 1 of center12] (center13);
\draw[clockwise, red] (center13) circle (0.1);
% Row no. 2
\coordinate[below = 1 of center11] (center21);
\draw[clockwise, blue] (center21) circle (0.1);
\coordinate[below = 1 of center12] (center22);
\draw[clockwise, blue] (center22) circle (0.1);
\coordinate[below = 1 of center13] (center23);
\draw[clockwise, blue] (center23) circle (0.1);
% Row no. 3
\coordinate[below = 1 of center21] (center31);
\draw[clockwise, red] (center31) circle (0.1);
\end{tikzpicture}
\end{document}
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/latex/l3backend/l3backend-pdftex.def)
No file main.aux.
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Dimension too large.
<to be read again>
\relax
l.43 ...w[clockwise, red] (center31) circle (0.1);
?
如何解决这个问题呢?
答案1
1mm
您可以通过替换来避免错误0.1
,它们是等效的。
请注意,您的代码相当于
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}
\foreach \i/\k [count=\n] in {0/red,1/blue,2/red}
\foreach \j [count=\m] in {0,1,2}
\draw [clockwise,\k] (\j cm,\i cm) coordinate (center\n\m) circle (1mm);
\end{tikzpicture}
\end{document}
您可能还会考虑pic
为此使用,但除非您需要绘制很多,否则这可能会不必要地复杂。
答案2
加载fpu
tikzlibrary 并使用如下所示的选项[/pgf/fpu/install only = {reciprocal}]
。此解决方案在 PGF 手册的第 50.2 节“处理“尺寸过大”错误”中建议。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{fpu}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}[/pgf/fpu/install only = {reciprocal}]
% Row no. 1
\coordinate(center11) at (0,0);
\draw[clockwise, red] (center11) circle (0.1);
\coordinate[right = 1 of center11] (center12);
\draw[clockwise, red] (center12) circle (0.1);
\coordinate[right = 1 of center12] (center13);
\draw[clockwise, red] (center13) circle (0.1);
% Row no. 2
\coordinate[below = 1 of center11] (center21);
\draw[clockwise, blue] (center21) circle (0.1);
\coordinate[below = 1 of center12] (center22);
\draw[clockwise, blue] (center22) circle (0.1);
\coordinate[below = 1 of center13] (center23);
\draw[clockwise, blue] (center23) circle (0.1);
% Row no. 3
\coordinate[below = 1 of center21] (center31);
\draw[clockwise, red] (center31) circle (0.1);
\end{tikzpicture}
\end{document}
产生相同错误的最小示例
我找到了一个产生相同错误的更简单示例。以下代码块包含一个编译时没有错误的文档:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}
\coordinate(center1) at (0, 0);
\draw[clockwise] (center1) circle (1mm);
\coordinate(center2) at (0, 1);
\draw[clockwise] (center2) circle (1mm);
\end{tikzpicture}
\end{document}
以下代码块向上面显示的示例添加了一个附加节点,并产生了相同的错误。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, fpu}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}[/pgf/fpu/install only = {reciprocal}]
\coordinate(center1) at (0, 0);
\draw[clockwise] (center1) circle (1mm);
\coordinate(center2) at (0, 1);
\draw[clockwise] (center2) circle (1mm);
\coordinate(center2) at (0, 2);
\draw[clockwise] (center2) circle (1mm);
\end{tikzpicture}
\end{document}
这个问题可以用同样的方法解决:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, fpu}
\tikzset{
clockwise/.style={
decoration = {
markings,
mark = at position 0.25 with {\arrow{<}},
},
postaction = {decorate}
}
}
\begin{document}
\begin{tikzpicture}[/pgf/fpu/install only = {reciprocal}]
\coordinate(center1) at (0, 0);
\draw[clockwise] (center1) circle (1mm);
\coordinate(center2) at (0, 1);
\draw[clockwise] (center2) circle (1mm);
\coordinate(center2) at (0, 2);
\draw[clockwise] (center2) circle (1mm);
\end{tikzpicture}
\end{document}