4

I want to adjust spacing between caption and table/figure in beamer. However I am not able to overcome the warning

Package caption Warning: \caption will not be redefined since it's already (caption) redefined by a document class or package which is (caption) unknown to the caption package.

I have tried by using caption and subfig packages. I used the command \captionsetup{skip=0pt,belowskip=0pt}. I am unable to overcome the warning. EDIT: I wish to add that I am trying to modify (reduce) the spacing in this frame. For other frames I am okay with the default spacing.

I need following format for my frame.

MWE the way it appears to me is

\documentclass{beamer}
\mode<presentation> {\usetheme{Madrid}}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{lmodern}% http://ctan.org/pkg/lm
\usepackage{bm}
\usepackage{subfig}
%   \usepackage{caption}
\graphicspath{{Images/}} % path for images

\begin{document}
    \begin{frame}
    \frametitle{Results: Measurement of Length}
    \begin{picture}(0,200)
    \put(-5,210){
        \begin{minipage}[t]{0.48\linewidth}
            \setbeamerfont{caption}{size=\tiny} 
            \captionsetup[figure]{skip=0pt}%,belowskip=0pt}
            \begin{figure}
                \includegraphics[width=4.5cm, height=3cm]{C5.S.Results/Slide1.png} 
                \caption{Calibration: 1mm $\approx$\ 247 pixels.}
            \end{figure}
        \end{minipage}
    }
    \put(175,210){
        \begin{minipage}[t]{0.48\linewidth}
            \centering
            \tiny{
            \begin{table}[H]
            \setbeamerfont{caption}{size=\tiny} 
            \captionsetup{skip=0pt,belowskip=0pt}   
            \caption{Mean of measurements shown in Fig.\  1}
            \begin{tabular}{cc}
                \specialrule{1pt}{0pt}{3pt}
                \textbf{Reading} & \textbf{Measurements from } \\
                \textbf{Number}& \textbf{Fig. A \ ($\bm\mu$m)}  \\
                \specialrule{1.5pt}{2pt}{4pt}
                    1 & 121.6\\
                    2 & 117.6\\
                    3 & 121.6\\
                    4 & 137.8\\
                    5 & 121.6\\\specialrule{0.25pt}{2pt}{4pt}
                \textbf{Mean diameter :} & \textbf{124}\\
                \specialrule{1pt}{2pt}{2pt}
            \end{tabular}
            \end{table}
            }
        \end{minipage}
    }
\end{picture}
\end{frame}
\end{document} 

The frame comes out like thisenter image description here

  • In any case, please provide a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – cfr Aug 25 '14 at 18:58
  • Please find the MWE (the way it appears a MWE to me). – Tarun Aug 25 '14 at 19:35
  • @cfr figure and table in beamer are not floats; the class redefines them so they don't float and it's perfectly safe to use them. This is, for example, the redefinition for figure in beamerbaselocalstructure.sty: \newenvironment{figure}[1][]{% \def\@captype{figure}% \par\nobreak\begin{center}\nobreak} {\par\nobreak\end{center}} – Gonzalo Medina Aug 25 '14 at 19:44
  • @GonzaloMedina Thanks. I didn't know that. However, the question is tagged 'floats' which was really the basis of my comment. However, what I should have said in that case was just that the OP is not, in fact, using floats (and that this is a good thing!). – cfr Aug 25 '14 at 19:47
  • @cfr;@GonzaloMedina I have removed the tag 'float'. Thanks for your observations. I wanted to tag it with 'figures'. I am surprised that such a tag doesn't seem to be available. – Tarun Aug 25 '14 at 19:55
5

The best way to proceed here is to locally redefine \abovecaptionskip and \belowcaptionskip (default value=7pt). The following example shows this redefinition (it's local since it's done inside an environment):

\documentclass{beamer}
\mode<presentation> {\usetheme{Madrid}}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{lmodern}% http://ctan.org/pkg/lm
\usepackage{bm}

\setbeamertemplate{caption}[numbered]

\begin{document}

\begin{frame}
\frametitle{Results: Measurement of Length}
    \begin{picture}(0,200)
    \setlength\abovecaptionskip{-5pt}
    \setlength\belowcaptionskip{0pt}
    \put(-5,210){
        \begin{minipage}[t]{0.48\linewidth}
            \setbeamerfont{caption}{size=\tiny} 
            \begin{figure}
                \includegraphics[width=4.5cm, height=3cm]{example-image-a} 
                \caption{Calibration: 1mm $\approx$\ 247 pixels.}
                \label{fig:calibration}
            \end{figure}
        \end{minipage}
    }
    \put(175,200){
        \begin{minipage}[t]{0.48\linewidth}
            \centering
            \tiny{
            \begin{table}[H]
            \setbeamerfont{caption}{size=\tiny} 
            \caption{Mean of measurements shown in Fig.~\ref{fig:calibration}}
            \begin{tabular}{cc}
                \specialrule{1pt}{0pt}{3pt}
                \textbf{Reading} & \textbf{Measurements from } \\
                \textbf{Number}& \textbf{Fig. A \ ($\bm\mu$m)}  \\
                \specialrule{1.5pt}{2pt}{4pt}
                    1 & 121.6\\
                    2 & 117.6\\
                    3 & 121.6\\
                    4 & 137.8\\
                    5 & 121.6\\\specialrule{0.25pt}{2pt}{4pt}
                \textbf{Mean diameter :} & \textbf{124}\\
                \specialrule{1pt}{2pt}{2pt}
            \end{tabular}
            \end{table}
            }
        \end{minipage}
    }
\end{picture}
\end{frame}
\end{document}

The result:

enter image description here

It's better not to number objects manually for cross-references; the recommended way is to use the standard \label, \ref mechanism. In your figure I placed a \label:

\caption{Calibration: 1mm $\approx$\ 247 pixels.}
\label{fig:calibration}

and then, in the table, I used \ref

\caption{Mean of measurements shown in Fig.~\ref{fig:calibration}}

(two runs are needed for the cross-reference to appear). I added

\setbeamertemplate{caption}[numbered]

to the preamble, so figures and tables are explicitly numbered.

  • Thank you so much. It worked like magic. I am very happy. – Tarun Jul 11 '15 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.