No Beamer, como você adiciona uma legenda a uma figura dentro de um nó tikz?

No Beamer, como você adiciona uma legenda a uma figura dentro de um nó tikz?

Eu pensei que encontraria a respostaAQUI, mas a solução parece não funcionar neste caso específico...

Em geral: como você coloca legendas para figuras dentro de nós tikz? Fiz o seguinte MWE, mas esse não é o layout que uso na minha apresentação, apenas um aleatório, então preciso de uma solução geral, não só para esse exemplo...

Neste exemplo, quero apenas colocar uma legenda logo abaixo da figura B, como devo fazer?

MWE:

\documentclass{beamer}

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

\begin{document}

\begin{frame}
    \begin{figure}
    \begin{tikzpicture}[remember picture, every node/.style={inner sep=0,outer sep=0}]

    \node[anchor=west] (A) at (0,0) {\includegraphics[width=2.25cm]{example-image-a}};

    \node[right=0.75cm of A.east, anchor=west] (B) {\includegraphics[width=2.25cm]{example-image-b}
        %\captionof{figure}{my caption here}%I was hoping this would work...
    };
    \node[below=\belowcaptionskip of B,text width=\linewidth]
    {\captionof{figure}{my caption here}};%And this doesn't work either...

    \node [right=0.75cm of B.east, anchor=west] (C) {\includegraphics[width=2.25cm]{example-image-c}};

    \node [below=0.75cm of A.south east, anchor=north west] (D) {\includegraphics[width=2.25cm]{example-image}};

    \node [right=0.75cm of D.east, anchor=west] (E) {\includegraphics[width=2.25cm]{example-image}};

    \node [right=0.75cm of E.east, anchor=west] (F) {\includegraphics[width=2.25cm]{example-image}};
    \end{tikzpicture}
    \end{figure}
\end{frame}

\end{document}

Produz:

Figo

Responder1

No caso, quando sua legenda possui apenas uma linha, você pode obter o resultado desejado sem uso de captionpacote e figureambiente:

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

\begin{document}
\begin{frame}
    \begin{center}
    \begin{tikzpicture}[node distance=2mm and 5mm]
\node              (A)  {\includegraphics[width=2.25cm]{example-image-a}};
\node [right=of A] (B)  {\includegraphics[width=2.25cm]{example-image-b}};
\node [right=of B] (C)  {\includegraphics[width=2.25cm]{example-image-c}};
    \node (capt) [below=of B,text width=\linewidth, align=center,font=\scriptsize]
                        {my caption here};
\node [below=of A |- capt.south] (D) {\includegraphics[width=2.25cm]{example-image}};
\node [right=of D] (E)  {\includegraphics[width=2.25cm]{example-image}};
\node [right=of E] (F)  {\includegraphics[width=2.25cm]{example-image}};
    \end{tikzpicture}
    \end{center}
\end{frame}
\end{document}

insira a descrição da imagem aqui

No entanto, você pode dividir a imagem TikZ em duas partes:

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

\begin{document}
\begin{frame}
    \begin{figure}\centering
    \begin{tikzpicture}[node distance=2mm and 5mm]
\node              (A)  {\includegraphics[width=2.25cm]{example-image-a}};
\node [right=of A] (B)  {\includegraphics[width=2.25cm]{example-image-b}};
\node [right=of B] (C)  {\includegraphics[width=2.25cm]{example-image-c}};
    \end{tikzpicture}
\caption{my caption here}
    \begin{tikzpicture}[node distance=2mm and 5mm]
\node              (D) {\includegraphics[width=2.25cm]{example-image}};
\node [right=of D] (E)  {\includegraphics[width=2.25cm]{example-image}};
\node [right=of E] (F)  {\includegraphics[width=2.25cm]{example-image}};
    \end{tikzpicture}
    \end{figure}
\end{frame}
\end{document}

Se você não gosta de ter Figurerótulo na legenda, você só precisa definir captiono modelo de acordo, por exemplo, adicionar ao preâmbulo:

\setbeamerfont{caption}{size=\scriptsize}
\setbeamertemplate{caption}{\insertcaption\par}

Adendo: Não está claro para mim qual é o propósito dos nós TikZ. Imagens em nós você pode organizar na mesma forma de quadro de antes, sem eles:

\documentclass{beamer}
\setbeamerfont{caption}{size=\scriptsize}
\setbeamertemplate{caption}{\insertcaption\par}

\begin{document}
\begin{frame}
    \begin{figure}\centering
\includegraphics[width=2.25cm]{example-image-a}\hfil
\includegraphics[width=2.25cm]{example-image-b}\hfil
\includegraphics[width=2.25cm]{example-image-c} 

\caption{my caption here}

\includegraphics[width=2.25cm]{example-image}\hfil
\includegraphics[width=2.25cm]{example-image}\hfil
\includegraphics[width=2.25cm]{example-image}
    \end{figure}
\end{frame}
\end{document}

A imagem do quadro é a mesma de antes, mas o código é mais simples e conciso.

Responder2

Use a justification=centeringopção no captionpacote.

\documentclass{beamer}
\usepackage{lmodern,tikz}
\usetikzlibrary{positioning,calc}
\usepackage[labelformat=empty,font=scriptsize,skip=0pt,
justification=centering,singlelinecheck=false]{caption}

\begin{document}
\begin{frame}
    \begin{figure}\centering    
    \begin{tikzpicture}
    \node [anchor=west] (A) at (0,0) {\includegraphics[width=2.25cm]{example-image-a}};
    \node [right=0.75cm of A.east, anchor=west] (B) {\includegraphics[width=2.25cm]{example-image-b}};
    \node [below=\belowcaptionskip of B,text width=\linewidth]{\captionof{figure}{my caption here}};    
    \node [right=0.75cm of B.east, anchor=west] (C) {\includegraphics[width=2.25cm]{example-image-c}};
    \node [below=0.75cm of A.south, anchor=north] (D) {\includegraphics[width=2.25cm]{example-image}};
    \node [right=0.75cm of D.east, anchor=west] (E) {\includegraphics[width=2.25cm]{example-image}};
    \node [right=0.75cm of E.east, anchor=west] (F) {\includegraphics[width=2.25cm]{example-image}};    
    \end{tikzpicture}
    \end{figure}
\end{frame}
\end{document}

insira a descrição da imagem aqui

informação relacionada