6

I am trying to define a type of table similar to the look-and-feel of beamer blocks. I tried the following (using the tabu for tables), but with no luck.

\newenvironment<>{tabvarblock}[2][.9\textwidth]{%
%\setlength{\textwidth}{#1}
\begin{actionenv}#3%
    \def\insertblocktitle{#2}
    \begin{tabu}to#1{\insertblocktitle}%
    \usebeamertemplate{block begin}}
{\end{tabu}%
\usebeamertemplate{block end}%
\end{actionenv}}

The use of the new structure would be, something like

\begin{tabvarblock}[0.5\textwidth]{X[m]X[m]}
A & B \NN
C & D \NN
\end{tabvarblock}

I also tried to use the solution in Example of fancy table using TikZ package. It worked, however the look-and-feel is not exactly the same.

4
  • related (?) beamer-style-text-box/
    – cmhughes
    Sep 26, 2012 at 15:33
  • Yes. But the first row in the table would be like would have the same look-and-feel as the block title; while the rest of the table would be like the block body.
    – cacamailg
    Sep 26, 2012 at 15:55
  • I did something like that before but I don't know if it is useful for you. See the edit history of my answer on this question tex.stackexchange.com/questions/67586/…
    – percusse
    Sep 26, 2012 at 15:57
  • The problem is to grab the beamer style. And I want to use tabular-like environment.
    – cacamailg
    Sep 26, 2012 at 17:08

1 Answer 1

5

The first approach is a \newenvironment that mix mdframed and tabular, but the same with tcolorbox instead of mdframed seem easier because this package have a beamer skin option. The first case is a fixed two columns but in the second the columns format is free (the second parameter of the new environment). You can compare both approaches in this MWE:

enter image description here

\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\usetikzlibrary{shadows}
\mdfdefinestyle{MyFrame}{%
    linecolor=gray!50,
    outerlinewidth=0.01em,
    skipabove=.5\baselineskip,
    skipbelow=.5\baselineskip,
    roundcorner=1em, shadow=true,
    leftmargin=.25\textwidth,
    rightmargin=.25\textwidth,
    innertopmargin=1ex,
    innerbottommargin=.5\baselineskip,
    innerrightmargin=1em,
    innerleftmargin=1em,
    backgroundcolor=yellow!05!white,
    frametitlerule=true,
    frametitlerulecolor=blue!40!,
    frametitlebackgroundcolor=blue,
    frametitlerulewidth=0.05em}


\newenvironment{mdbeamer}[1]
{ \begin{mdframed}[style=MyFrame, 
  frametitle={\hfill\color{white}#1\hfill}]
  \centering
  \begin{tabular}{cc}
}
{ \end{tabular}
  \end{mdframed}
}

\usepackage{tcolorbox}
\tcbuselibrary{skins}


\tcbset{colback=yellow!05!white,colframe=blue!95,
width=.5\textwidth,before=\hfill,after=\hfill}


\newenvironment{skinbeamer}[2]
{ 
\begin{tcolorbox}[skin=beamer, adjusted title= \centering #1]
\centering
\begin{tabular}{#2}
}
{ \end{tabular}
  \end{tcolorbox}
}


\begin{document}


\begin{mdbeamer}{My mdframed  table}
A & B \\
C & D \\
\end{mdbeamer}


\begin{skinbeamer}{My tcolorbox table}{|c|c|}
\hline
 A & B \\
\hline
C & D \\
\hline
\end{skinbeamer}

\end{document}
3
  • Thanks. But it is not exactly what I am looking for.
    – cacamailg
    Sep 26, 2012 at 21:06
  • Sorry I haven't seen your second command skinbeamer which can be an approximated solution (with some tweaks for the title behave like a tabular of one line). But how do I remove the background box shadow?
    – cacamailg
    Sep 26, 2012 at 21:32
  • In the first case, change shadow=true by shadow=false . In the second, remove skin=beamer, (the comma also)
    – Fran
    Sep 26, 2012 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .