3

I'd like to mimic beamer's block environment with tcolorbox because the latter seems more flexible to me. I have several box-style environments that I'll ultimately need to create. My first (failed) attempt was to mimic the block environment colors. Code is below.

My consoleBox environment came close but the colors aren't quite right (too dark). I thought the beamer skin might get me beamer colors but, if it does, I'm not sure which colors it is using.

Pointers would be appreciated!

David

\documentclass[aspectratio=169]{beamer}
\usepackage[skins]{tcolorbox}
\usecolortheme{rose}
\newenvironment{consoleBox}
{\usebeamercolor{block title}\usebeamercolor{block body}%
  \begin{tcolorbox}[sharp corners,frame empty,coltitle=block title.fg,%
    colbacktitle=block title.bg,colback=block body.bg,title=Console,%
    boxrule=0.5pt,arc=4pt,left=0pt,right=6pt,top=6pt]}
  {\end{tcolorbox}}
\begin{document}
\begin{frame}
\frametitle{Problem}

  \begin{block}{Console}
    This is the desired appearance.
  \end{block} 

  \begin{consoleBox}
    This is close but not quite right.  The body background is way too
    dark and the title background is a little too dark.
  \end{consoleBox}

  \begin{tcolorbox}[skin=beamer,title=Console]
    This is an attempt with skins...one might think that the beamer
    skin would use the beamer color theme?
  \end{tcolorbox}


\end{frame}
\end{document}
1

1 Answer 1

2

A simplified version of the answer Ignasi already linked to in his comment:

\documentclass[aspectratio=169]{beamer}
\usepackage[skins]{tcolorbox}
\usecolortheme{rose}

\newtcolorbox{consoleBox}[2][]{%
    colbacktitle=structure.fg!20!white, 
    coltitle=structure.fg, 
    colback=block title.bg!40!white,
    title=#2,
    boxrule=0pt,
    sharp corners,
    #1
}  
  
\begin{document}
\begin{frame}
\frametitle{Problem}

  \begin{block}{Console}
    This is the desired appearance.
  \end{block} 

  \begin{consoleBox}{Console}
    This is close but not quite right.  The body background is way too
    dark and the title background is a little too dark.
  \end{consoleBox}

\end{frame}
\end{document}

The code can be further simplified with the new tcolorbox inner theme (https://www.ctan.org/pkg/beamertheme-tcolorbox ). This theme will automatically get the colours, shape, etc. from the theme you are using:

\documentclass[aspectratio=169]{beamer}
\usepackage[skins]{tcolorbox}
\usecolortheme{rose}

\useinnertheme{tcolorbox}

\newtcolorbox{consoleBox}[2][]{%
    title=#2,
    #1
}  

\begin{document}
\begin{frame}
\frametitle{Problem}

  \begin{block}{Console}
    This is the desired appearance.
  \end{block} 

  \begin{consoleBox}{Console}
    This is close but not quite right.  The body background is way too
    dark and the title background is a little too dark.
  \end{consoleBox}

\end{frame}
\end{document}

enter image description here

1

You must log in to answer this question.

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