# Position a \graph in tikz

Shouldn't the following \graph {a} be positioned at node middle?

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{graphs}

\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (2,2);
\node (middle) at (1,1) {};
\path[draw] (middle) circle (.5);
\path[draw] (middle) graph {a};
\end{tikzpicture}
\end{document}


I read answer Position a \graph in a tikz picture (relatively) but it isn't working as advertised.

• Why do you need to use the graph operation here when you can use the nodes as well: path[draw] (middle) node {a} ? – AndréC Sep 12 '18 at 5:32
• graph {a} is just an example. Imagine a complex graph instead. – user170268 Sep 12 '18 at 12:55
• Okay, can you complete the question with this sample graph? – AndréC Sep 12 '18 at 12:57
• I don't think the complexity of the graph is the issue here, but why graph isn't being positioned at the coordinate. This graph could be also generate inside a long path, and I would expect it to be positioned at the last specified coordinate. – user170268 Sep 12 '18 at 13:08
• I believe I wrote a minimal example. The issue isn't how to write this graph using nodes, but positioning graphs using coordinates. – user170268 Sep 12 '18 at 13:15

Welcome to TeX.SE! You are right, at least I confirm your observation. One thing that does work, though, is to use shift, (Thanks to Andrew for pushing me. ;-)

• either in a scope (example b)
• or just in the path (example c).

(I tried various options, compiled with pdflatex or lualatex with and without \RequirePackage{luatex85}, the result on my machine was always the same: the graph sat at the origin. Most likely I am missing something, otherwise that would be the first time I would see an answer by Torbjørn that is not 100% accurate, so I guess I am doing something stupid.)

\documentclass{article}
%\RequirePackage{luatex85}
\usepackage{tikz}
\usetikzlibrary{graphs}

\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (2,2);
\coordinate (middle) at (1,1) {};
\path[draw] (middle) circle (.5);
\path[draw] (middle) graph {a};
\begin{scope}[shift={(middle)}]
\path[draw] graph {b};
\end{scope}
\path[shift={(2,2)}] graph {c};
\end{tikzpicture}
\end{document}


• Notice that you can avoid the use of scope entirely by using \path[shift=(middle)] graph {a};. This is implicit in your answer, with the graph c, but it's kind of hidden since your answer suggests that you need the scope environment. In fact, I posted this as a follow-up answer, which I just deleted, because I didn't notice this in your post. – Andrew Sep 12 '18 at 4:05
• @Andrew Yes, this is how my lowest example c works. I wrote ", or just use shift" to indicate that option. I will be happy to make it clearer. I am actually concerned that I am doing something stupid. so far I have never seen any answer by Torbjørn that was not 100% accurate, so I am not sure if my answer will stay. – user121799 Sep 12 '18 at 4:12
• Per my manual reading, I think the positioning of graph inside a path should work. This might be a bug. – user170268 Sep 12 '18 at 13:26