Here we are going to see how to achieve the same effect of dragging and dropping, not visually, but using the tikz package. At first this may seem as a dull and complicated version of the what you see is what you get abilities; but believe me that once you get used to it, you will be able to do much more things, you will see it as a powerful tool that is even easier and quicker than using the mouse. In short, that you will never look back.

But to start this transitional journey, here I am going to show you one basic
feature: how to overlay images, like if you dragged one on top of the other

Consider the following tow images:


The following code highlights the process of overlapping two images in Beamer using TikZ package:

% Overlap images in Beamer

% Theme choice

% load the package tikz to manipulate the images


\begin{frame}{Overlap images in Beamer}
% create a center environment, so that the contents appear
% at the center of the frame

% create a new tikz picture
% load the first image nature1.png as a node called img1
\node (img1) {\includegraphics[height=3cm]{nature1.png}};

% insert a pause so that two slides are created:
% the first containing only nature1.png and the second with
% nature2.png overlapping the first image

% create a new node with the image nature2.png,
% that is ubicated at the south east of the first node
\node (img2) at (img1.south east)




This code creates two slides as shown below:


  • On the preamble, we used CambridgeUS theme and loaded TikZ package.
  • Then, inside a frame, we added a center environment in order to position our content on the center of the frame.
  • Inside the center environment, we added tikzpicture environment to include images.
  • Including an image in TikZ is achieved by the \node command where its content has the well known \includegraphics command. The node content is put between curly braces {}.
  • The first node corresponds to the first image is named (img1) and the second node corresponds to the second image and named (img2).
  • Between the two node images, we added \pause command in order to display the first image in a slide then overlapped with the second image in another slide. Check Creating Overlays in Beamer lesson!
  • Saving nodes corresponds to saving its coordinates and allows us to access to any point of its border. For that, we positioned the second image at the south east of image 1, which corresponds to (img1.south east). Think about it as follows:

We reached the end of this tutorial, Please if you find it useful, share it!