我正在画一棵家谱树,森林套餐其中大约有 50 个节点。当我尝试添加另一个节点时,我收到了“维度太大”的消息。
我读过了这和这,这让我了解了错误的起源,但对于我该如何解决它没有太大的帮助。
我在下面附上了文本;抱歉它太长了,但只有当我有这么多条目时才会出错。取消注释其中一个条目将导致错误。原始代码取自这问题,并可以找到所需的 Helvet Neue 字体这里。
\documentclass{standalone}
\usepackage{tabularx}
\usepackage{forest}
\usepackage{marvosym}
\usetikzlibrary{shapes.geometric}
\definecolor{color1}{HTML}{FFFFFF}
\definecolor{color2}{HTML}{FFFFFF}
\newcommand\Person[8]{%
{\textbf{#1}} \\
\begin{tabular}{cl}
b: & #2 \\
d: & #3 \\
& #4 \\
\end{tabular} \\
{\textbf{#5}} \\
\begin{tabular}{cl}
b: & #6 \\
d: & #7 \\
& #8 \\
\end{tabular}
}
\newcommand\SinglePerson[4]{%
{\textbf{#1}} \\
\begin{tabular}{cl}
b: & #2 \\
d: & #3 \\
& #4 \\
\end{tabular}
}
\begin{document}
\begin{forest}
delay={
for tree={
edge path={
\noexpand\path[\forestoption{edge}]
([xshift=-(6pt-1pt*level)].child anchor) to[out=180,in=0]
([xshift=(6pt-1pt*level)]!u.parent anchor)\forestoption{edge label};
},
if n=1
{fill=color1,shape=tape,tape bend bottom=none}
{if n'=1
{fill=color2,shape=tape,tape bend top=none}
{}
}
}
},
for tree={
line width=3pt,
inner sep=4pt,
draw=brown,
minimum size=1cm,
text width=4.5cm,
child anchor=west,
parent anchor=east,
grow=east,
l sep=8cm,
s sep=10pt,
draw,
anchor=west,
edge={line width=(18pt-3pt*level),line cap=rect,color=brown},
}
[\Person{L----}{}{}{}{}{}{}{}
[\Person{K----}{}{}{}{M----}{}{}{}
[\Person{P----}{}{}{}{A----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{P----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
[\Person{T----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
]
[\Person{L----}{}{}{}{E----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
%[\Person{E----}{}{}{}{}{}{}{}]
%[\Person{K----}{}{}{}{}{}{}{}]
%[\Person{S----}{}{}{}{}{}{}{}]
%[\Person{M----}{}{}{}{}{}{}{}]
%[\Person{A----}{}{}{}{}{}{}{}]
]
[\Person{K----}{}{}{}{}{}{}{}
%[\Person{A----}{}{}{}{}{}{}{}]
%[\Person{T----}{}{}{}{}{}{}{}]
[\Person{G----}{}{}{}{}{}{}{}]
]
[\Person{N----}{}{}{}{F----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
]
[\Person{C----}{}{}{K----}{}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{G----}{}{}{}{}{}{}{}]
]
[\Person{T----}{}{}{}{E----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
]
[\Person{E----}{}{}{}{A----}{}{}{} ]
[\Person{S----}{ABT 1896-1900}{}{}{C----}{1890}{}{}
[\Person{M----}{1918}{}{}{}{}{}{} ]
[\Person{P----}{13 Mar 1922}{}{}{}{}{}{} ]
[\Person{G---- \Gentsroom}{7 Nov 1925}{--}{}{A---- \Ladiesroom}{17 Dec 1923}{--}{},fill=color2
[\Person{C----}{20 Oct 1950}{}{}{S---- \Gentsroom}{}{}{}
[\Person{G---- \Gentsroom}{21 Nov 1980}{}{}{M----}{}{}{}
]
[\Person{G---- \Gentsroom}{2 Dec 1982}{}{}{M----}{}{}{}
]
]
[\Person{S---- \Gentsroom}{15 Jan 1953}{--}{}{K----}{}{--}{}
[\Person{T----}{}{--}{}{T---- \Gentsroom}{}{--}{}
[\SinglePerson{K----}{}{--}{}
]
]
[\SinglePerson{T---- \Gentsroom}{}{--}{}
]
[\SinglePerson{R----}{}{--}{}
]
][\Person{A----}{}{--}{}{D---- \Gentsroom}{}{--}{}
[\SinglePerson{S---- \Gentsroom}{}{--}{}
]
[\Person{G---- \Gentsroom}{}{--}{}{A----}{}{--}{}
[\SinglePerson{A----}{}{--}{}
]
[\SinglePerson{D---- \Gentsroom}{}{--}{}
]
]
[\SinglePerson{N----}{}{}{Tseri, Nicosia}
]
]
[\Person{M----}{13 Feb 1960}{--}{}{N---- \Gentsroom}{8 Jul 1958}{--}{}
[\Person{N----}{19 Nov 1987}{--}{}{C---- \Gentsroom}{}{--}{}
]
[\SinglePerson{D---- \Gentsroom}{4 Dec 1989}{--}{}
]
[\SinglePerson{C----}{22 May 1995}{--}{}
]
]
]
[\Person{M----}{1928}{}{}{}{}{}{} ]
]
[\Person{G----}{}{}{}{E----}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
]
[\Person{M----}{}{}{}{}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
]
]
]
\end{forest}
\end{document}
关于如何解决这个问题有什么想法吗?
答案1
问题不在于文档的最终大小(虽然很大,但低于 TeX 的大小\maxdimen
)。相反,forest 进行的一些内部计算暂时超出了这个最大尺寸。此外,即使您\usetikzlibrary{fpu}
认为它与浮点错误无关,问题仍然存在。
因此,我能找到的唯一解决方案是使用较小的字体并相应地重写一些边缘样式、距离等。这样,整个文档就会变小,因此不会触发 maxdimen 溢出。如果尺寸和距离选择得当,文档的外观不会改变,因为毕竟你使用的是standalone
包,生成的 pdf 可以再次重新缩放到所需的原始尺寸。
因此,例如,这是您的示例文档的结果(注释掉了额外的节点,以便文档可编译):
这是中心区域的细节:
默认情况下,文档使用 10pt 字体,因此以下代码将其更改为 5pt,并将样式中所有“硬编码”尺寸乘以 0.5:
\documentclass{standalone}
\usepackage{times}
\usepackage{tabularx}
\usepackage{forest}
\usepackage{marvosym}
\usetikzlibrary{shapes.geometric}
\definecolor{color1}{HTML}{FFFFFF}
\definecolor{color2}{HTML}{FFFFFF}
\newcommand\Person[8]{%
{\textbf{#1}} \\
\begin{tabular}{cl}
b: & #2 \\
d: & #3 \\
& #4 \\
\end{tabular} \\
{\textbf{#5}} \\
\begin{tabular}{cl}
b: & #6 \\
d: & #7 \\
& #8 \\
\end{tabular}
}
\newcommand\SinglePerson[4]{%
{\textbf{#1}} \\
\begin{tabular}{cl}
b: & #2 \\
d: & #3 \\
& #4 \\
\end{tabular}
}
\begin{document}\fontsize{5pt}{6pt}
\begin{forest}
delay={
for tree={
edge path={
\noexpand\path[\forestoption{edge}]
([xshift=-(3pt-.5pt*level)].child anchor) to[out=180,in=0]
([xshift=(3pt-.5pt*level)]!u.parent anchor)\forestoption{edge label};
},
if n=1
{fill=color1,shape=tape,tape bend bottom=none}
{if n'=1
{fill=color2,shape=tape,tape bend top=none}
{}
}
}
},
for tree={
line width=1.5pt,
inner sep=2pt,
draw=brown,
minimum size=.5cm,
text width=2.25cm,
child anchor=west,
parent anchor=east,
grow=east,
l sep=4cm,
s sep=5pt,
draw,
anchor=west,
edge={line width=(9pt-1.5pt*level),line cap=rect,color=brown},
}
[\Person{L----}{}{}{}{}{}{}{}
[\Person{K----}{}{}{}{M----}{}{}{}
[\Person{P----}{}{}{}{A----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{P----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
[\Person{T----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
]
[\Person{L----}{}{}{}{E----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
[\Person{S----}{}{}{}{}{}{}{}]
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{A----}{}{}{}{}{}{}{}]
]
[\Person{K----}{}{}{}{}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{T----}{}{}{}{}{}{}{}]
[\Person{G----}{}{}{}{}{}{}{}]
]
[\Person{N----}{}{}{}{F----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
]
[\Person{C----}{}{}{K----}{}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{G----}{}{}{}{}{}{}{}]
]
[\Person{T----}{}{}{}{E----}{}{}{}
[\Person{M----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
]
[\Person{E----}{}{}{}{A----}{}{}{} ]
[\Person{S----}{ABT 1896-1900}{}{}{C----}{1890}{}{}
[\Person{M----}{1918}{}{}{}{}{}{} ]
[\Person{P----}{13 Mar 1922}{}{}{}{}{}{} ]
[\Person{G---- \Gentsroom}{7 Nov 1925}{--}{}{A---- \Ladiesroom}{17 Dec 1923}{--}{},fill=color2
[\Person{C----}{20 Oct 1950}{}{}{S---- \Gentsroom}{}{}{}
[\Person{G---- \Gentsroom}{21 Nov 1980}{}{}{M----}{}{}{}
]
[\Person{G---- \Gentsroom}{2 Dec 1982}{}{}{M----}{}{}{}
]
]
[\Person{S---- \Gentsroom}{15 Jan 1953}{--}{}{K----}{}{--}{}
[\Person{T----}{}{--}{}{T---- \Gentsroom}{}{--}{}
[\SinglePerson{K----}{}{--}{}
]
]
[\SinglePerson{T---- \Gentsroom}{}{--}{}
]
[\SinglePerson{R----}{}{--}{}
]
][\Person{A----}{}{--}{}{D---- \Gentsroom}{}{--}{}
[\SinglePerson{S---- \Gentsroom}{}{--}{}
]
[\Person{G---- \Gentsroom}{}{--}{}{A----}{}{--}{}
[\SinglePerson{A----}{}{--}{}
]
[\SinglePerson{D---- \Gentsroom}{}{--}{}
]
]
[\SinglePerson{N----}{}{}{Tseri, Nicosia}
]
]
[\Person{M----}{13 Feb 1960}{--}{}{N---- \Gentsroom}{8 Jul 1958}{--}{}
[\Person{N----}{19 Nov 1987}{--}{}{C---- \Gentsroom}{}{--}{}
]
[\SinglePerson{D---- \Gentsroom}{4 Dec 1989}{--}{}
]
[\SinglePerson{C----}{22 May 1995}{--}{}
]
]
]
[\Person{M----}{1928}{}{}{}{}{}{} ]
]
[\Person{G----}{}{}{}{E----}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{K----}{}{}{}{}{}{}{}]
]
[\Person{M----}{}{}{}{}{}{}{}
[\Person{A----}{}{}{}{}{}{}{}]
[\Person{E----}{}{}{}{}{}{}{}]
]
]
]
\end{forest}
\end{document}
额外的节点被取消注释,因此包含在最终图像中,该图像可以无错误地进行编译并生成:
放大到中心部分,我们几乎看不到与第一个文档的区别:
笔记:我将主字体改为times
,因为这种字体在任何尺寸下都具有相同的形状。相反,Computer modern 对较小的字体使用不同的形状,而较小的字体在重新缩放后会变得更宽。