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

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}
  • @cdavidshaffer You're welcome! – user36296 May 26 '18 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.