Beamer \visible 幻灯片过渡,字幕不起作用

Beamer \visible 幻灯片过渡,字幕不起作用

我有带“可见”转换的 MWE;有些元素在 <1> 中可见,有些元素在 <2> 中可见。

我获得了预期的结果,直到我尝试弄乱标题;当我尝试在 <2> 中添加图 B 的标题(在 MWE 中注释)时,我得到了大约一百万个错误,首先是:

\spacefactor 不正确。 \end{frame}

请注意,我想为图 A 和 B 添加不同的标题。

这是 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}

其结果为:

A

乙

请注意 B 下没有标题...我该如何让它工作?谢谢!

答案1

编辑: 尝试以下 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}

如果有多行标题,则为带有标题的节点定义单独的样式是明智的。例如:

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

而不是\node[below=of b] {caption of figure B};使用

\node[capt=3.75cm, below=of b] {caption of figure B};

相关内容