2

beamer tables

In Table looking like a block, two methods are shown to give tables a look similar to the block environment in the beamer class. Both require that header and content rows are split: the former is put into the argument of \begin{block}, the latter makes the content of that environment. The slightly adapted code is repeated below for convenience.

\documentclass[xcolor=table]{beamer}  
\usetheme{Berlin}  
\setbeamertemplate{blocks}[rounded][shadow=true]
\usepackage{tikz}

% reuse table markup
\mode<article>{
  \usepackage{booktabs}
}
\mode<presentation>{
  \definecolor{TableHeader}{RGB}{38,38,134}
  \definecolor{TableBody}{RGB}{233,233,243}
  \newcommand{\midrule}{\rowcolor{TableBody}}% ≈ \hline
  \newcommand{\toprule}{\rowcolor{TableHeader}}% ≈ \firsthline
  \newcommand{\bottomrule}{}% ≈ \lasthline
}

\begin{document}

%% zebra-striped tables
\rowcolors{1}{}{yellow}

\begin{frame}[t]{Problem: mismatched \texttt{tabular} and \texttt{block} style}
\begin{center}
\begin{tabular}{*2{p{0.45\textwidth}}}
% Header row:
  \toprule
  Left Header Cell & Right Header Cell \\ 
  \midrule
% Content rows:
  \begin{itemize}\item a \item b\end{itemize} &
  \begin{enumerate}\item c \item d \end{enumerate} \\
  e & \alert{f} \\ 
  \bottomrule
\end{tabular}
\end{center}
\begin{block}{Block caption}
  Block contents
\end{block}
\end{frame}

\begin{frame}[t]{Method 1: split \texttt{tabular}}
\begin{block}{% Header row:
\begin{center}
\begin{tabular}{*2{p{0.45\textwidth}}}
  \toprule
  Left Header Cell & Right Header Cell \\    % don’t put \midrule or \hline here
\end{tabular}
\end{center}%
}
% Content rows:
\begin{center}
\begin{tabular}{*2{p{0.45\textwidth}}}
  \midrule
  \begin{itemize}\item a \item b\end{itemize} &
  \begin{enumerate}\item c \item d \end{enumerate} \\
  e & \alert{f} \\ 
  \bottomrule
\end{tabular}
\end{center}
\end{block}
\end{frame}

\begin{frame}[t]{Method 2: aligned TikZ blocks}
\tikzset{blocknode/.style={inner sep=2,text width=0.5\textwidth,below right}}
\begin{block}{\tikz{% Header row:
  \node[blocknode] {Left Header Cell}; 
  \node[blocknode] at (0.5\textwidth,0) {Right Header Cell};
}}% Content rows:
\begin{tikzpicture}
  \node[blocknode] {\begin{itemize}\item a\item b\end{itemize}};
  \node[blocknode] at (0.5\textwidth,0) {\begin{enumerate}\item c\item d\end{enumerate}};
  \node[blocknode] at (0,-2) {e};
  \node[blocknode] at (0.5\textwidth,-2) {\alert{f}};
\end{tikzpicture}
\end{block}
\end{frame}

\end{document}

Implicit table markup

Common tables often use horizontal lines either generated by \*hline or by \*rule if one uses the booktabs package like one should. Usually the header row is bordered by two rules, sometimes the header contains severals rows. At the bottom there maybe is a footer row to indicate sums or similar which is also surrounded by horizontal lines. There hardly ever is another line necessary in tables that are simple enough to appear in screen presentations.

% vertically structured table
\begin{tabular}{…}
\firsthline
Header rows \\
\hline
Content rows \\
\hline
Footer rows \\
\lasthline
\end{tabular}
% … with booktabs.sty
\begin{tabular}{…}
\toprule
Header rows \\
\midrule
Content rows \\
\midrule
Footer rows \\
\bottomrule
\end{tabular}

Questions

In dual-use (\mode switch) documents that shall be used for generating a presentation and a print handout (but also in general):

  1. Can one reuse this implicit table markup to get tables just look like blocks without actually wrapping each one inside another environment?
    1. block (after being split up)
    2. tikzpicture
  2. Should one better introduce semantic markup for tabular structures?

Complication 1: Sum rows should also get a different background color and – depending on theme – rounded corners at the bottom left and right.

Complication 2: Zebra striping (\rowcolors) and manual row highlighting (either \hline/midrule or \rowcolor) should work. So the TikZ solution is probably out.

closed as unclear what you're asking by user36296, Stefan Pinnow, Mensch, yo', Mico Sep 26 '16 at 16:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.