How to make box sizes consistent and "glue" boxes together (in beamer)?

I have been putting together a new beamer template and cannot solve a few last problems. A minimal working example that highlights these problems is the following (it doesn't look minimal but I feel it is):

\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}
~\\
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}

~\\
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}


I now have three questions:

1. The theorem boxes include some margin around the text, which I prefer. How can I adapt the margins so that all boxes are perfectly consistent?

2. Since the "Question"-boxes correspond to theorem-environments, I cannot freely fill the upper part ("block title"), which I would like. Of course, this would in some sense be equivalent to glueing together the first two boxes or change color settings within one box. How can I do that?

3. I would expect this to be easily fixed, but nothing I found so far did the job: I'd like the font change to apply to the whole presentation (i.e. all text except titles). How can I do that?

• Welcome to TeX.SX! Jul 12, 2017 at 12:57
• Your code defines a new theorem style which uses the beamer environment exampleblock. It seems what you want to do is to directly use this environment ? (or directly the block environment?) For the font issue, I believe a quick look at the fontspec package documentation would solve your problem. Jul 12, 2017 at 13:02
• @TonioElGringo, thank you. Well, I would like to use this environment for theorems and the like, but I'm open to any other construction that works for the inflation problem and/or the glueing problem. Jul 12, 2017 at 13:09

I suspect what you really want to know: You can use beamer blocks like this

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


(beamercolorbox is something for "behind the scenes" - if you don't really need it directly, use the beamer constructs that will take care of all the configuration - that's much easier)

\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}


The theorem boxes include some margin around the text, which I prefer. How can I adapt the margins so that all boxes are perfectly consistent?

simply use blocks. As blocks have a mandatory title and your first two boxes had no title, \setbeamertemplate{block begin}{...} needs to be redefined.

Since the "Question"-boxes correspond to theorem-environments, I cannot freely fill the upper part ("block title"), which I would like. Of course, this would in some sense be equivalent to glueing together the first two boxes or change color settings within one box. How can I do that?

Again the answer is "use blocks"

I would expect this to be easily fixed, but nothing I found so far did the job: I'd like the font change to apply to the whole presentation (i.e. all text except titles). How can I do that?

If you set \fontspec{Cambria} at the beginning of your presentation all the normal text will be in Cambria, the titles of frames, blocks etc. will remain Verdana. To change them, you can adjust \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}
}

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 ()'')

• @Mau314 From looking up the original definition in the beamer source code - but I don't think you need to know them :) The redefinition of \setbeamertemplate{block begin}{...} is just in the code so that the first two blocks can be without title - not sure if you really need the first two blocks or if you just asked in preparation of your "gluing together" idea. Jul 12, 2017 at 13:38