Wie fügt man in Beamer einer Abbildung innerhalb eines Tikz-Knotens eine Beschriftung hinzu?

Wie fügt man in Beamer einer Abbildung innerhalb eines Tikz-Knotens eine Beschriftung hinzu?

Ich dachte, ich würde die Antwort findenHIER, aber die Lösung scheint in diesem speziellen Fall nicht zu funktionieren ...

Allgemein: Wie platziert man Bildunterschriften in Tikz-Knoten? Ich habe das folgende MWE erstellt, aber das ist nicht das Layout, das ich in meiner Präsentation verwende, sondern nur ein zufälliges, also brauche ich eine allgemeine Lösung, nicht nur für dieses Beispiel ...

In diesem Beispiel möchte ich direkt unter Abbildung B eine Überschrift einfügen. Wie gehe ich dabei vor?

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}

Produziert:

Feige

Antwort1

captionIn einem Fall, in dem Ihre Überschrift nur eine Zeile hat, können Sie das gewünschte Ergebnis ohne Verwendung von Paket und figureUmgebung erzielen :

\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}

Bildbeschreibung hier eingeben

Sie können das TikZ-Bild jedoch in zwei Teile aufteilen:

\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}

Wenn Sie keine Beschriftung in der Überschrift haben möchten Figure, müssen Sie nur die Vorlage entsprechend anpassen caption, zum Beispiel der Präambel Folgendes hinzufügen:

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

Nachtrag: Mir ist nicht klar, was der Zweck der TikZ-Knoten ist. Bilder in Knoten können Sie in derselben Rahmenform anordnen wie zuvor ohne sie:

\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}

Das Bild des Rahmens ist dasselbe wie zuvor, aber der Code ist einfacher und prägnanter.

Antwort2

Nutzen Sie die justification=centeringOption im captionPaket.

\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}

Bildbeschreibung hier eingeben

verwandte Informationen