0

I have the MWE with "visible" transitions; there are elements that are visible in <1> and elements that are visible in <2>.

I obtain the desired result until I try to mess with captions; the moment I try to add the caption of Figure B in <2> (commented in the MWE), I get the like one million errors, starting with:

Improper \spacefactor. \end{frame}

NOTE THAT I WANT TO ADD DIFFERENT CAPTIONS FOR FIGURES A AND B.

This is the MWE:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usepackage[labelformat=empty,font=scriptsize,skip=0pt,
justification=raggedright,singlelinecheck=false]{caption}
\usepackage{threeparttable}

\begin{document}

\begin{frame}
    \begin{figure}
    \begin{measuredfigure}
    \begin{tikzpicture}[remember picture, every node/.style={inner sep=0,outer sep=0,align=left}]
    \node (node1) at (0,0) {\includegraphics[width=6.8cm]{example-image}};

    \visible<1>{
        \node[right=6.9cm of node1.south west, anchor=south west] (node2) {\includegraphics[width=3.75cm]{example-image-a}};
    }
    \visible<2>{
        \node[right=6.9cm of node1.south west, anchor=south west] (node2) {\includegraphics[width=3.75cm]{example-image-b}};
    }
    \end{tikzpicture}
    \visible<1>{
        \captionof{figure}{\hspace{6.9cm}caption of figure A}
    }
    %\visible<2>{%WORKS UNTIL I TRY TO ADD THIS CAPTION
    %   \captionof{figure}{\hspace{6.9cm}caption of figure B}
    %}
    \end{measuredfigure}
    \end{figure}
\end{frame}

\end{document}

Which produces:

A

B

Note the absence of caption under B... How can I make it work?? Thanks!!

2

Edit: try the following MWE:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{frame}
    \begin{figure}
\begin{tikzpicture}[
    node distance =0mm and 5mm,
    every node/.style={anchor=west, align=center}
                    ]
\node (a) {\includegraphics[width=6.8cm]{example-image}};
\visible<1>{
\node (b) [above right=of a.south east] {\includegraphics[width=3.75cm]{example-image-a}};
\node[below=of b] {caption of figure A};
            }
\visible<2>{
\node (b) [above right=of a.south east] {\includegraphics[width=3.75cm]{example-image-b}};
\node[below=of b] {caption of figure B};
            }
\end{tikzpicture}
    \end{figure}
\end{frame}
\end{document}

In case of multi line caption is sensible define separate style for nodes with caption. For example:

 capt/.style = {text width=#1, align=left}

and than instead \node[below=of b] {caption of figure B}; use

\node[capt=3.75cm, below=of b] {caption of figure B};
  • This is not what I am looking for, the caption of figure B should be different from the caption of figure A... – DaniCee Feb 2 '17 at 4:17
  • I see there might be a confusion with the names I gave to the nodes, let me clarify the MWE – DaniCee Feb 2 '17 at 4:20
  • Yes that's what I thought... as in my other question, we need another node for captions in these scenarios, we cannot just use captionof{figure} – DaniCee Feb 2 '17 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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