我正在使用 latex beamer 类创建演示文稿,并想更改图形和标题之间的间距。我认为目前间距太大了。
\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}
如何实现呢?以下是幻灯片的图片:
答案1
正确的做法是重新定义\abovecaptionskip
,以便垂直间距的变化能够一致地应用于全部标题;在下面的例子中,我使用了
\setlength\abovecaptionskip{-5pt}
但您可以根据需要更改参数中的值。
\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}
结果:
该线\PassOptionsToPackage{demo}{graphicx}
只是用黑色矩形替换实际图形;请在实际文档中删除该线。
答案2
\vspace*{-0.3cm}
您可以通过在标题前使用(或您喜欢的任何距离)手动完成此操作。
\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}
答案3
您可以使用caption
包裹为了这:
\usepackage[skip=2pt]{caption} % example skip set to 2pt
这将影响所有数据。
文档说:
标题和图形或表格内容之间的垂直间距由选项 skip=amount 控制。标准 LATEX 文档类 article、report 和 book 将其预设为 skip=10pt,但其他文档类可能使用不同的数量。