[Tex/LaTex] Add an image on the top-left corner of a customized block in beamer

beamerblockenvironments

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 :

enter image description here

enter image description here

enter image description here

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?

Best Answer

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}

enter image description here