Search code examples
latexcaptionbeamer

caption outside float in figure Beamer/Latex


I am trying to add a photo that actually works in the main.tex until I insert one of the captions. Is there any way to get around this? many thanks in advance.

\documentclass{beamer}
\usetheme{Ilmenau}
\setbeamercovered{transparent}
\setbeamercolor*{item}{fg=blue}

\usepackage{caption}
\captionsetup{font=scriptsize,labelfont=scriptsize}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\title{DNA - Computing}
\author{A}
\begin{document}
    \begin{frame}[plain]
        \maketitle
    \end{frame}
    
%6 FOTO
\begin{frame}{DNA (1)}
    \begin{itemize}
        \begin{columns}
            \column{0.50\linewidth}
            \centering
            \includegraphics[height=4cm, width=4cm]{./6.jpg}
            %\caption{Aufbau DNA}
            %\captionof{./6.jpg}{Abbildung: Aufbau DNA}%
            
            \column{0.50\linewidth}     
            \item Desoxyribonukleinsäure
            \pause \item Speicherung der Erbinformationen/ Multiprozessorsysteme
            \pause \item Doppelhelix 
            \pause \item Grundbausteinen:   
            \begin{itemize}
                \item kleiner organische Basen
                \item Zuckermoleküle
                \item Phosphatgruppen  
            \end{itemize} 
        \end{columns} 
    \end{itemize}
\end{frame}

\end{document}

Solution

  • Two problems:

    • you can't use \caption outside of a figure (or table) environment

    • You have to specify the float type in \captionof, not the file name, e.g. \captionof{figure}{Aufbau DNA} to set the caption of a figure


    \documentclass{beamer}
    \usetheme{Ilmenau}
    \setbeamercovered{transparent}
    \setbeamercolor*{item}{fg=blue}
    
    \usepackage{caption}
    \captionsetup{font=scriptsize,labelfont=scriptsize}
    \usepackage[T1]{fontenc}
    \usepackage[ngerman]{babel}
    
    \title{DNA - Computing}
    \author{A}
    \begin{document}
        \begin{frame}[plain]
            \maketitle
        \end{frame}
        
    %6 FOTO
    \begin{frame}{DNA (1)}
        \begin{itemize}
            \begin{columns}
                \column{0.50\linewidth}
                \centering
                \includegraphics[height=4cm, width=4cm]{example-image-duck}
    %            \caption{Aufbau DNA}
                \captionof{figure}{Aufbau DNA}%
                
                \column{0.50\linewidth}     
                \item Desoxyribonukleinsäure
                \pause \item Speicherung der Erbinformationen/ Multiprozessorsysteme
                \pause \item Doppelhelix 
                \pause \item Grundbausteinen:   
                \begin{itemize}
                    \item kleiner organische Basen
                    \item Zuckermoleküle
                    \item Phosphatgruppen  
                \end{itemize} 
            \end{columns} 
        \end{itemize}
    \end{frame}
    
    \end{document}