beamer add tag
JeT
Based on https://tex.stackexchange.com/questions/547207/how-to-wrap-a-frame-in-a-tcolorbox-when-using-modearticle?noredirect=1#comment1382274_547207 where a cat/marmot advised me to post my question here.

**My question**

How do I wrap the frame environment in beamer to have it in a tcolorbox in \mode<article> ? (and not just the title as below)

![Beamerarticle.png](/image?hash=f924ea89d37d8af2a7a858d51803bbb2f7b5935fe1a13c940408b7a6bcc38759)  
  
**Context**

I use `beamer` and `beamerticle`.

I'd like to highlight the frames in a `tcolorbox` when I use `\mode<article>`. It enables me to see what is in the notes vs the shorter version that should be in the frames.

I understand I need to change the `\setbeamertemplate` with the right `key` for the frame environment. I'd like what's in the frame to be a wrapped in a `tcolorbox` in `\mode<article>` (not just the title as in MWE with an error).

I'd like also to have the Title(+Subtitle) as the title of the `tcolorbox`.

MWE

```
\documentclass[11pt]{article}
\usepackage{xcolor}
\usepackage[envcountsect]{beamerarticle}
\usepackage{tcolorbox}

\mode<article>
{
\setbeamertemplate{frame begin}{%
    \begin{tcolorbox}[
            colback=red!20,
            colframe=red!60,
            arc=4mm,
            title={\insertframetitle \emph{\insertframesubtitle}},
            coltitle=red!50!black, 
            fonttitle=\bfseries\scshape,
            detach title,
            before upper={\tcbtitle\par}
            ]
            }%
\setbeamertemplate{frame end}{\end{tcolorbox}}
}

\begin{document}

\begin{frame}
    {Title of the frame}
    {Subtitle of the frame}

    \begin{itemize}
        \item first
        \item Second
        \item third
    \end{itemize}

\end{frame}

\end{document}
```

  
  
Top Answer
samcarter
You can wrap the whole frame in tcolorbox like in the following code. Instead trying to figure out how to get the frametitle into the title, I suggest to format the frametitle template the same as the tcolorbox title would look like.

```
\documentclass[11pt]{article}
%\documentclass{beamer}
\usepackage{xcolor}
\usepackage[envcountsect]{beamerarticle}
\usepackage{tcolorbox}

\makeatletter
\mode
<article>
{

  \def\beamer@dosingleframe{%
    \bgroup%
    \beamer@inframetrue%
    \let\frame=\framelatex
    \begin{tcolorbox}[
                colback=red!20,
                colframe=red!60,
                arc=4mm,
                ]
    \usebeamertemplate{frame begin}%
    \bgroup\aftergroup\beamer@endframe%
    \beamer@article@startframe}%
  \def\beamer@endframe{%
    \end{tcolorbox}\usebeamertemplate{frame end}\egroup}
    
  \setbeamertemplate{frametitle}{{\color{red!50!black}\bfseries\insertframetitle~\emph{\insertframesubtitle}}}
}

\makeatother

\begin{document}


\begin{frame}
    \frametitle{Title of the frame}
    \framesubtitle{Subtitle of the frame}

    \begin{itemize}
        \item first
        \item Second
        \item third
    \end{itemize}

\end{frame}

\end{document}
```  
Answer #2
Skillmon
The following should work most of the time (and if it doesn't, you can blame @samcarter, she said it should work):  
  
```  
\documentclass[11pt]{article}
\usepackage{xcolor}
\usepackage[envcountsect]{beamerarticle}
\usepackage{tcolorbox}

\usepackage{xparse}
\RenewDocumentEnvironment{frame}{d<>ooG{}G{}}
  {%
    \begin{tcolorbox}[
            colback=red!20,
            colframe=red!60,
            arc=4mm,
            title={#4 \emph{#5}},
            coltitle=red!50!black, 
            fonttitle=\bfseries\scshape,
            detach title,
            before upper={\tcbtitle\par}
            ]%
  }
  {\end{tcolorbox}}

\begin{document}

\begin{frame}
    {Title of the frame}
    {Subtitle of the frame}

    \begin{itemize}
        \item first
        \item Second
        \item third
    \end{itemize}

\end{frame}

\end{document}
```
Answer #3
marmot
This is more or less entirely stolen from @samcarters nice answer. The only point is to show how redefining `\frametitle` can help. 

```
\documentclass[11pt]{article}
%\documentclass{beamer}
\usepackage[envcountsect]{beamerarticle}
\usepackage{tcolorbox}
\newtcolorbox{beamerframebox}[1][]{%
			colback=red!20,
            colframe=red!60,
            arc=4mm,
            coltitle=red!50!black, 
            fonttitle=\bfseries,
            detach title,
            before upper={\tcbtitle\par\medskip\noindent},
			#1}
\makeatletter
\newsavebox\BeamerFrameB@x
\newif\ifFrame@hasTitle
\newif\ifFrame@hasSubTitle
\tcbset{frame@title/.code={\ifFrame@hasTitle
\ifFrame@hasSubTitle
\tcbset{title=\@gtempa}%
\else
\tcbset{title=\@gtempa\par\emph{\@gtempb}}%
\fi\fi}}
%
\mode
<article>
{
  \def\beamer@dosingleframe{%
    \bgroup%
    \beamer@inframetrue%
    \let\frame=\framelatex
	\renewcommand\frametitle[1]{\global\Frame@hasTitletrue\gdef\@gtempa{##1}\relax}%
	\renewcommand\framesubtitle[1]{\global\Frame@hasTitletrue\gdef\@gtempb{##1}\relax}%
    \begin{lrbox}\BeamerFrameB@x%
	\begin{minipage}{\dimexpr\linewidth-1.5cm}\usebeamertemplate{frame begin}%
    \bgroup\aftergroup\beamer@endframe%
    \beamer@article@startframe}%
  \def\beamer@endframe{%
  	\global\setbox\BeamerFrameB@x\box\BeamerFrameB@x%
	\end{minipage}%
    \end{lrbox}%
	\begin{beamerframebox}[frame@title]
	\usebox\BeamerFrameB@x%
	\end{beamerframebox}%
	\usebeamertemplate{frame end}\egroup}
}

\makeatother

\begin{document}


\begin{frame}
\frametitle{Title of the frame}
\framesubtitle{Subtitle of the frame}

    \begin{itemize}
        \item first
        \item Second
        \item third
    \end{itemize}

\end{frame}

\end{document}
```

![Screen Shot 2020-05-31 at 1.15.26 PM.png](/image?hash=58193a36ff642946b0c77659f0fd69d52926691943e0bd9bafd5dd39aafd8e2e)

If you comment out 

```
detach title,
before upper={\tcbtitle\par\medskip\noindent},
```

you will get

![Screen Shot 2020-05-31 at 1.16.21 PM.png](/image?hash=1e1cfaf72d11ec11a105e871db7dd05b9d6857c9b15c766b86a62f9ce717a89c)

The only point is to show that you can, at least in principle, translate macros like `\frametitle` into keys of e.g. `tcolorbox`.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.