# Tikz, centering object and correcting an arrow in flowchart

i placed the circle with the word Start in the center of picture using positioning library:

\node[start] (start)  {start};
% row 2
\node[block] (measurement) [below of=start] {Add new measurement, \\ $y_k$ to buffer};
\node[left=6cm of measurement] (level three) {};


my question is if it possible to place Start circle in the center of the page in a more accurate way instead of guessing where the center is? (e.g. 0.5\textwidth)

my second question, i would like to correct line from Number of regression to regression solution false and .... It should pass above the diamond and connect the diamond from the east side like the 3 other arrows.

EDIT

A solution to the array (vector) problem:

 \path [line,rounded corners] (i > 0 1.south) |- node[above right,midway] {$i=0$} ($(if 2.east) + (0.5,2)$) -- ($(if 2.east) + (0.5,0)$) -- (if 2.east);


simply creating an addition virtual point around if 2 position, using calc library.

A solution for centering the Start circle i still havent found.

END EDIT here is an example code i used:

  \documentclass[]{scrbook}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\selectlanguage{english}

\usepackage[]{amsmath,amssymb,amsthm}
\usepackage[landscape,a4paper,left=30mm,right=20mm,top=20mm, bottom=20mm]{geometry}
\usepackage{mathtools}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,matrix,decorations.pathreplacing, shapes. geometric,calc,positioning}

\begin{document}
\tikzset{decision/.style={diamond, aspect=2, draw, fill=blue!20, text badly centered, inner sep=0pt,align=center}}

\tikzset{block/.style={rectangle, draw, fill=blue!20, text centered, rounded corners, align=center}}
\tikzset{line/.style={draw, very thick, color=black!50, -latex'}}
\tikzset{start/.style={shape=circle,draw,minimum size=1.2cm, draw=blue!80, fill=blue!20, text centered, align=center}}
\tikzset{datashape/.style={ trapezium, draw, trapezium left angle=60, trapezium right angle=-60}}

\begin{tikzpicture}[node distance=1.5cm, auto, >=stealth, every node/.style={ auto, font=\footnotesize, anchor=center, >=stealth}]

% row 1
\node[start] (start)  {start};
% row 2
\node[block] (measurement) [below of=start] {Add new measurement, \\ $y_k$ to
buffer};
\node[left=6cm of measurement] (level three) {};
% row 3
\node[decision] (reg_status) [below left of=level three, node distance=3cm] %
{Regression\\status};%
\node[block] (update_goodness) [right of=reg_status,node distance=4cm] %
{update\\Goodness of Fit\\$\chi_\mathrm{red}^2$};%
\node [decision] (line_pass) [right of=update_goodness,node distance=4.5cm]%
{Is \\ $\left|\delta \right| < \left( 3.5\cdot \sigma_{\varepsilon} + % \sigma_{\hat{\beta}_k}\right)$\\ and \\ $\chi_\mathrm{red}^2 < 1.6$};
\node [block] (update_beta_k) [right of=line_pass,node distance=5.5cm] %
{Update estimated values\\$\chi_\mathrm{red}^2$, $\hat{\beta}_k^i$ and %
$\operatorname{Cov}$};
% row 4
\node [block] (Reg_False) [below of=line_pass, node distance=2.3cm]%
{Set regression status\\equal False};
% row 5
\node [block] (create_replica) [right of=Reg_False,node distance=4cm]
{Create a replica of\\current regression solution\\$i \to i+1$};
\node [block] (Update_replica) [right of=create_replica,node distance=4cm]
{Clean buffer,\\Update:\\$\hat{\beta}_k^{i+1}$, $\operatorname{Cov}_k^{i+1}$ and %
$\chi_\mathrm{red}^2$};
% row 6
\node [decision] (i > 0 1) [below of=reg_status,node distance=4cm]
{Number\\of\\regression};
\node [block]    (update estimate) [right of=i > 0 1,node distance=5cm]
{Update estimated values \\ $^{i+1}\chi_\mathrm{red}^2$, $\hat{\beta}_k^{i+1}$ and %
$\operatorname{Cov}_k^{i+1}$};
% row 7
\node [decision] (if 2) [below of=Update_replica,node distance=5cm]
{Is \\ regression solution false \\ and \\ sufficent number of measurements};

\begin{scope}[every path/.style=line]
\path [line] (start)-- (measurement);
\path [line,rounded corners] (measurement) -| (reg_status);
\path [line] (reg_status) -- node[above,midway] {True} (update_goodness);
\path [line] (reg_status) -- node[near start,right] {False} (i > 0 1);
\path [line] (update_goodness) -- (line_pass);
\path [line] (line_pass) -- node[above,midway] {Yes} (update_beta_k);
\path [line] (line_pass) -- node[right,midway] {No}  (Reg_False);
\path [line] (Reg_False) -- (create_replica);
\path [line] (create_replica) -- (Update_replica);
\path [line] (i > 0 1) -- node[above,midway] {$i>0$} (update estimate);
\path [line,rounded corners] (update_beta_k.east) -| ($(if 2.east) + (0.5,0)$) |- (if 2.east);
\path [line,rounded corners] (Update_replica.east) -| ($(if 2.east) + (0.5,0)$) |- (if 2.east);
\path [line,rounded corners] (update estimate.east) -| ($(if 2.east) + (0.5,0)$) |- (if 2.east);
\path [line,rounded corners] (i > 0 1.south) |- node[above right,near start]%
{$i=0$} ($(if 2.east) + (0.5,0)$) |- (if 2.east);
\end{scope}
\end{tikzpicture}
\end{document}


Here is a picture of what the above TeX code return

-
Have a look on the solutions for Centering a TikZ picture around an area. –  Martin Scharrer May 19 '11 at 13:17
The problem of centring the start circle is that considered in the question that Martin links to above. You should try the techniques given there. –  Loop Space May 20 '11 at 9:36

You can place tikz pictures exactly where you want on a page with the current page node, an absolute position with respect to a page. This is done with the following code

\documentclass{scrbook}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]

\draw[red] (current page.center) circle (1cm);

\end{tikzpicture}
\end{document}


If you want to place something exactly within a picture you may use the current bounding box node. With this approach, to center something horizontally on a page, you might consider

\documentclass{scrbook}

\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}[]

\draw (0,0) rectangle (2,3);
\draw (1,2) rectangle (4,4);

\draw[red] (current bounding box.north) circle (1cm);

\end{tikzpicture}
\end{center}
\end{document}

-
In your second example, the circle is placed in the middle of the page but has to be drawn after the rest of the picture. In particular, other pieces of the picture can't be drawn depending on its position (as they might adjust the bounding box and so move the circle out of the centre). –  Loop Space May 20 '11 at 9:38