# Why my tikz image falls out of page margin?

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"
}
},
};
};
\end{tikzpicture}
\end{figure}
\end{document}


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

• 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

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"
}
},

• 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