TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to merge two existing TikZ pictures into one? I have two pictures of this type and want to set them beneath each other in one tikzpicture environment (and adding some arrows between both pictures) without editing all the coordinates :

  \begin{tikzpicture}[domain=0:2.1, smooth, scale=0.8]
  \draw[->] (0,0) -- (4.2,0);
  \draw[->] (0,0) -- (0,3.2);
  \draw[] (1,0) -- (1,-0.15) node[below] {$\alpha_0$};
  \draw[color=red,thick,samples=500] plot (\x,{3*exp(-5*(\x-1)^2});
  \draw[color=blue,dashed,thick,samples=500] plot (\x,{3*exp(-5*(\x-1)^2});

Is there an easy way to do that?

share|improve this question
It's quite hard to tell without a MWE, but maybe you are looking for the scope environment provided by tikz/pgf? – bloodworks Feb 5 '13 at 15:55
Welcome to TeX.sx! – Corentin Feb 5 '13 at 15:56

You can simply include both your TikZ pictures into one by placing them inside nodes of yet another TikZ picture. As long as you don't seriously have to worry about compilation time it is OK to write something like the code below.
It also helps with the arrows in between.



       \node (a) at (0,0)
               \draw (0,0) circle (1cm);
        \node (b) at (a.south) [anchor=north,yshift=-1cm]
            \tikz\fill[blue] (0,0) circle (0.7cm);
       \draw [<->] (a)--(b);


Result of the example code

share|improve this answer

To shift part of a picture one can use a {scope} and one of the shifting options:

  • shift=<coordinate> (Argument has do be in braces {} when it contains a comma ,)
  • xshift=<distance>
  • yshift=<distance>

In the following example I’ll use shift and a predefined coordinate (shift) (the name doesn’t matter) to have easy access to the shifting later.



  % Shifting coordinate (optional)
  \coordinate (shift) at (0,-3);
  % First image, without a scope
  \draw (0,0) circle (1);
  \fill (2,-1) rectangle ++(4,2);
  %% named node
  \node (A 1) at (8,0) {Node 1};
  %% named coordinate
  \coordinate (C 1) at (10,0);
    \draw (8,0) circle (1);
    \fill (2,-1) rectangle ++(4,2);
    \node (A 2) at (0,0) {Node 2};
    \coordinate (C 2) at (10,0);
  % Connection line
  %% A) use named coordinates nodes
  \draw [red,->] (A 1) -- (A 2);
  %% B) use named coordinates
  \draw [blue, ->] (C 2) -- (C 1);
  %% C) use calculation with (shift)
  \draw [green, ->] (0,0) -- ($(8,0)+(shift)$);
  %% D) shift a single coordinate
  \draw [orange, ->] (2,-1) -- ([shift=(shift)] 4,1);

resulting image

To access both coordinate systems I’d prefer using named nodes or coordinates which is basically the same (red and blue arrow in the example). But it is also possible to use the calc library and add the shifting manually, by using ($<coord>+(shift)$) (green arrow). As Qrrbrbirlbel stated it is also possible to apply the shift option to a single coordinat (orange arrow).

share|improve this answer
The shifting options can be applied to single coordinates too (without the calc library): \draw [green, ->] (0,0) -- ([shift=(shift)] 8,0); – Qrrbrbirlbel Feb 5 '13 at 17:25
@Qrrbrbirlbel: Thank you I added that to my answer. – Tobi Feb 5 '13 at 17:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.