10

I would like to create a block in Beamer exactly as the one illustrated below. Does someone know how to do it?

enter image description here

15

I don't know which fonts do you use and I made the example for pdflatex so, you'll have to adapt to xetex. But the box is quite similar to the one you want. It's made with tcolorbox.

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\tcbuselibrary{skins}

\newtcolorbox{myblock}[1]{
    enhanced,
    frame hidden, interior hidden, segmentation hidden,
    coltitle=black,
    fonttitle=\bfseries\rmfamily,
    fontupper=\tiny,
    title={#1},
    overlay unbroken={\draw[gray,line width=1pt] (frame.north west) rectangle (frame.south east);
    \draw[gray,line width=1pt] ([xshift=5mm]interior.north west)--([xshift=-5mm]interior.north east);
    \shade (frame.south west)--++(0,-1mm)--(frame.south)--cycle;
    \shade (frame.south east)--++(0,-1mm)--(frame.south)--cycle;}
    }

\begin{document}
\begin{frame}{A nice box for beamer}

\begin{myblock}{Oups, nous avons rencontré une erreur.}
Note partagée non trouvée

L'URL fornie ne correspond pas à une note partagée valide. Cela a pu être causé par une erreur typographique dans le lien, ou le propiétaire l'a privaisée.
\end{myblock}
\end{frame}
\end{document}

enter image description here

2nd version

tcolorboxes width is textwidth by default, you can change its size, but if you want to use boxes adjusted to their contents, you need tcboxes.

tcbox width is determined by its text width, if title is longer than text then it's automatically wrapped. \newtcbox creates a command, while \newtcolorbox defines a new environment.

Next code shows how to adapt previous box to be used as tcbox. Previous box is slightly modified, now it uses 2 parameters being the first one optional. It can be used to modify some of default style parameters, like margins. And because margins can change, also middle line is drawn according default or changed margins.

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\tcbuselibrary{skins}

\makeatletter
\newtcolorbox{myblock}[2][]{
    enhanced,
    frame hidden, interior hidden, segmentation hidden,
    coltitle=black,
    fonttitle=\bfseries\rmfamily,
    fontupper=\tiny,
    title={#2},
    overlay unbroken={\draw[gray,line width=1pt] (frame.north west) rectangle (frame.south east);
    \draw[gray,line width=1pt] ([xshift=\kvtcb@lefttitle+\kvtcb@boxsep]interior.north west)--([xshift=-(\kvtcb@righttitle+\kvtcb@boxsep)]interior.north east);
    \shade (frame.south west)--++(0,-1mm)--(frame.south)--cycle;
    \shade (frame.south east)--++(0,-1mm)--(frame.south)--cycle;},
    #1
    }

\newtcbox{mybox}[2][]{
      enhanced,
      frame hidden, interior hidden, segmentation hidden,
    coltitle=black,
    fonttitle=\bfseries\rmfamily,
    fontupper=\tiny,
    title={#2},
    overlay unbroken={\draw[gray,line width=1pt] (frame.north west) rectangle (frame.south east);
    \draw[gray,line width=1pt] ([xshift=\kvtcb@lefttitle+\kvtcb@boxsep]interior.north west)--([xshift=-(\kvtcb@righttitle+\kvtcb@boxsep)]interior.north east);
    \shade (frame.south west)--++(0,-1mm)--(frame.south)--cycle;
    \shade (frame.south east)--++(0,-1mm)--(frame.south)--cycle;},
    #1
    }
\makeatother

\begin{document}
\begin{frame}{A nice box for beamer}

\begin{myblock}{Oups, nous avons rencontré une erreur.}
Note partagée non trouvée

L'URL fornie ne correspond pas à une note partagée valide. Cela a pu être causé par une erreur typographique dans le lien, ou le propiétaire l'a privaisée.
\end{myblock}

\mybox{Oups, this is a long title}{Note partagée non trouvée}
\mybox[left=0mm,right=1cm]{Oups}{Note partagée non trouvée}
\end{frame}
\end{document}

enter image description here

Note Since tcolorbox 3.05 lifted shadows are possible as a tcolorbox option. Some examples are shown in Lifted or curved drop shadow

  • Is it possible to this block to adapt its length to the content? – Cybernetician May 27 '14 at 15:59
  • @Humberto I think so, use newtcbox instead of newtcolorbox. I cannot test it now, I'll do asap. – Ignasi May 27 '14 at 16:54
  • Thank you for you answer Ignasi, but \newtcbox does not work. Is it possible to reduce the margins inside the block? – Cybernetician May 28 '14 at 7:25
  • @Humberto, tcbox are commands not environment. Take a look at updated answer. – Ignasi May 28 '14 at 8:44
  • @Humberto, May be you want to look at tex.stackexchange.com/q/180431/1952 where simimlar shadows are applied – Ignasi May 28 '14 at 8:46

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.