TikZ change reference point

The issue, I think, is to do with the internal and external specifications of the picture. When you draw a picture using TikZ then you scribble lots of stuff all over the page, using whatever coordinates you like. When you've finished, TikZ very nicely goes around your picture with a pair of scissors and cuts it out. It then hands it over to the TeX page layout builder and says, "Here's your picture.". The TeX page layout builder just gets the picture as-is and doesn't look closely at it. Indeed, as far as the layout builder is concerned, the picture could just be a frame. In particular, the layout builder doesn't look to see what coordinates you used in designing your picture.

So if you want your picture placed somewhere particular on the page, it's not TikZ that you need to talk to, but the layout builder. A simple way would be to tell her to put a big blank space in front of it, aka \hspace{2cm} (or \hspace*{2cm} if the former gets ignored).

It is possible to do what you want from within TikZ, though, by making the picture effectively bigger. Then when TikZ goes round with his scissors, he cuts the frame that he thinks is there whether or not there is actually anything in the picture (he's a bit dumb, you see).

Slightly less prosaically, in your picture then there is nothing at (0,0) so it gets ignored when computing the picture size. If you put something there then it will not be ignored. The trick is to put something there but to do it in a way that is actually nothing. (It's a bit like the emptyset in mathematics: it is nothing, but the fact that it is nothing is still something.)

Here's one way:

\documentclass[titlepage,a4paper]{article}

\usepackage{tikz}
\usepackage[lmargin=2.500000cm,rmargin=2.500000cm,tmargin=2.500000cm,bmargin=2.500000cm]{geometry}

\begin{document}
\section[General remarks]{General remarks}
\subsection[Geometry and coordinate system]{Geometry and coordinate system}
The main layout of the structure is adopted:\\

\begin{tikzpicture}[scale=1,thick]
\path (0,0); % <--- THIS LINE IS ADDED
  \begin{scope}[shift={(20mm,0)}]
    \foreach \xoffset in {0,5.2}
    {
      \begin{scope}[shift={(\xoffset,0)}]
      \draw[xstep=1,ystep=1] (0,0) grid (5,5);
      \end{scope}
    }
  \end{scope}
\end{tikzpicture}
\end{document}

Result:

Shifted grids


Shifting the whole picture doesn't make much sense. TikZ cuts every picture to its minimal bounding box. Therefore drawing from e.g. (0,0) to (10,10) or from (100,100) to (110,110) will give you the same visual result!

If you want to "move the picture 20mm to the right" you can put an otherwise empty path which includes (-20mm,0), so that the bounding box will be extended for this amount:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\section[General remarks]{General remarks}
\subsection[Geometry and coordinate system]{Geometry and coordinate system}
The main layout of the structure is adopted:\\

\begin{tikzpicture}[thick,scale=1]
    \path (-20mm,0);
    \foreach \xoffset in {0,5.2}
    {
      \begin{scope}[shift={(\xoffset,0)}]
      \draw[xstep=1,ystep=1] (0,0) grid (5,5);
      \end{scope}
    }
\end{tikzpicture}
\end{document}

If this isn't what you want tell me please.


If I understand correctly tikz behaviour, the picture is actually shifted, but at the end the picture is cropped so that the only remaining parts are those that contain some drawing. To obtain what you ask, you could explicitely set a bounding box using '\useasboundingbox' command as in:

\begin{tikzpicture}[scale=1,thick]
  \useasboundingbox (0,0) rectangle (70mm,5);
  \begin{scope}[shift={(20mm,0)}]
    \foreach \xoffset in {0,5.2}
    {
      \begin{scope}[shift={(\xoffset,0)}]
      \draw[xstep=1,ystep=1] (0,0) grid (5,5);
      \end{scope}
    }
  \end{scope}
\end{tikzpicture}

Tags:

Tikz Pgf