[Tex/LaTex] How to customize block in Beamer

beamerblockgraphics

I want to customize block (alertblock) in Beamer. I want a transparent block, with a red frame and where the title is also in red like the one given in the image below:

Goal(with rounded corners)

MWE:

 \documentclass[12 pt]{beamer}
    \usetheme{default}

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \usepackage[T1]{fontenc} % pour taper les lettres accentues
    \usepackage[latin1]{inputenc}
    \usepackage[frenchb]{babel}
    \usepackage[babel=true]{csquotes} % csquotes va utiliser la langue dÈfinie dans babel
    \frenchbsetup{StandardLists=true}


    %%%%%%%%%%
    % FONTS %
    %%%%%%%%%%

    %% Default font: lmodern, doesn't require fontspec % solves some default warnings
    %\usepackage[T1]{fontenc}
    %\usepackage{lmodern}           
    %\usepackage{sfmath}        % Sans Serif Math, off by default

    %% Protects fonts from Beamer screwing with them
    %% http://tex.stackexchange.com/questions/10488/force-computer-modern-in-math-mode
    \usefonttheme{professionalfonts}

    %% XeLaTeX fonts: (comment out if you don't use XeLaTeX)

    %% For advanced fonts: access local OS X fonts
    \usepackage[no-math]{fontspec}      
    %% This template uses typical OS X and Adobe fonts
    \defaultfontfeatures{Mapping=tex-text}  % This seems to be important for mapping glyphs properly

    \setmainfont{Chalkboard}            % Beamer ignores "main font" in favor of sans font
    \setsansfont{Chalkboard}            % This is the font that beamer will use by default
    % \setmainfont{Gill Sans Light}     % Prettier, but harder to read

    \setbeamerfont{title}{family=\fontspec{Chalkduster}}


    %\newcommand{\handwriting}{\fontspec{augie}} % From Emerald City, free font
    % \newcommand{\handwriting}{}   % If you prefer no special handwriting font or don't have augie

    %% Gill Sans doesn't look very nice when boldfaced
    %% This is a hack to use Helvetica instead
    %% Usage: \textbf{\forbold some stuff}
    %\newcommand{\forbold}{\fontspec{Helvetica}}
    % \newcommand{\forbold}{} % if you want no special boldface



    %%%%%%%%%%%%%%%%%%%%%%%%
    % Usual LaTeX Packages %
    %%%%%%%%%%%%%%%%%%%%%%%%
    \usepackage{unicode-math}
    \setmathfont[math-style=upright]{Neo Euler}


    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{graphicx}
    \usepackage{mathrsfs}           % For Weinberg-esque letters
    \usepackage{cancel}             % For "SUSY-breaking" symbol
    \usepackage{slashed}            % for slashed characters in math mode
    \usepackage{bbm}                % for \mathbbm{1} (unit matrix)
    \usepackage{amsthm}             % For theorem environment
    \usepackage{multirow}           % For multi row cells in table
    \usepackage{arydshln}           % For dashed lines in arrays and tables
    %\usepackage{tikzfeynman}       % For Feynman diagrams
    \usepackage{wasysym}
    \usepackage{pifont}
    \usepackage{ifsym}
    %\usepackage{bbding}
    % \usepackage{subfig}           % for sub figures
    % \usepackage{young}            % For Young Tableaux
    % \usepackage{xspace}           % For spacing after commands
    % \usepackage{wrapfig}          % for Text wrap around figures
    % \usepackage{framed}


    %\graphicspath{{images/}}   % Put all images in this directory. Avoids clutter.


    %\usetikzlibrary{backgrounds}
    %\usetikzlibrary{mindmap,trees} % For mind map
    % http://www.texample.net/tikz/examples/computer-science-mindmap/
    %\setbeamertemplate{background canvas}{\includegraphics [width=\paperwidth]{blackboard_bk.pdf}}

    %==================%
    \setbeamercolor{normal text}{fg=white}
    \setbeamercolor{alerted text}{fg=red!80}
    \setbeamercolor{structure}{fg=yellow!80}
    \setbeamercolor{frametitle}{fg=green}
    \setbeamercolor{title}{fg=white}
    \setbeamertemplate{blocks}[shadow=false]
    \setbeamercolor{block body}{fg=normal text.bg!90!black}
    \setbeamercolor{block body example}{bg=normal text.bg!90!black}
\begin{document}    
    \begin{frame}{Test num\'ero 2}
    \begin{block}{Un bloc normal}
      Texte du block 
     \end{block}

     \begin{alertblock}{Un bloc tr\`es alerte}
      Texte du block 
     \end{alertblock}

     \begin{exampleblock}{Un bloc exemplaire}
      Exemple de block 
     \end{exampleblock}
    \end{frame}

    \end{document}

Best Answer

You can use the tcolorbox package:

\documentclass{beamer}
\usepackage{tcolorbox}

\newtcolorbox{mybox}[1][Theorem:]{
colback=white,
colbacktitle=white,
coltitle=red!70!black,
colframe=red!70!black,
boxrule=1pt,
titlerule=0pt,
arc=15pt,
title={\strut#1}
}

\begin{document}

\begin{frame}
\begin{mybox}
test
\end{mybox}
\begin{mybox}[Proposition:]
test
\end{mybox}
\end{frame}

\end{document}

enter image description here

And adding the beamer skin:

\documentclass{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcolorbox{mybox}[1][Theorem:]{
beamer,
colback=white,
colbacktitle=white,
coltitle=red!70!black,
colframe=red!70!black,
boxrule=1pt,
titlerule=0pt,
arc=15pt,
title={\strut#1}
}

\begin{document}

\begin{frame}
\begin{mybox}
test
\end{mybox}
\begin{mybox}[Proposition:]
test
\end{mybox}
\end{frame}

\end{document}

enter image description here

In a comment it has been requested to reduce the separation between title and contents; this can be done using middle and boxsep; I also set the frame color to white and used borderline to produce the frame:

\documentclass{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcolorbox{mybox}[1][Theorem:]{
beamer,
colback=white,
colbacktitle=white,
coltitle=red!70!black,
colframe=white,
boxrule=1pt,
titlerule=0pt,
arc=15pt,
middle=0pt,
boxsep=0pt,
borderline={0.5pt}{0pt}{red},
title={\strut#1}
}

\begin{document}

\begin{frame}
\begin{mybox}
test
\end{mybox}
\begin{mybox}[Proposition:]
test
\end{mybox}
\end{frame}

\end{document}

enter image description here

A new request in a comment is to be able to add an eventual annotation to the environments (in a fashion similar to the optional argument of the structures defined with \newtheorem using amsthm or ntheorem). In this case, I think is better to use a style and \newtcbtheorem:

\documentclass{beamer} 
\usepackage{tcolorbox} 
\tcbuselibrary{skins,theorems}

\tcbset{
mybox/.style={
  beamer,
  colback=white,
  colbacktitle=white,
  coltitle=red!70!black,
  colframe=white,
  boxrule=1pt,
  titlerule=0pt,
  arc=15pt,
  middle=0pt,
  boxsep=0pt,
  borderline={0.5pt}{0pt}{red},
  theorem name,
  description delimiters=(),
  title={\strut#1}
  }
}
\newtcbtheorem{theo}{Theorem}{mybox}{thm}
\newtcbtheorem{prop}{Proposition}{mybox}{pro}

\begin{document}

\begin{frame}

\begin{theo}{}{testa}
test
\end{theo}
\begin{theo}{Fundamental theorem of algebra}{testb}
test
\end{theo}
\begin{prop}{}{testc}
test
\end{prop}
\begin{prop}{Some important proposition}{testc}
test
\end{prop}

\end{frame}

\end{document}

enter image description here

Notice the special way in which each theorem environment is invoked using three mandatory arguments: the first one for the name used to define the structure; the second one for the eventual annotation and the third one for a label for eventual cross-references. Since they are mandatory arguments, you have to use them always, even if empty, so

\begin{prop}{}{}
test
\end{prop}

and not just

\begin{prop}
test
\end{prop}