
我的 MWE 具有「可見」過渡;有些元素在 <1> 中可見,有些元素在 <2> 中可見。
我得到了想要的結果,直到我試著弄亂字幕;當我嘗試在 <2> 中添加圖 B 的標題(在 MWE 中註釋)時,我收到了大約一百萬個錯誤,從以下內容開始:
\spacefactor 不正確。 \結束{幀}
請注意,我想為圖 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}
其產生:
請注意 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};