Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\begin{figure*}
\begin{center}
\includegraphics[height=2cm]{foo11.jpg}
\includegraphics[height=2cm]{foo12.jpg}\\
\includegraphics[height=2cm]{foo21.jpg}
\includegraphics[height=2cm]{foo22.jpg}
\end{center}
\caption{my caption.}
\end{figure*}

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.

share|improve this question

migrated from stackoverflow.com Jan 7 '13 at 22:31

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 16 down vote accepted

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

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\begin{figure}
  \centering
  \setbox1=\hbox{\includegraphics[height=2cm]{example-image-b}}
  \includegraphics[height=2cm]{example-image-a}\llap{\includegraphics[height=1cm]{example-image-c}}
  \includegraphics[height=2cm]{example-image-a}\llap{\raisebox{1cm}{\includegraphics[height=1cm]{example-image-c}}} \\
  \includegraphics[height=2cm]{example-image-b}\llap{\makebox[\wd1][l]{\includegraphics[height=1cm]{example-image-c}}}
  \includegraphics[height=2cm]{example-image-b}\llap{\makebox[\wd1][l]{\raisebox{1cm}{\includegraphics[height=1cm]{example-image-c}}}}
  \caption{My caption.}
\end{figure}
\end{document}

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.

share|improve this answer
    
thanks a lot !! –  WhitAngl Jan 12 '13 at 3:52

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

screenshot

Code

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}

\begin{figure}[!htb]
    \centering
    \begin{tikzpicture}
        \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}};
        \end{scope}
    \end{tikzpicture}
    \caption{Find that penguin!}
\end{figure}
\end{document}
share|improve this answer

The just-submitted-to-CTAN stackengine package has this feature. The commands are \topinset and \bottominset. The four arguments to inset commands are {little image}{big image}{V-offset}{H-offset}. The \def\stackalignment{l or r} determines whether the H-offset is from the left or right. There is a c alignment too, but H-offset will not affect it...it will be centered.

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

The package is now available at http://ctan.org/tex-archive/macros/latex/contrib/stackengine .

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\parskip 1em
\begin{document}
\def\big{\includegraphics[height=4cm]{example-image}}
\def\little{\includegraphics[height=1.2cm]{example-image}}
\def\stackalignment{l}
\topinset{\little}{\big}{5pt}{2pt}
\bottominset{\little}{\big}{5pt}{25pt}\par
\def\stackalignment{r}
\topinset{\little}{\big}{7pt}{7pt}
\bottominset{\little}{\big}{12pt}{-5pt}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

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.