# Centering and Reference Coordinates

Question 1 Can I define reference coordinates for x and y and then use these coordinates to adjust my figures inside a Tikz picture?

As an illustration, if I want to readjust all the rectangles in this picture to the left by 0.25, I will have to manually change the coordinates of each box or each \foreach instruction. Please advise a better solution for this. Can I define coordinates in the starting such as x = 0 and y = 0 then if I have to readjust the rectangles I just change x to -0.25 and y to -0.25.

Question 2 How can I center a tikzpicture in one column of the conference paper ?

MWE

\ifCLASSINFOpdf

\else
\fi
\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}

\hyphenation{op-tical net-works semi-conduc-tor}

\begin{document}

\title{Bare Demo of IEEEtran.cls for Conferences}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}
I wish you the best of success.

\begin{tikzpicture}
%Can I give a reference coordinate such as x = 0 and y = 0 and then draw figures
%based on that reference points through out the picture?

\draw [rounded corners](0,0) rectangle +(9,6);

\draw [rounded corners](0.15,0.5) node[above right, font =\small,align=center,text width = 2cm]{YYYY} rectangle +(2.25,5);

\foreach \x in {2.5}
\foreach \y in {0.5,3,4.5}
{
\draw [rounded corners] (\x,\y) rectangle +(6.35,1);

}

\foreach \x in {2.75,4.25,5.75,7.25}
\foreach \y in {0.9,3.4,4.9}
{
\draw [rounded corners] (\x, \y) node[above right, font=\scriptsize,text width = 1.8cm] {XXX} rectangle +(1.2,0.5);
}

\end{tikzpicture}

\end{document}


Thanks!

-
As for your first question, I would go with \begin{scope}[xshift=a,yshift=b] ...code... \end{scope}. This rigidly traslates the things you draw in the scope of a vector (a,b) from the origin of the tikzpicture. As for your second question, maybe it's better if you make another post. – Pier Paolo Jun 28 '14 at 21:43
Or calculate from the reference node. Agree that the second question should be a second question. It isn't even related to the first one ;). – cfr Jun 28 '14 at 22:15

You could use calc:

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning, calc}

\begin{document}

\begin{tikzpicture}
\coordinate (ref) at (0,0);
\draw [rounded corners](ref) rectangle +(9,6);
\draw [rounded corners]($(ref) + (0.15,0.5)$) node[above right, font =\small,align=center,text width = 2cm]{YYYY} rectangle +(2.25,5);
\foreach \x in {2.5}
\foreach \y in {0.5,3,4.5}
{
\draw [rounded corners] ($(ref) + (\x,\y)$) rectangle +(6.35,1);
}
\foreach \x in {2.75,4.25,5.75,7.25}
\foreach \y in {0.9,3.4,4.9}
{
\draw [rounded corners] ($(ref) + (\x, \y)$) node[above right, font=\scriptsize,text width = 1.8cm] {XXX} rectangle +(1.2,0.5);
}
\coordinate (ref) at (-0.25,-0.25);
\tikzset{color=red}
\draw [rounded corners](ref) rectangle +(9,6);

\draw [rounded corners]($(ref) + (0.15,0.5)$) node[above right, font =\small,align=center,text width = 2cm]{YYYY} rectangle +(2.25,5);
\foreach \x in {2.5}
\foreach \y in {0.5,3,4.5}
{
\draw [rounded corners] ($(ref) + (\x,\y)$) rectangle +(6.35,1);

}
\foreach \x in {2.75,4.25,5.75,7.25}
\foreach \y in {0.9,3.4,4.9}
{
\draw [rounded corners] ($(ref) + (\x, \y)$) node[above right, font=\scriptsize,text width = 1.8cm] {XXX} rectangle +(1.2,0.5);
}
\end{tikzpicture}

\end{document}


-
Thanks a lot for answering my question. This forum is really great and you guys rock !!! – New User Jun 29 '14 at 4:49