2

I try to draw a background on a tree layout graph but whatever the method I use, lualatex throws this error: Dimension too large.

I test show background rectangle, fit, local boonding box with scope environnement methods but i got the same error.

I suspect that this methods are called before the graphs are drawn. But I don't know how to do to draw a background on it.

\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}

I use pgf 3.0.0 with lualatex.

3

This is not an answer because I don't know what happens. But in case you could use it, a possible workaround consists in drawing a transparent node around your figure with remember picture help.

\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}

enter image description here

And a second workaround could be to use a tcbox (from tcolorbox package)

\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}

enter image description here

2

You may use some scopes to work around this feature/bug(?) of graphdrawing library:

\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}
  • Yes. I didn't think to scope. thanks – Justin Feb 13 '15 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.