5

For a beamer presentation, I would like to enclose text in a box such that:
- all the line of the box are blank,
- except the upper left corner, and the lower right corner of the box which are color X.

\begin{\mybox}{blue}
     Some text here
\end{\mybox}

box example

(I made this example by hand, the text doesn't have to be centered).

I saw some examples where the box lines all have the same color.
But I don't see how to adapt them.

1 Answer 1

6

Here's one possible solution using the ubiquitous \tikzmark; in fact, this is a variation of a decoration that I use in some of my presentations; the new environment cblock has an optional argument allowing to change the color used:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\definecolor{pbblue}{HTML}{0A75A8}
\definecolor{pborange}{HTML}{F57E0F}

\newcommand\tikzmark[1]{\tikz[overlay,remember picture] \coordinate (#1) {};}
\newlength\mylinewd% the length used for the lines
\setlength\mylinewd{30pt}

\def\decorateblock#1{%
  \setbeamertemplate{block begin}{%
    \tikzmark{start}\par{\usebeamercolor{#1}\insertblocktitle}\par}
  \setbeamertemplate{block end}{%
    \tikzmark{end}\par
    \begin{tikzpicture}[remember picture,overlay]
      \coordinate (e) at ($(start)+(-10pt,0)$);
      \coordinate (f) at ($(end)+(\textwidth,0)$);
      \draw[ultra thick,#1] ( $ (e) + (0pt,-\mylinewd) $ ) -- ( $ (e) + (0pt,5pt) $ ) -- ( $ (e) + (\mylinewd,5pt) $ ) ;
      \draw[ultra thick,#1] ( $ (f) + (0pt,\mylinewd) $ ) -- (f) -- ( $ (f) + (-\mylinewd,0pt) $ ) ;
    \end{tikzpicture}%
  }%
}

\newenvironment<>{cblock}[1][pbblue]
  {\decorateblock{#1}\begin{block}}
  {\end{block}}

\begin{document}

\begin{frame}
\begin{cblock}{Example}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{cblock}
\begin{cblock}[pborange]{Example}
text text text text text text text text text text text text text text text text text text text text 
\end{cblock}
\end{frame}

\end{document}

enter image description here

The code needs two runs to stabilize.

1
  • @NicolasEssis-Breton You're welcome! Glad I could help. Mar 29, 2013 at 1:52

You must log in to answer this question.