在我的一些Beamer 主题我使用的答案是在 Beamer 中使框架标题和块宽度相同。
然而现在一个问题已经提出,这由以下 MWE 证明:
\documentclass{beamer}
\setbeamertemplate{block begin}{
\begin{beamercolorbox}[wd=\textwidth, ht=0.5cm, dp=0.2cm, leftskip=0.2cm]{block title}%
\usebeamerfont*{block title}%
{\rule[-0.4ex]{0mm}{2ex}\insertblocktitle}%
\end{beamercolorbox}%
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\begin{beamercolorbox}[wd=\textwidth, ht=0.5cm, dp=0.2cm, leftskip=0.2cm]{block body}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block end}{
\end{beamercolorbox}
\vspace*{.25cm}
}
\setbeamertemplate{frametitle}{
\vspace*{0.3cm}
\begin{beamercolorbox}[wd=\textwidth, dp=0.3cm, ht=0.9cm, leftskip=0.2cm]{frametitle}
\usebeamerfont{frametitle}\insertframetitle%
\end{beamercolorbox}
}
\setbeamercolor{block title}{bg=yellow}
\setbeamercolor{frametitle}{bg=yellow}
\begin{document}
\begin{frame}{Block}
This is text before the block.
\begin{block}{blocktitle} some text here
\begin{itemize}
\item This is an item in the block.
\end{itemize}
This is text after the itemize.
\end{block}
This is text after the block.
\end{frame}
\end{document}
如您所见,块标题、块主体和周围的文本都变得混乱和重叠。请帮我解决这个问题!同样重要的是,包含框架标题的彩色框和包含块标题的彩色框(以及包含块主体的彩色框,如果有的话)的宽度保持不变。
答案1
我确信这段代码有问题,但它似乎解决了眼前的问题。链接的解决方案为块设置了一个固定高度,与为块和框架标题设置的高度相同。您不需要逐项显示来显示问题 - 只需多行文本即可。
\documentclass{beamer}
\setbeamertemplate{block begin}{
\vskip\baselineskip
\begin{beamercolorbox}[wd=\textwidth, ht=0.5cm, dp=0.2cm, leftskip=0.2cm]{block title}%
\usebeamerfont*{block title}%
{\rule[-0.4ex]{0mm}{2ex}\insertblocktitle}%
\end{beamercolorbox}%
{\nointerlineskip\vskip-0.5pt}%
\usebeamerfont{block body}%
\begin{beamercolorbox}[wd=\textwidth, leftskip=0.2cm]{block body}%
\vskip-.75ex\vbox{}%
}
\setbeamertemplate{block end}{
\end{beamercolorbox}
\vspace*{.25cm}
}
\setbeamertemplate{frametitle}{
\vspace*{0.3cm}
\begin{beamercolorbox}[wd=\textwidth, dp=0.3cm, ht=0.9cm, leftskip=0.2cm]{frametitle}
\usebeamerfont{frametitle}\insertframetitle%
\end{beamercolorbox}
}
\setbeamercolor{block title}{bg=yellow}
\setbeamercolor{frametitle}{bg=yellow}
\begin{document}
\begin{frame}{Block}
This is text before the block.
\begin{block}{blocktitle} some text here
\begin{itemize}
\item This is an item in the block.
\end{itemize}
This is text after the itemize.
\end{block}
This is text after the block.
\end{frame}
\end{document}