我在使用 Beamer 包中的块时遇到了问题。这些块中标题下方的间距在不同的块类型之间是不同的,在我的情况下是exampleblock
和之间alertblock
。以下图片说明了我的意思:
如您所见,顶部示例块中的标题比底部警报块的标题更靠近正文。我想让示例块看起来与警报块相同。我该怎么做?
这是我的代码的一个最小工作示例:
\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\setbeamertemplate{navigation symbols}{}
\definecolor{blue}{rgb}{0,0.568627,0.862745}
\definecolor{lightblue}{rgb}{0.784313,0.901960,0.980392}
\definecolor{grey}{rgb}{0.713725,0.745098,0.776470}
\definecolor{lightgrey}{rgb}{0.898039,0.909803,0.921568}
\usecolortheme[named=black]{structure}
\setbeamertemplate{blocks}[default]
\setbeamercolor{block title}{bg=blue,fg=white}
\setbeamercolor{block body}{bg=lightgrey}
\setbeamercolor{block title alerted}{bg=white}
\setbeamercolor{block body alerted}{bg=lightblue}
\setbeamercolor{block title example}{fg=blue}
\setbeamercolor{block body example}{bg=lightblue}
\setbeamertemplate{itemize items}[circle]
\setbeamertemplate{itemize item}{\color{blue}$\bullet$}
\setbeamertemplate{itemize subitem}{\color{blue}$\bullet$}
\setbeamertemplate{frametitle}{\vspace*{1.7cm}\textbf{\small\insertframetitle}}
\begin{document}
\frame {
\frametitle{Vor-und Nachteile}
\begin{exampleblock}{Vorteile}
\begin{itemize}
\item Vorteil 1
\item Vorteil 2
\end{itemize}
\end{exampleblock}
\begin{alertblock}{Nachteile}
\begin{itemize}
\item Nachteil 1
\item Nachteil 2
\end{itemize}
\end{alertblock}
}
\end{document}
在 Windows 10 上使用 MiKTeX XeTeX 进行编译
答案1
您的示例和警报块之间的区别在于,在一种情况下,您将block title
背景颜色设置为白色,在另一种情况下,您没有设置它。Beamer 对空白块背景使用不同的边距。
您可以通过为两种情况设置颜色或将两种情况都留空来避免该问题,只要保持一致即可。
\documentclass[aspectratio=169,xcolor=dvipsnames]{beamer}
\definecolor{blue}{rgb}{0,0.568627,0.862745}
\definecolor{lightblue}{rgb}{0.784313,0.901960,0.980392}
\definecolor{grey}{rgb}{0.713725,0.745098,0.776470}
\definecolor{lightgrey}{rgb}{0.898039,0.909803,0.921568}
\setbeamercolor{block title}{bg=blue,fg=white}
\setbeamercolor{block body}{bg=lightgrey}
\setbeamercolor{block title alerted}{bg=white}
\setbeamercolor{block body alerted}{bg=lightblue}
\setbeamercolor{block title example}{fg=blue,bg=white}
\setbeamercolor{block body example}{bg=lightblue}
\begin{document}
\frame {
\frametitle{Vor-und Nachteile}
\begin{exampleblock}{Nachteile}
\begin{itemize}
\item Nachteil 1
\item Nachteil 2
\end{itemize}
\end{exampleblock}
\begin{alertblock}{Nachteile}
\begin{itemize}
\item Nachteil 1
\item Nachteil 2
\end{itemize}
\end{alertblock}
}
\end{document}