我尝试在树形布局图上绘制背景,但无论我使用何种方法,lualatex 都会引发此错误:尺寸太大。
我测试显示背景矩形,合身,本地绑定盒使用范围环境方法,但我得到了同样的错误。
我怀疑这个方法是在绘制图形之前调用的。但我不知道如何在其上绘制背景。
\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[local bounding box=bb, tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
\node [label=center:Internet] (internet) {};
\node [label=center:SDSL] (sdsl) {};
\node [label=center:CORE] (core) {};
\node [label=center:Site 1, site] (site01) {};
\graph [use existing nodes] {
core -- sdsl;
core -- internet;
sdsl -- site01
};
%\node[fill=black!20,fit=(internet) (core) (sdsl) (site01)] {};
\node[fill=black!20,fit=(bb)] {};
\end{tikzpicture}
\end{document}
我使用带有 lualatex 的 pgf 3.0.0。
答案1
这不是一个答案,因为我不知道会发生什么。但如果您可以使用它,一个可能的解决方法是在remember picture
帮助下在您的图形周围绘制一个透明节点。
\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[remember picture, local bounding box=bb, tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
\node [label=center:Internet] (internet) {};
\node [label=center:SDSL] (sdsl) {};
\node [label=center:CORE] (core) {};
\node [label=center:Site 1, site] (site01) {};
\graph [use existing nodes] {
core -- sdsl;
core -- internet;
sdsl -- site01
};
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
\node[fill=black!20,fit=(internet) (site01), opacity=.3] {};
\end{tikzpicture}
\end{document}
第二种解决方法是使用tcbox
(来自tcolorbox
包)
\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}
\usepackage{tcolorbox}
\begin{document}
\tcbox{
\begin{tikzpicture}[tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
\node [label=center:Internet] (internet) {};
\node [label=center:SDSL] (sdsl) {};
\node [label=center:CORE] (core) {};
\node [label=center:Site 1, site] (site01) {};
\graph [use existing nodes] {
core -- sdsl;
core -- internet;
sdsl -- site01
};
\end{tikzpicture}
}
\end{document}
答案2
您可以使用一些范围来解决该graphdrawing
库的功能/错误(?):
\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}
\begin{scope}[local bounding box=bb,tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
\node [label=center:Internet] (internet) {};
\node [label=center:SDSL] (sdsl) {};
\node [label=center:CORE] (core) {};
\node [label=center:Site 1, site] (site01) {};
\graph [use existing nodes] {
core -- sdsl;
core -- internet;
sdsl -- site01
};
\end{scope}
\begin{scope}[on background layer]
\node[fill=black!20,fit=(bb)] {};
\end{scope}
\end{tikzpicture}
\end{document}