如何使盒子尺寸一致并将盒子“粘合”在一起(在投影仪中)?

如何使盒子尺寸一致并将盒子“粘合”在一起(在投影仪中)?

我一直在组装一个新的 beamer 模板,但无法解决最后几个问题。下面是一个突出这些问题的最小工作示例(它看起来并不最小,但我觉得它是最小的):

\documentclass{beamer}

\makeatletter
\def\th@mystyle{
    \normalfont 
    \setbeamercolor{block title example}{bg=orange,fg=white}
    \setbeamercolor{block body example}{bg=orange!20,fg=black}
    \def\inserttheoremblockenv{exampleblock}
}

\makeatother
\theoremstyle{mystyle}
\newtheorem{que}{Question}

\usepackage{fontspec}
\setmainfont{Verdana}

\begin{document}

\section{Boxes}

\frame{
\frametitle{Boxes}
\fontspec{Cambria}
\setbeamercolor{postit}{fg=black,bg=orange!20} \begin{beamercolorbox}[rounded=false,shadow=true]{postit} How to inflate these two boxes such that their size... \end{beamercolorbox}
\setbeamercolor{postit}{fg=black,bg=green}
\begin{beamercolorbox}[rounded=false,shadow=true]{postit}...is precisely consistent with that of the third box?\end{beamercolorbox}
~\\
    \begin{que}[About this box]
    How to get such a box with arbitrary content, i.e. basically without it being a kind of theorem/definition? (Right now, the title is at least ``Question ()'')
\end{que}

~\\
\begin{que}[About the font]
How to apply the font change visible in the first two boxes to the whole presentation or at least the whole frame?
\end{que}
}

\end{document}

我现在有三个问题:

  1. 定理框在文本周围留有一些空白,我更喜欢这样。如何调整空白,使所有框都完全一致?

  2. 由于“问题”框对应于定理环境,我无法自由填充我想要的上部(“块标题”)。当然,这在某种意义上相当于将前两个框粘在一起或更改一个框内的颜色设置。我该怎么做?

  3. 我希望这个问题能够轻松修复,但目前为止我发现没有一种方法可以解决这个问题:我希望字体更改能够应用于整个演示文稿(即除标题外的所有文本)。我该怎么做?

答案1

基本问题的答案

我怀疑你真正想知道的是:你可以像这样使用投影仪块

\begin{block}{<block title>}
   <block content>
\end{block}

beamercolorbox是“幕后”的东西 - 如果你并不直接需要它,那么使用 beamer 构造来处理所有的配置 - 这容易得多)

\documentclass{beamer}

\setbeamercolor{block title}{bg=orange,fg=white}
\setbeamercolor{block body}{bg=orange!20,fg=black}

\begin{document}

\begin{frame}
\frametitle{Boxes}
    \begin{block}{How to inflate these two boxes such that their size...}
        ...is precisely consistent with that of the third box?
    \end{block}
\end{frame}

\end{document}

在此处输入图片描述

回答各个子问题

定理框在文本周围留有一些空白,我更喜欢这样。如何调整空白,使所有框都完全一致?

只需使用blocks。由于blocks 具有强制标题,而您的前两个框没有标题,因此\setbeamertemplate{block begin}{...}需要重新定义。

由于“问题”框对应于定理环境,我无法自由填充我想要的上部(“块标题”)。当然,这在某种意义上相当于将前两个框粘在一起或更改一个框内的颜色设置。我该怎么做?

答案仍然是“使用blocks”

我希望这个问题能够轻松修复,但目前为止我发现没有一种方法可以解决这个问题:我希望字体更改能够应用于整个演示文稿(即除标题外的所有文本)。我该怎么做?

如果您\fontspec{Cambria}在演示文稿的开头设置,则所有常规文本都将使用 Cambria 字体,而框架、块等的标题将保留为 Verdana 字体。要更改它们,您可以调整\setbeamerfont{block title}{...}

% !TEX TS-program = xelatex
\documentclass{beamer}

\makeatletter
\def\th@mystyle{
    \normalfont 
    \setbeamercolor{block title example}{bg=orange,fg=white}
    \setbeamercolor{block body example}{bg=orange!20,fg=black}
    \def\inserttheoremblockenv{exampleblock}
}

\makeatother
\theoremstyle{mystyle}
\newtheorem{que}{Question}

\setbeamercolor{block body}{fg=black,bg=orange!20} 
\setbeamercolor{block title}{bg=orange,fg=white} 

\usepackage{xstring}

\setbeamertemplate{block begin}
{
  \par\vskip\medskipamount%
  \IfStrEq{\insertblocktitle}{}{}{
      \begin{beamercolorbox}[colsep*=.75ex]{block title}
        \usebeamerfont*{block title}\insertblocktitle%
      \end{beamercolorbox}%
  }
  {\parskip0pt\par}%
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
    \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}

\usepackage{fontspec}
\setmainfont{Verdana}


\begin{document}
\fontspec{Cambria}

\section{Boxes}

\begin{frame}
\frametitle{Boxes}

\begin{block}{} 
        How to inflate these two boxes such that their size... 
\end{block}

{
    \setbeamercolor{block body}{fg=black,bg=green} 
    \begin{block}{} 
        precisely consistent with that of the third box? 
    \end{block}
}

\begin{block}{About this box}
  How to get such a box with arbitrary content, i.e. basically without it being a kind of theorem/definition? (Right now, the title is at least ``Question ()'')
\end{block}

\end{frame}

\end{document}

在此处输入图片描述

相关内容