# How to move a whole tikzpicture?

I have a tikzpicture, rounded by a fbox, and embedded in a minipage. Is it possible to change the position of the whole picture inside the minipage? for instance, move the picture 1 unit higher and 1 unit on the right? I know that we could always change the coordinates of each elements in the picture (e.g., change (2,3) to (1,2)), but it is obviously not a good solution.

-
Changing the coordinates wouldn't help anyway, because as far as TeX is concerned for the placement on the page only the bounding box (=outline) of the picture is taken into account. – Caramdir Aug 17 '11 at 1:58

Horizontal displacement is easily obtained via \hspace[*]{<length>}, while vertical displacement can be managed using \raisebox{<length>}{<stuff>} from the graphicx package. As is clear from the following minimal example, the image on the left has been translated (+3em,+4em), while the duplicate figure on the left has been left unchanged in terms of positioning/translation:

\documentclass{article}
\usepackage{tikz}%
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{caption,subcaption}%
\usepackage{calc}% http://ctan.org/pkg/calc

​\begin{document}
\noindent\begin{minipage}[t]{0.48\linewidth}%
\centering
\fbox{%
\begin{minipage}[t]{\linewidth-2\fboxsep-2\fboxrule}% Remove fbox rule/sep width
\hspace*{3em}\raisebox{4em}{\begin{tikzpicture}% Moved (+3em,+4em)
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\end{tikzpicture}}
\end{minipage}}
\captionof{figure}{picture1}\label{fig:picture1}
\end{minipage}\hfill
\begin{minipage}[t]{0.48\linewidth}%
\centering
\fbox{%
\begin{minipage}[t]{\linewidth-2\fboxsep-2\fboxrule}% Remove fbox rule/sep width
\begin{tikzpicture}
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{minipage}}
\captionof{figure}{picture2}\label{fig:picture2}
\end{minipage}

​\end{document}​​​​​​​​​​​​​


-
Amazing, that works, thank you again... – SoftTimur Aug 16 '11 at 23:42

As a very late answer, you could do the following to control the spacing above, below and to the left of your tikzpicture (adapting Werner's example):

\fbox{%
\begin{minipage}[t]{0.8\linewidth}
\hspace*{0.2\linewidth}
\rule[-2cm]{0pt}{6cm}
\begin{tikzpicture}
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\end{tikzpicture}%
\begin{tikzpicture}[baseline]
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\end{tikzpicture}%
\begin{tikzpicture}[baseline={(0,-0.5)}]
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw (0,0) circle (1cm);
\end{tikzpicture}%
\end{minipage}%
}


The idea is the following:

• hspace* moves the tikzpicture to the right (as in Werner's response).
• The invisible rule (or empty width) ensures that the minipage extends (at least) 2cm below the baseline and 4=6-2 cm above the baseline.
• By default, the tixpicture aligns itself such that the lowest point in the picture is at the baseline.
• This behaviour can be changed using the baseline option. Simply adding baseline moves the tikzpicture such that the baseline lies at y=0. Otherwise, one may specify a coordinate (but only the y component of this coordinate will play a role).

In this example, the horizontal line through the second circle is precisely at the baseline.

-