3

So I have the table in the following working example.

I used the solution at Column and row padding in tables but still the text inside each cell is not centered vertically …

Besides, I wanted to give it a fancier look like in Beamer table drop shadow but I don't seem to be able to include \rowcolors{1}{RoyalBlue!20}{RoyalBlue!5} when working with \multicolumn, same for the drop shadow.

\documentclass[ignorenonframetext, xcolor={dvipsnames,table}]{beamer}
\mode<presentation> {
\usetheme{Berkeley}
\usecolortheme{dolphin}

\usepackage{multirow}
\usepackage{pbox}
}

\begin{document}
\begin{frame}
\begin{center}
{\small
\begin{tabular}{l|c|c|c|}
    \multicolumn{1}{r}{}
        & \multicolumn{1}{c}{\textbf{\pbox{20cm}{Tissue-specific\\penetrance}}}
        & \multicolumn{1}{c}{\textbf{\pbox{20cm}{Ubiquitous\\penetrance}}}
        & \multicolumn{1}{c}{}\\
    \cline{2-4}
        \textbf{\pbox{20cm}{Tissue-specific\\expression}}
        & \textit{\pbox{20cm}{CLASS 1\\12 genes}}
        & \textit{\pbox{20cm}{CLASS 4\\8 genes}}
        & \textcolor{green!70!black}{20 genes}\\
    \cline{2-4}
        \textbf{\pbox{20cm}{Ubiquitous\\expression}}
        & \textit{\pbox{20cm}{CLASS 3\\32 genes}}
        & \textit{\pbox{20cm}{CLASS 2\\20 genes}}
        & \textcolor{pink}{52 genes}\\
    \cline{2-4}
    \cline{2-4}
        & \textcolor{red!70!black}{44 genes}
        & \textcolor{RoyalBlue}{28 genes}
        & \textbf{\pbox{20cm}{72 genes}}\\
    \cline{2-4}
\end{tabular}
}
\end{center}
\end{frame}
\end{document}
4
  • A few notes beforehand: The \bgroup/\egroup is not needed as the center environment itself already groups its content. The use of \small is wrong. It is a switch so you don’t use \small{<something>} but (to keep it local) {\small <something>}. In this case, though, you could just add \small before \begin{tabular} and it makes the whole table in that size. Jun 24, 2013 at 1:14
  • Thanks for the suggestions! I have just made the changes and edited the question, but now the table looks much more condensed... how could I specify the row height so that the text remains vertically aligned? and how could I specify the color for each row (and the drop shadow)? Many thanks again!
    – DaniCee
    Jun 24, 2013 at 15:12
  • anyone can help? I just need to specify row height... any idea???
    – DaniCee
    Jun 24, 2013 at 17:09
  • no one?? isn't there any way to specify row height?
    – DaniCee
    Jun 24, 2013 at 20:56

4 Answers 4

4

I'd suggest "cals" tables:

\documentclass[ignorenonframetext, xcolor={dvipsnames,table}]{beamer}
\mode<presentation> {
\usetheme{Berkeley}
\usecolortheme{dolphin}
}
\usepackage{cals}

\iffalse
\makeatletter
\let\olderow=\erow
\def\erow{\ht\cals@current@row=1.2cm \olderow}
\let\oldbrow=\brow
\def\browI{\oldbrow\def\cals@bgcolor{RoyalBlue!20}\let\brow=\browII}
\def\browII{\oldbrow\def\cals@bgcolor{RoyalBlue!5}\let\brow=\browI}
\let\brow=\browI
\fi

\begin{document}
\begin{frame}
\begin{center}
\small
\makeatletter
\begin{calstable}


\colwidths{{27mm}{27mm}{28mm}{20mm}}
\brow
\cell{}
\cell{\bfseries Tissue-specific\\penetrance}
\cell{\bfseries Ubiquitous\\penetrance}
\cell{}
\erow
\brow
\cell{\bfseries Tissue-specific\\expression}
\cell{CLASS 1\\12 genes}
\cell{CLASS 4\\8 genes}
\cell{\textcolor{green!70!black}{20 genes}}
\erow
\brow
\cell{\bfseries Ubiquitous\\expression}
\cell{CLASS 3\\32 genes}
\cell{CLASS 2\\20 genes}
\cell{\textcolor{pink}{52 genes}}
\erow
\brow
\cell{}
\cell{\textcolor{red!70!black}{44 genes}}
\cell{\textcolor{RoyalBlue}{28 genes}}
\cell{\bfseries 72 genes}
\erow
\end{calstable}
\end{center}
\end{frame}
\end{document}

The table looks good even without tuning:

Slide with a table

If you want to experiment with row colors and height, change "iffalse" to "iftrue". I have no experience with drop shadows, therefore can't recommend anything.

1

This is sort of in between the no-space in cells of your question and the space found in olpa's answer.

\documentclass[ignorenonframetext, xcolor={dvipsnames,table}]{beamer}
\mode<presentation> {
\usetheme{Berkeley}
\usecolortheme{dolphin}
\usepackage{multirow}
\usepackage[oldsyntax]{stackengine}
}
\begin{document}
\begin{frame}
\begin{center}
{\small
\Sstackgap=2pt%
\def\stackalignment{l}%
\begin{tabular}{l|c|c|c|}
    \multicolumn{1}{r}{}
        &\multicolumn{1}{c}{\textbf{\stackanchor[1pt]{Tissue-specific}{penetrance}}}
        & \multicolumn{1}{c}{\textbf{\stackanchor[1pt]{Ubiquitous}{penetrance}}}
        & \multicolumn{1}{c}{}\\
    \cline{2-4}
        \textbf{\stackanchor[1pt]{Tissue-specific}{expression}}
        & \textit{\stackanchor{CLASS 1}{12 genes}}
        & \textit{\stackanchor{CLASS 4}{8 genes}}
        & \textcolor{green!70!black}{20 genes}\\
    \cline{2-4}
        \textbf{\stackanchor[1pt]{Ubiquitous}{expression}}
        & \textit{\stackanchor{CLASS 3}{32 genes}}
        & \textit{\stackanchor{CLASS 2}{20 genes}}
        & \textcolor{pink}{52 genes}\\
    \cline{2-4}
    \cline{2-4}
        & \textcolor{red!70!black}{44 genes}
        & \textcolor{RoyalBlue}{28 genes}
        & \textbf{72 genes}\\
    \cline{2-4}
\end{tabular}
}
\end{center}
\end{frame}
\end{document}

enter image description here

[EDIT: This MWE uses obsolete stackengine syntax for setting stackgap lengths (e.g., \Sstackgap=1ex), which prevented scalable lengths from scaling under a fontsize change. Version 2 of the package (submitted 7/11/13) remedies the problem with a small syntax change.]

1

Here is a way to create that table with {NiceTabular} of nicematrix.

\documentclass[ignorenonframetext, xcolor={dvipsnames}]{beamer}
\mode<presentation> {
\usetheme{Berkeley}
\usecolortheme{dolphin}

\usepackage{multirow}
\usepackage{nicematrix}
}

\begin{document}
\begin{frame}
\begin{center}
\small
\begin{NiceTabular}{ccc}[first-row,first-col,hvlines,cell-space-limits=5pt]
        & \Block{}{Tissue-specific\\penetrance}
        & \Block{}{Ubiquitous\\penetrance} \\
        \Block{}{Tissue-specific\\expression}
        & \Block{}{CLASS 1\\12 genes}
        & \Block{}{CLASS 4\\8 genes}
        & \textcolor{green!70!black}{20 genes}\\
        \Block{}{Ubiquitous\\expression}
        & \Block{}{CLASS 3\\32 genes}
        & \Block{}{CLASS 2\\20 genes}
        & \color{pink} 52 genes \\
        & \color{red!70!black} 44 genes
        & \color{RoyalBlue} 28 genes
        & 72 genes \\
\end{NiceTabular}
\end{center}
\end{frame}
\end{document}

Output of the above code

0

With tabularray:

\documentclass[ignorenonframetext, xcolor={dvipsnames}]{beamer}
\mode<presentation> {
\usetheme{Berkeley}
\usecolortheme{dolphin}

\usepackage{tabularray}
}

\begin{document}
\begin{frame}
\begin{center}
\small
\begin{tblr}{
  colspec={*4{Q[c,m]}},
  hline{2-Z}={2-Z}{solid},
  vline{2-Z}={2-Z}{solid},
  }
  & {Tissue-specific\\penetrance}
  & {Ubiquitous\\penetrance} \\
  {Tissue-specific\\expression}
    & {CLASS 1\\12 genes}
    & {CLASS 4\\8 genes}
    & \textcolor{green!70!black}{20 genes}\\
  {Ubiquitous\\expression}
    & {CLASS 3\\32 genes}
    & {CLASS 2\\20 genes}
    & \color{pink} 52 genes \\
  & \color{red!70!black} 44 genes
    & \color{RoyalBlue} 28 genes
    & 72 genes \\
\end{tblr}
\end{center}
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

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