Graphics, Figures & Tablescolortbl | Row Color for fixed Width Columns fails

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

colortbl | Row Color for fixed Width Columns fails

Post by isharp2 »

Hi,

I want to make a table that has a fixed with and a row color. We all know that when you make a fixed width column, we need to add @{\\extracolsep{\\fill}} to actually fill the table. When I do this, the \rowcolor fills my table with blank white space.

Code: Select all

\begin{center}
\begin{tabular*}{5in}{| @{\extracolsep{\fill}} l | @{\extracolsep{\fill}} l | @{\extracolsep{\fill}} l | @{\extracolsep{\fill}} l |} 

\rowcolor{tablecolor}
\hline
Review Date   & Name  & Position & Action \\
\hline
March 12,2012 & Man 1 & Manager & Accepted \\
              & Man 2 & Manager & Accepted \\
\hline
\end{tabular*}
\end{center}
Please help my \rowcolor fill the entire row in the table.
Attachments
Row color fixed width table blank spaces.
Row color fixed width table blank spaces.
latex-table-rowcol-fill.png (8.74 KiB) Viewed 5986 times
Last edited by isharp2 on Tue Apr 03, 2012 6:11 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

colortbl | Row Color for fixed Width Columns fails

Post by localghost »

Please get used to always providing a proper minimal example to give an adequate problem description.

Thorsten
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

colortbl | Row Color for fixed Width Columns fails

Post by isharp2 »

Below is a minimum working example:

Code: Select all

\documentclass{article} 
\usepackage{graphicx}
\usepackage{array}       %For different font sizes in tabular
\usepackage{color}
\usepackage{titlesec}     %Re-colors title sections
\usepackage{colortbl}      %puts colors in tables
\definecolor{tablecolor}{rgb}{1,1,0.8} 
\begin{document}

\begin{center}
\begin{tabular*}{5in}{| @{\extracolsep{\fill}} l | @{\extracolsep{\fill}} l | @{\extracolsep{\fill}} l | @{\extracolsep{\fill}} l |} 

\rowcolor{tablecolor}
\hline
Review Date   & Name  & Position & Action \\
\hline
March 12,2012 & Man 1 & Manager & Accepted \\
              & Man 2 & Manager & Accepted \\
\hline
\end{tabular*}
\end{center}

\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

colortbl | Row Color for fixed Width Columns fails

Post by localghost »

isharp2 wrote:Below is a minimum working example: […]
The example is not minimal. It loads packages that are not necessary to reproduce the problem. Just for information to others who this way might learn wrong requirements for a minimal example.

The table you want to typeset works fine with tabularx.

Code: Select all

\documentclass[11pt]{article}
\usepackage{geometry}       % to avoid warnigs
\usepackage{tabularx}
\usepackage[table]{xcolor}  % option loads »colortbl«

\begin{document}
  \begin{tabularx}{5in}{|X|X|X|X|}\hline
    \rowcolor{yellow!20}
    ReviewDate & Name & Position & Action \\ \hline
    March 12, 2012 & Man1 & Manager & Accepted \\
    & Man2 & Manager & Accepted \\ \hline
  \end{tabularx}
\end{document}
isharp2
Posts: 23
Joined: Fri Feb 11, 2011 2:06 am

Re: colortbl | Row Color for fixed Width Columns fails

Post by isharp2 »

vielen Dank für Ihre Antwort
Post Reply