4

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

enter image description here

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?

3

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}

\setbeamertemplate{blocks}[rounded][shadow]
\setbeamercolor{block title}{fg=blue!70!black,bg=white}
\setbeamercolor{block body}{bg=white}

\makeatletter
\pgfdeclareverticalshading{bmb@transition}{200cm}{%
  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}

enter image description here

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}
\setbeamertemplate{blocks}[rounded][shadow]
\usetikzlibrary{shadings,shadows}

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

\makeatletter
\pgfdeclareverticalshading{bmb@transition}{200cm}{%
  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,
  fuzzy shadow={0.6ex}{-0.6ex}{1pt}{0.5pt}{black!80!white},
  #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}

enter image description here

  • 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

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.