# tikz, overlay pgf pictures

I have three tikz/pgf pictures which I want to overlay using something like that

\subfloat[]{
\begin{tikzpicture}
\draw [yshift=5cm](0,0) rectangle (5,5);
\end{tikzpicture}
\scalebox{0.71}{\input{figures/hahn_long.pgf}}
\scalebox{0.4}{\input{figures/hahn_short.pgf}}


but that doesn't work, since it draws the three pictures, one after another (even the yshift has no effect). How can I do that?

-
Welcome to TeX.SX! –  Claudio Fiandrino Nov 11 '13 at 14:41
Did you try putting only the draw commands in the files and inputing them in the same TikZ-picture? Like \begin{tikzpicture} \draw...; \input{} }input{} \input{figures/hahn_long.pgf}? –  Tom Bombadil Nov 11 '13 at 14:52
yeah, not really, because the two .pgf pictures are created with python-matplotlib, and are therefore quite complicated, and not just simple \draw... commands... –  wa4557 Nov 11 '13 at 15:04

## 1 Answer

Without a minimal working example (MWE) it is a bit difficult to know what exactly shall be achieved here. However, if your goal is to horizontally overprint the context of your three figures, this can be achieved either using low-level TeX commands (\llap{<content>}, \rlap{<content>}) or, a bit more generic and less error-prone, LaTeX's \makebox[<width>][<align>]{<content>} command, with a zero value for the <width> parameter.

This TUBboat article provides a bit of background on these (and more) commands. In the following, I will use \makebox; in the last example additionally \raisebox{<yshift>}{<content>} to implement a vertical shift:

  \documentclass{article}
\usepackage{xcolor}

\newcommand{\figone}{{\color{black}\rule{4cm}{4cm}}}
\newcommand{\figtwo}{{\color{red}\rule{3cm}{3cm}}}
\newcommand{\figthree}{{\color{blue}\rule{2cm}{2cm}}}

\begin{document}
Text starts here:

\makebox[0pt][l]{\figone}%
\makebox[0pt][l]{\figtwo}%
\figthree%

\makebox[0pt][r]{\figone}%
\makebox[0pt][r]{\figtwo}%
\makebox[0pt][r]{\figthree}%

Text ends here:

\begin{center}
Centered:

\makebox[0pt][c]{\figone}%
\makebox[0pt][c]{\figtwo}%
\makebox[0pt][c]{\figthree}%

Centered, y-shifted:

\makebox[0pt][c]{\figone}%
\raisebox{0.5cm}{\makebox[0pt][c]{\figtwo}}%
\raisebox{1cm}{\makebox[0pt][c]{\figthree}}%

And so on...
\end{center}

\end{document}


Lacking the real figures, I have substituted the tree figures by colored squares of different size. The output looks like following:

-
I'd recommend \makebox[0pt][l]{...} instead of \rlap{...}; it's a bit longer to type, but avoids strange surprises by \rlap. –  egreg Nov 11 '13 at 18:49
@egreg: \makebox is certainly more flexible, but what strange surprises have to be expected by \rlap? –  Daniel Nov 11 '13 at 19:31
\rlap doesn't start horizontal mode. –  egreg Nov 11 '13 at 20:24
@egreg: Alright, thanks for telling me. I have switched to \makebox. –  Daniel Nov 11 '13 at 23:21
Cool. Works thanks! –  wa4557 Nov 12 '13 at 10:22