2

I am trying to draw a simple dependency graph using tikz and lualatex. I can't figure out why the result falls out of page... Here is the code and the result:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{trees}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\tikz[nodes={text depth=.2em, draw, fill=white}, rounded corners]
\graph[tree layout,  grow=down]  {
"Rule Manager"->{
    "Module Base"->{
        "Communicator"
        },
    "Log Data"->{
        "Communicator", 
        "ODB Oracle"
        }, 
    "Rule Manager Status"->{
        "Status Base", 
        "Rule Base"
        },
    "Rules"->{
        "Rule Base", 
        "Profiles"->{
            "Message"->{
                "Communicator", 
                "Interface SOAP", 
                "ODB Utils"
                },
            "Profile Base"
            }
        },
    "Threadpool"
    };
};
\end{tikzpicture}
\end{figure}
\end{document}

cropped image

Update: The image is not wider that the page width. Adding more nodes, pushes it further right:

Partial graph Completed graph

4
  • Because it is wider than the text width. There is just not enough space for those nodes on one line in that font size – daleif Oct 27 '18 at 10:19
  • @daleif It is not wider. – sorush-r Oct 27 '18 at 10:33
  • try to center the image with \begin{center}\begin{tikzpicture}....\end{tikzpicture}\end{center} .. maybe this action solve your problem – Athanasios Margaris Oct 27 '18 at 10:46
  • Have you tried \fbox{..} around the entire tikzpicture. Then we can see what latex thinks the size is. You can also ask tikzpicture to draw its own boundingbox, it might not be correct – daleif Oct 27 '18 at 10:46
2

Your \tikz command inside the tikzpicture environment is wrong. You should use either, but not both in combination. Add the options directly to the environment and you should be fine:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{trees}

\begin{document}
\begin{figure}
\begin{tikzpicture}[nodes={text depth=.2em, draw, fill=white}, rounded corners]
\graph[tree layout,  grow=down]  {
"Rule Manager"->{
    "Module Base"->{
        "Communicator"
        },
    "Log Data"->{
        "Communicator", 
        "ODB Oracle"
        }, 
    "Rule Manager Status"->{
        "Status Base", 
        "Rule Base"
        },
    "Rules"->{
        "Rule Base", 
        "Profiles"->{
            "Message"->{
                "Communicator", 
                "Interface SOAP", 
                "ODB Utils"
                },
            "Profile Base"
            }
        },
    "Threadpool"
    };
};
\end{tikzpicture}
\end{figure}
\end{document}
1
  • 1
    The \tikz{[...]} macro means essentially the same as \begin{tikzpicture}[...]\end{tikzpicture}. Nesting these command can lead to strange results. :) – Jasper Habicht Oct 27 '18 at 10:57

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.