# How can add a line to block environment in Beamer?

I would like to define a block environment as illustrated in the figure in the link

I made this block using the code

\begin{block}{My title\\ \vspace{-1.25em} \line(1,0){312}}\vspace{-0.7em}

teste
\end{block}

Does someone knows how to do that? BTW, how can I change the title font using XeLaTeX?

Internally, beamer uses the shading bmb@transition to add some color between the title and the body parts of a block. You can redefine this shading to produce a solid color:

\documentclass{beamer}

\setbeamercolor{block title}{fg=blue!70!black,bg=white}
\setbeamercolor{block body}{bg=white}

\makeatletter
color(0pt)=(blue!70!black); color(2pt)=(blue!70!black)}
\makeatother

\begin{document}

\begin{frame}
\begin{block}{My Title}
Test text.
\end{block}
\end{frame}

\end{document}

In the code above, the line width will be equal to the block width. If one wants the rule width to equal the width of the text inside the block, a different approach is necessary; in this case, the tcolorbox package can be used with its beamer skin, to produce a block having the same specifications as a beamer block, and then one can easily add the rule with the desired specifications.

A little example, comparing both approaches: a standard beamer block (rule width=block width), and a Bblock produced with the help of tcolorbox (rule width=text width):

\documentclass{beamer}
\usepackage[most]{tcolorbox}

\setbeamercolor{block title}{fg=blue!70!black,bg=white}
\setbeamercolor{block body}{bg=white}

\makeatletter
color(0pt)=(blue!70!black); color(2pt)=(blue!70!black)}
\makeatother

\newtcolorbox{Bblock}[2][]{
beamer,
equal height group=beamer,
colback=white,
colframe=white,
coltitle=blue!70!black,
fonttitle=\normalfont\large,
oversize,
overlay={
\draw[blue!70!black,ultra thick]
([xshift=6pt,yshift=-0.5\pgflinewidth]title.south west) --
([xshift=-6pt,yshift=-0.5\pgflinewidth]title.south east);},
left=1mm,
right=1mm,
top=1mm,
bottom=1mm,
middle=1mm,
#1,title=#2}
\makeatletter
\tikzset{beamer@color/.style={top color=white,bottom color=white}}
\makeatother

\newcommand\Text{%just for the example
Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel justo
vitae lacus tincidunt ultrices. Lorem ipsum dolor sit amet, con-
sectetuer adipiscing elit. In hac habitasse platea dictumst. Integer
tempus convallis augue. Etiam facilisis. Nunc elementum fermen-
tum wisi.}

\begin{document}

\begin{frame}
\begin{block}{My Title}
\Text
\end{block}

\begin{Bblock}{My Title}
\Text
\end{Bblock}
\end{frame}

\end{document}

• Thank you Medina, Since the line starts before the texts, isn't possible to use \noindent inside the block, in order to align the text and the line? – Cybernetician Jul 2 '13 at 16:33
• @Humberto The line begins where the block does; the line goes from the left end of the block to the right end of the block; on the other hand, \noindent has no effect here. – Gonzalo Medina Jul 2 '13 at 17:06
• @Humberto having a line whose width equals the text width (instead of the block width) can be done, but requires a different approach. In some hours (I have to leave now) I can add this new approach. – Gonzalo Medina Jul 2 '13 at 17:12