I currently have some LaTeX code to have multiple images side by side:

\caption{my caption.}

I would now like to add a small inset, inside for example foo12.jpg and foo22.jpg. For example, having the image bar12.jpg as a small thumbnail in the top-right corner of foo12.jpg and having the image bar22.jpg as a small thumbnail in the top-right corner of foo22.jpg.

Of course, my goal is not to do that using Photoshop (or any external tool/script) but to do it directly in LaTeX. I guess this should be doable (since with Acrobat we can place images wherever we want in a PDF, and since LaTeX figures are "floating"), but have no idea how and I can't find any resource to help.


3 Answers 3


If you know the dimensions of the images, then you can easily do this with a raised overlap.

enter image description here

\usepackage{graphicx}% http://ctan.org/pkg/graphicx
  \includegraphics[height=2cm]{example-image-a}\llap{\raisebox{1cm}{\includegraphics[height=1cm]{example-image-c}}} \\
  \caption{My caption.}

I've used the example images from the mwe package, and knowing that the heights will be 1cm, raising by 1cm will fill the 2cm of the original image. However, if you don't know the heights, one can always box the contents and extract the height, as I did with \setbox1=\hbox{...} and using \wd1 (width of box 1). There might be better ways of doing this.


The stackengine package has this feature. UPDATED for newer syntax.

The command featured here is \stackinset. The six arguments to inset content are

\stackinset{<hrz>}{<offset>}{<vrt>}{<offset>}{<inset content>}{<base content>}

The value of <hrz> of l, c, or r determines whether the H-offset is from the left, center, or right. The value of <vrt> of t, c, or b determines whether the V-offset is from the top, center, or bottom.

As you can see, the offsets can also be negative, essentially moving the inset outside of the larger graphic.

The package is available at https://ctan.org/pkg/stackengine, with a companion package for tabbed stacking at https://ctan.org/pkg/tabstackengine.

\parskip 1em



enter image description here

  • is there a way to get the inset to protrude into the caption? It is killing me because I certainly have much more space to make my inset bigger, but if I make it go into the caption (where there is in fact lots of space available), the whole figure goes down a bit, in order to not interfere with the caption. But I don't care about it going through the caption. Is there any work-around? Commented Dec 7, 2018 at 21:56
  • @user1271772 Try smashing a vertically shifted image: \begin{figure} \caption{This is my caption} \stackinset{l}{2pt}{t}{}{\smash{\abovebaseline[2pt]{\little}}}{\big} \end{figure} \begin{figure} \stackinset{l}{2pt}{b}{}{\smash{\belowbaseline[10pt]{\little}}}{\big} \caption{This is my caption} \end{figure} Commented Dec 8, 2018 at 3:10
  • 1
    Thanks for this nice package! Maybe you could consider updating this answer to use \stackinset instead as it seems \topinset and its family got deprecated in more recent versions of the package?
    – Raven
    Commented Dec 28, 2020 at 18:47
  • 1
    @Raven Tank you for the suggestion. Done. Commented Dec 28, 2020 at 22:38

Borrowing some of the excellent code from Drawing on an image with TikZ you can achieve this using tikz





        \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=\textwidth]{mushroom}};
        \begin{scope}[x={(image.south east)},y={(image.north west)}]
            \draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
            \foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
            \foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
            \node[anchor=south west,inner sep=0] (image) at (0.5,0.7) {\includegraphics[width=0.1\textwidth]{tux}};
    \caption{Find that penguin!}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .