2

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

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?

3
  • Welcome to TeX.SX!
    – Bobyandbob
    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.
    – Mau314
    Jul 12, 2017 at 13:09

1 Answer 1

1

Answer to the basic problem

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}

enter image description here

Answer the individual sub-questions

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

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

enter image description here

5
  • Great, thank you very much. May I ask how you know the appropriate parameter values for the blocks, i.e. for colsep and so on?
    – Mau314
    Jul 12, 2017 at 13:20
  • @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
  • I see. Both is right. I'm sure at some point I will use blocks like the first two, but I also suspected it would lead to gluing.
    – Mau314
    Jul 12, 2017 at 13:40
  • Alright, I see... The standard block environment already has the right dimensions for my 2nd question. Your solution for my first question is very nice and will be useful for sure; the third one as well of course!
    – Mau314
    Jul 12, 2017 at 14:09
  • @Mau314 To summarize the solution: i.stack.imgur.com/J3Nae.png Jul 12, 2017 at 14:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .