Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

As a follow up to this question, I am trying to insert tables in my beamer presentation so that they have the same style as blocks. However, I want to avoid using rules in my tables, and I am trying to used colored rows (with package xcolor) to improve readability.

Here is an example of my code:

\PassOptionsToPackage{table}{xcolor}
\documentclass{beamer}

\usepackage{tabularx}

\definecolor{RowColorOdd}{rgb}{0.914,0.914,0.953}
\definecolor{RowColorEven}{rgb}{1,1,1}

\usetheme{Darmstadt}
\usecolortheme{seahorse}

\begin{document}

\begin{frame}[plain]
  \begin{block}{\centering\begin{tabularx}{1\textwidth}{@{}p{0.56\textwidth}@{}X@{}X@{}}\textcolor{white}{Header 1} & \textcolor{white}{Header 2} & \textcolor{white}{Header 3}\end{tabularx}}%
  \centering
    \rowcolors{1}{RowColorOdd}{RowColorEven}%
    \begin{tabularx}{1\textwidth}{@{}p{0.56\textwidth}@{}X@{}X@{}}%
      1.1 & 1.2 & 1.3 \\%
      2.1 & 2.2 & 2.3 \\%
      3.1 & 3.2 & 3.3 \\%
      4.1 & 4.2 & 4.3
    \end{tabularx}%
  \end{block}%
\end{frame}

\end{document}

However, this code results in the following table, where rows are oversized with respects to the block frame: Result

Any idea how I can fix this ?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

for both tabular use:

\begin{tabularx}{\dimexpr\textwidth-2\tabcolsep}{@{}p{0.56\textwidth}@{}X@{}X@{}}%

enter image description here

share|improve this answer
    
Thanks for your answer! I understand your solution, and it works, but now the rows are undersized w/r to the block, probably due to the block inner margins. Is there a way to take these margins into account so that the rows are exactly as wide as the block ? –  AldurDisciple May 16 '13 at 13:36
    
use it for both tabulars. The box has an inner border. You can use as an alternative package tcolorbox –  Herbert May 16 '13 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.