# Add an image on the top-left corner of a customized block in beamer

I would like to use some customized blocks in my beamer presentations, with a layout that is inspired by these examples found on a website :

The idea is to build a specific block environments, like \begin{carefullBlock}... for the first one, \begin{questionBlock}...for the second one, and \begin{informationBlock}... for the second one, in order to display a block with the same general layout as standard blocks, but without a title line, only text inside, and the corresponding image on the left corner. The best would be that the left border of these blocks should be aligned with standard blocks. So the image should exceed the left margin a little bit.

Does anyone know how to do it?

• The requirement about alignment of left margins will probably cause the image either to be too small or to have some portion out of the frame; block in most themes are almost as wide aas the full \paperwidth. – Gonzalo Medina Feb 6 '14 at 14:08
• Yeah, I thought so. But it really is an 'icing on the cake' requirement. So it's not a big deal if it's not possible. – BonyHoax Feb 6 '14 at 14:13
• bclogo package also creates boxed environments with a logo it its upper left corner. – Ignasi Feb 7 '14 at 10:08

One possibility using the tcolorbox package and its beamer skin:

\documentclass{beamer}
\usetheme{Copenhagen}
\usepackage{tcolorbox}
\tcbuselibrary{most}

\setbeamercolor{myblock}{bg=cyan!20}
\pgfdeclareimage[width=20pt]{em}{em.png}
\pgfdeclareimage[width=20pt]{qm}{qm}
\pgfdeclareimage[width=20pt]{st}{st}

\newtcolorbox{eblock}{
beamer,
enhanced,
colback=olive!50,
overlay={\node at (frame.north west) {\pgfuseimage{em}};}
}
\newtcolorbox{qblock}{
beamer,
enhanced,
overlay={\node at (frame.north west) {\pgfuseimage{qm}};}
}
\newtcolorbox{sblock}{
beamer,
enhanced,
colback=cyan!50,
overlay={\node at (frame.north west) {\pgfuseimage{st}};}
}

\begin{document}

\begin{frame}

\begin{eblock}
test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{eblock}\vfill

\begin{qblock}
test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{qblock}\vfill

\begin{sblock}
test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
\end{sblock}
\end{frame}

\end{document}


• It looks great, but could it be possible to overlap the corner with the center of the image? – BonyHoax Feb 6 '14 at 15:02
• Oh, I just realized you simply have to ajust the value of \makeboxand \raiseboxdepending on the size of the image. Everything is then just fine. – BonyHoax Feb 6 '14 at 15:56
• My last issue is with the setting of the bg color for each types of blocks. I don't know where to put what... I tried to put \setbeamercolor{block body}{fg=black,bg=olive!50}`inside the block, but it has no effect. – BonyHoax Feb 6 '14 at 16:07
• @BonyHoax I've changed the approach, using this time tcolorbox; now you can easily adjust the position for the images and also set colors. – Gonzalo Medina Feb 6 '14 at 16:14
• Yeah, I just found out, so I deleted my comment :) – BonyHoax Feb 6 '14 at 18:06