20

i'm creating a presentation with the latex beamer class and want to change the spacing between the figure and the caption. I think it is to large at the moment.

\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Luebeck}
\setbeamercolor{structure}{fg=PineGreen}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{graphicx}

\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
  \oldmacro\hfill%
  \insertframenumber\,/\,\inserttotalframenumber}

\setbeamertemplate{itemize items}[triangle]
\setbeamerfont{caption}{size=\tiny}


\begin{document}

\begin{frame}{Tresholding - OpenCV-Methoden}

\centering
\begin{minipage}{.5\textwidth}
    \centering
    \begin{figure}
        \includegraphics[width=.8\linewidth]{images/treshold_otsu.png}
        \caption{Otsu Tresholding}
    \end{figure}
\end{minipage}%
\begin{minipage}{.5\textwidth}
    \centering
    \begin{figure}
        \includegraphics[width=.8\linewidth]{images/treshold_adaptive.png}
        \caption{Adaptive Tresholding}
    \end{figure}
\end{minipage}

\end{frame}

\end{document}

How could that be achieved? Here is an image of the slide:

Image of a slide with the spacing marked

1
  • If you are creating slides and don't intend to create a list of figures, then you really don't need either figure or caption. Use a tabular instead. Commented Feb 2, 2015 at 15:07

3 Answers 3

22

The proper way to do this is to redefine \abovecaptionskip so the change in vertical spacing will consistently apply to all the captions; in the example below I used

\setlength\abovecaptionskip{-5pt}

but you can change the value in the argument according to your needs.

\PassOptionsToPackage{demo}{graphicx}
\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Luebeck}
\setbeamercolor{structure}{fg=PineGreen}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{textcomp}

\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
  \oldmacro\hfill%
  \insertframenumber\,/\,\inserttotalframenumber}

\setbeamertemplate{itemize items}[triangle]
\setbeamerfont{caption}{size=\tiny}

\setlength\abovecaptionskip{-5pt}

\begin{document}

\begin{frame}{Tresholding - OpenCV-Methoden}

\centering
\begin{minipage}{.5\textwidth}
    \centering
    \begin{figure}
        \includegraphics[width=.8\linewidth]{images/treshold_otsu.png}
        \caption{Otsu Tresholding}
    \end{figure}
\end{minipage}%
\begin{minipage}{.5\textwidth}
    \centering
    \begin{figure}
        \includegraphics[width=.8\linewidth]{images/treshold_adaptive.png}
        \caption{Adaptive Tresholding}
    \end{figure}
\end{minipage}

\end{frame}

\end{document}

The result:

enter image description here

The line \PassOptionsToPackage{demo}{graphicx} simply replaces actual figures with black rectangles; delete that line in your actual document.

1
  • There is also a \belowcaptionskip which is particularly useful for tables (since their caption is usually on top).
    – stefanct
    Commented Jun 18, 2020 at 14:32
6

You can do it manually by using \vspace*{-0.3cm} (or whatever distance you like) in front of the caption.

\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Luebeck}
\setbeamercolor{structure}{fg=PineGreen}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{textcomp}
\usepackage{graphicx}

\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
  \oldmacro\hfill%
  \insertframenumber\,/\,\inserttotalframenumber}

\setbeamertemplate{itemize items}[triangle]
\setbeamerfont{caption}{size=\tiny}


\begin{document}

\begin{frame}{Tresholding - OpenCV-Methoden}

\centering
\begin{minipage}{.5\textwidth}
    \centering
    \begin{figure}
        \includegraphics[width=.8\linewidth]{example-grid-100x100bp.pdf}
        \vspace*{-0.3cm}
        \caption{Otsu Tresholding}
    \end{figure}
\end{minipage}%
\begin{minipage}{.5\textwidth}
    \centering
    \begin{figure}
        \includegraphics[width=.8\linewidth]{example-grid-100x100bp.pdf}
        \vspace*{-0.3cm}
        \caption{Adaptive Tresholding}
    \end{figure}
\end{minipage}

\end{frame}

\end{document}

enter image description here

1
  • But then you need to do this for each caption. Commented Feb 2, 2015 at 17:20
2

You can use the caption package for this:

\usepackage[skip=2pt]{caption} % example skip set to 2pt

This will effect all figures.

The documentation says:

The vertical space between the caption and the figure or table contents is controlled by the option skip=amount. The standard LATEX document classes article, report and book preset it to skip=10pt, but other document classes may use a different amount.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .