I am trying to color a certain row in a table which has been made using the tabular* environment. The statement I have used for the tabular* is:
\begin{tabular*}{\textwidth}{@{\extracolsep{2cm plus 5cm minus 2cm}}lcl}
and for the rowcolor, I used:
\rowcolor[gray]{.95}
before each row that I needed colored. However the output is such that it appears that discrete cells are colored but there is space between the cells that is NOT colored. I believe the extracolsep is responsible for this, but I don't know how to take care of this. Any help you can provide would be most appreciated.
Thanks
Graphics, Figures & Tables ⇒ How to color a certain row in tabular* environment?
NEW: TikZ book now 40% off at Amazon.com for a short time.

How to color a certain row in tabular* environment?
Since I was not getting a reply to this, I contacted a friend who is a TeX guru and he came up with the following for a row to be colored in tabular* environment:
Put this in preamble:
\usepackage[dvips]{color}
\usepackage{multicol}
\definecolor{Mygrey}{gray}{0.95}
Then put this statement above the line with the row contents that you want colored:
\makebox[0pt][l]{\fboxsep0pt\colorbox{Mygrey} {\strut\hspace*{\linewidth}}}
So, in my case, the relevant code looked like:
\makebox[0pt][l]{\fboxsep0pt\colorbox{Mygrey} {\strut\hspace*{\linewidth}}}
Deposit Money Bank Assets & $dkldby$ & 1.084$^{**}$ \\
Put this in preamble:
\usepackage[dvips]{color}
\usepackage{multicol}
\definecolor{Mygrey}{gray}{0.95}
Then put this statement above the line with the row contents that you want colored:
\makebox[0pt][l]{\fboxsep0pt\colorbox{Mygrey} {\strut\hspace*{\linewidth}}}
So, in my case, the relevant code looked like:
\makebox[0pt][l]{\fboxsep0pt\colorbox{Mygrey} {\strut\hspace*{\linewidth}}}
Deposit Money Bank Assets & $dkldby$ & 1.084$^{**}$ \\
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How to color a certain row in tabular* environment?
A much easier way would be to use the colortbl package. It is loaded by the xcolor package when setting a special option.
More information is given in the according manuals which can be found on CTAN
Best regards
Thorsten¹
Code: Select all
\usepackage[table]{xcolor}
Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10