1

I am using beamerarticle and want to put a box around the content between frames and only when there is really content. Is that possible? I tried it with mdframes package quite symmetric to Framing \frame using mdframed with beamerarticle but did not succeed as I got errors on compilation.

\documentclass[a4paper,12pt]{article}
\usepackage{beamerarticle}
\usepackage{mdframed}

\mode<article>{ \setbeamertemplate{frame begin}{\end{mdframed}} \setbeamertemplate{frame end}{\begin{mdframed}} }

\begin{document}

\begin{frame} \frametitle{testframe} content for testframe \end{frame}

lalala interframetext

\begin{frame} \frametitle{testframe} content for testframe \end{frame}

\end{document}

Arne
  • 1,305

1 Answers1

1

Two problems:

  • the timing of your templates is wrong. The frame begin and frame end templates are executed when the frame environment has already began/is still going. This will create kind of a chain link between your mdframe and beamer's frame environments. You have to open and close your mdframe before or after the beamer frame.

  • you also have to consider the edge cases, e.g. the first \begin{frame} which tries to close an environment which was never opened and the last \end{frame} which also creates an mdframe which is never closed.


%\documentclass{beamer}

\documentclass[a4paper,12pt]{article} \usepackage{beamerarticle} \usepackage{mdframed}

\mode<article>{ \AfterEndEnvironment{frame}{\begin{mdframed}} \BeforeBeginEnvironment{frame}{\end{mdframed}} }

\begin{document}

\mode<article>{\begin{mdframed}} \begin{frame} \frametitle{testframe} content for testframe \end{frame}

lalala interframetext

\begin{frame} \frametitle{testframe} content for testframe \end{frame} \mode<article>{\end{mdframed}}

\end{document}

  • Okay, agreed, I did use the timing in a wrong way. Yet, I was wondering if you can in some way automatically detect, whether there is content in between? But probably it is the best way, as you suggested at https://tex.stackexchange.com/questions/659402/beamerarticle-and-includeonlylecture?noredirect=1#comment1640716_659402, to use just explicit mdframed whenever I have text there... – Arne Sep 25 '22 at 11:41