# [Tex/LaTex] Using scope to move objects using the same coordinate system as the objects themselves

scopingtikz-pgf

Summary of answers

The question has been answered by TorbjørnT. with a comment. If using scope with xshift it is necessary to specify the unit as cm. This is also working if the entire picture is later scaled. Thanks! The included code is now working as it should. –

The solution provided by JLDiaz works just as well and does not requiere any units! Here to image is moved using shift={(x,z)} (make sure to get all the brackets).

A third possible solution has been proposed by Ignasi, again as a comment to the question. To me this approach using pic might be especially useful if elements need to be repeated a few times in the same image.

Thanks for all the good input!

The question

I am trying to make an illustration for a latex document and it is going quite good. I know the code could be a lot better but for now it is good enough for me. Well, mostly.

Because the code is kind of purely written (or so I think) moving a group of objects is not all that easy. The solution I found (here) for this is scope which does work. However I am a bit unhappy with how it works.

In the code below the object is rotated by 15 degree around the point (0,0) as expected. However, the xshift=2 does not shift the entire scope by 2 on the same scale shifting everything manually by 2 would have.

I know that the axis environment has it's own coordinate system that can be accessed via (axis cs:10,10). Is there anything similar for scope?

Might this be a solution that could be adapted (I could split the image – chair, table and computer – in separate parts I guess)?

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}%[scale=0.750]
\tikzstyle{every node}=[font=\small]
% Temp stuff for construction only
\draw[step=.2, lightgray, very thin] (0,0) grid ++(15.0,8.0);
\foreach \s in {0,1,...,15.0}{
\draw [lightgray](\s,0) -- (\s,-.1) node[below, lightgray]{\s};
}
\foreach \s in {0,1,...,8.0}{
\draw [lightgray](0,\s) -- (-.1,\s) node[left, lightgray]{\s};
}
% The Inside of the house
\begin{scope}[xshift=2cm, rotate=15] % unit was not in original code for question!
% Table
\draw (11.9,0) rectangle ++(0.1,1.); % leg 1
\draw (12.8,0) rectangle ++(0.1,1.);    % leg 2
\draw (11.8,1.) rectangle ++(1.2,0.05); % Surface plate
% Computer (iMac) ;-)
\fill (12.72,1.45) circle (0.03); % The nob in the back
\draw (12.74,1.45) .. controls (12.8,1.25) and (12.8,1.22) .. (12.8,1.06) -- (12.55,1.06); % Stand
\draw [fill=white, rotate around={-10:(12.6,1.15)}] (12.6,1.2) rectangle ++(0.07,0.6); % the iMac
% Chair
\draw (11.1,0) -- ++(0.2,0.2) -- ++ (0.2,-0.2); % leg part 1
\draw (11.3,0.2) -- ++(0,0.45); % leg part 2
\draw (11.05,0.65) rectangle ++(0.5,0.05); % seat
\draw (11,0.75) rectangle ++(0.05,0.5); % back support
\draw (11.15,0.65) .. controls (10.95,0.57) and (10.95,0.75) .. (11,0.95); % connection seat - back
\end{scope}
\end{tikzpicture}
\end{document}


P.S.: Could anyone point me at a comprehensive guide to understand the different coordinate systems in tikz? I have not been able to find anything like that.

And this is the final image I meant to create. I know its not much and likely the code (the above is only part of it) could be written more efficiently but never the less I am very happy with the result.

#### Best Answer

Interestingly, the option shift accepts as parameter a pair of coordinates, which do not require units (beware of the braces around the parenthesis):

\begin{tikzpicture}
\node[draw] {Foo};
\draw (1,1) circle (0.2);
\begin{scope}[shift={(1,1)}]
\node[draw] {Bar};
\end{scope}
\end{tikzpicture}


You can use scale, x, and/or y options in the tikzpicture, as usual.