0

I am attempting to work through nice (absolute) positioning in beamer for a presentation. I decided to avoid tickz because I am running short on time. So I found a nice post here that offers a simple solution using \put. I am however attempting to extend that solution to add some text below my figure. Say for example:

The original example is (copied from the post):

\PassOptionsToPackage{demo}{graphicx}%% Only for demo here
\documentclass{beamer}
\def\Put(#1,#2)#3{\leavevmode\makebox(0,0){\put(#1,#2){#3}}}

\begin{document}

\begin{frame}
\includegraphics[height=3cm]{img1}\pause
\Put(10,50){\color{blue}\includegraphics[height=3cm]{img2}}\pause
\Put(100,30){\color{red}\includegraphics[height=3cm]{img3}}
\end{frame}

\end{document}

And I want to have for example a text with 'black', 'blue' and 'red' positioned at the bottom of each rectangle.

I thought to simply define:

\def\Putt(#1,#2){\put(#1,#2)\minipage{#}}

but it does not work. It gives me some strange error:

! You can't use `\raise' in internal vertical mode.

I say strange, because in principle, I am leaving out \leavevmode in my new command. Please advice.

maurizio
  • 281

1 Answers1

1

minipage is an environment hence you cannot use \minipage{...} alone. Instead, you can wrap the figure environment in a varwidth, then use varwidth as the third argument of \Put.

An example:

\PassOptionsToPackage{demo}{graphicx}%% Only for demo here
\documentclass{beamer}
\usepackage{varwidth}

\def\Put(#1,#2)#3{\leavevmode\makebox(0,0){\put(#1,#2){#3}}}

\begin{document}

\begin{frame}
  \includegraphics[height=3cm]{example-image-a}\pause

  \Put(10,50){%
    \begin{varwidth}{\linewidth}
      \begin{figure}
        \centering
        \color{blue}\includegraphics[height=3cm]{example-image-b}
        \caption{Title}
      \end{figure}
    \end{varwidth}%
  }\pause

  \Put(100,30){\color{red}\includegraphics[height=3cm]{example-image-c}}
\end{frame}

\end{document}

enter image description here

muzimuzhi Z
  • 26,474
  • @muzimzhi Thank you! I thought it could be easier. But this is a good working solution. – maurizio Jun 06 '20 at 13:25
  • @maurizio You can define new commands to abstract varwidth and figure environments, which might make the input more compact. – muzimuzhi Z Jun 06 '20 at 14:12