# TikZ graph positioning

I am trying to use TikZ to include a simple graph in a short document, but I can't get to position the image properly. Sorry if it is a bit stupid, but this is the first time I am doing something like this.

Here is the code:

\documentclass[12pt]{article}
\usepackage[czech]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usepackage{amsmath}
\tikzstyle{vertex}=[auto=left,circle,fill=black!25,minimum size=20pt,inner sep=0pt]

\begin{document}
\raggedright
Jméno: Alexandar Živkovič\\
UČO: 325003\\
\bigskip
\begin{enumerate}
\item %1)
\pagebreak
\item %2)
Graf:\bigskip
\begin{tikzpicture}
\node[vertex] (n1) at (3,3)  {1};
\node[vertex] (n2) at (6,3)  {2};
\node[vertex] (n3) at (7, 1) {3};
\node[vertex] (n4) at (6, -1) {4};
\node[vertex] (n5) at (3, -1) {5};
\node[vertex] (n6) at (2, 1) {6};

\foreach \from/\to in {n1/n2,n1/n3,n1/n5,n2/n1,n2/n3,n2/n4,n2/n5,n2/n6,n3/n1,n3/n2,n3/n5,n3/n6,n4/n2,n4/n5,n4/n6,n5/n1,n5/n2,n5/n3,n5/n4,n5/n6,n6/n2,n6/n3,n6/n4,n6/n5}
\draw (\from) -- (\to);

\end{tikzpicture}

Počet sledů z vrcholu $1$ do vrcholu $6$ délky $5$:\smallskip

\item %3)

\end{enumerate}
\end{document}


Any help is welcome.

-
How exactly do you want to position it? – Count Zero Nov 1 '11 at 21:25
Between "Graf:\bigskip" and "Počet sledů z vrcholu $1$ do vrcholu $6$ délky $5$:\smallskip", preferably to the middle of the page. There would be some matrixes after that. – Alexandar Živkovič Nov 1 '11 at 21:27
– Peter Grill Nov 1 '11 at 21:37

Simply add a \par after Graf:. bigksip only takes effect at the next paragraph. With

Graf:\par\bigskip


we obtain the desired result:

As @Frédéric suggested \begin{center}...\end{center} around the tikzpicture will work. However, this will have additional vertical space as per Should I use center or centering for figures? and When should we use \begin{center} instead of \centering?. Alternatively, you could use

\begin{figure}[h]\centering
\begin{tikzpicture}
...
\end{tikzpicture}
\end{figure}

-
Thanks! Can you please also tell me how to align it to the center of the page? – Alexandar Živkovič Nov 1 '11 at 21:39

A simple and effective solution is to wrap the picture within \begin{center}and \end{center} . This will place it in the center, on the next line.

\documentclass[12pt]{article}
\usepackage[czech]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\usepackage{amsmath}
\tikzstyle{vertex}=[auto=left,circle,fill=black!25,minimum size=20pt,inner sep=0pt]

\begin{document}
\raggedright
Jméno: Alexandar Živkovič\\
UČO: 325003\\
\bigskip
\begin{enumerate}
\item %1)
\pagebreak
\item %2)
Graf:
\begin{center}
\begin{tikzpicture}
\node[vertex] (n1) at (3,3)  {1};
\node[vertex] (n2) at (6,3)  {2};
\node[vertex] (n3) at (7, 1) {3};
\node[vertex] (n4) at (6, -1) {4};
\node[vertex] (n5) at (3, -1) {5};
\node[vertex] (n6) at (2, 1) {6};

\foreach \from/\to in {n1/n2,n1/n3,n1/n5,n2/n1,n2/n3,n2/n4,n2/n5,n2/n6,n3/n1,n3/n2,n3/n5,n3/n6,n4/n2,n4/n5,n4/n6,n5/n1,n5/n2,n5/n3,n5/n4,n5/n6,n6/n2,n6/n3,n6/n4,n6/n5}
\draw (\from) -- (\to);

\end{tikzpicture}
\end{center}

Počet sledů z vrcholu $1$ do vrcholu $6$ délky $5$:\smallskip

\item %3)

\end{enumerate}
\end{document}

-
Thanks for that too! :) – Alexandar Živkovič Nov 1 '11 at 21:42
@AlexandarŽivkovič Thank by upvoting. ;-) – lockstep Nov 1 '11 at 21:47