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.

I'm trying to make an ENTIRE table gray (see picture enter image description here

but I can't get it to work with \raisebox.

Here's my code:

\documentclass[a4paper,11pt]{article}
\usepackage{color,amsmath,amsfonts,amssymb}
\usepackage{rotating}
\usepackage{colortbl}

\definecolor{Gray}{gray}{0.9}

\newcolumntype{g}{>{\columncolor{Gray}}c}
\begin{table}[h]
\begin{center} {\footnotesize
\begin{tabular}{lccg}
\hline
 & \multicolumn{3}{c}{AFC Window 1}    \\
  & \multicolumn{1}{c}{gmt} & \multicolumn{1}{c}{jfk} &
\multicolumn{1}{c}{fbi}\\\hline
\rowcolor{Gray}
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\rowcolor{Gray}
\raisebox{2ex}{Constant} & (1.22) & (2.22) & (0.56)\\[0ex]
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Constant} & (1.22) & (2.22) & (0.56)\\[0ex]
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Log(assets)$^a$} & (1.22) & (2.22) & (0.56)\\[0ex]
\hline
\end{tabular} }
\end{center}
\caption{\footnotesize Number of turns and distance between top and bottom.}
\label{turns}
\end{table}


\end{document}

Thanks guys.

share|improve this question
    
It's not clear what layout you want to achieve. You have negative spacing between the rows, so the coloured panel of one row obscures the text in the previous row. From your title, if you really want a background to the whole table don't use \rowcolor at all just use \colorbox{Gray}{\begin{tabular}..... –  David Carlisle Jul 13 '12 at 15:40

1 Answer 1

up vote 3 down vote accepted

You have to "smash" the raised box, rather than using negative vertical space

\documentclass[a4paper,11pt]{article}
\usepackage{color,amsmath,amsfonts,amssymb}
\usepackage{rotating}
\usepackage{colortbl}

\definecolor{Gray}{gray}{0.9}

\begin{document}
\begin{table}[h]
\centering\footnotesize
\begin{tabular}{l*{2}{>{$}c<{$}}>{\columncolor{Gray}$}c<{$}}
\hline
& \multicolumn{3}{c}{AFC Window 1}    \\
& \multicolumn{1}{c}{gmt} & \multicolumn{1}{c}{jfk} &
\multicolumn{1}{c}{fbi}\\\hline
\rowcolor{Gray}%
& 0.025^* & -0.002 & 1.155^* \\
\rowcolor{Gray}%
\smash{\raisebox{1.5ex}{Constant}}& (1.22) & (2.22) & (0.56)\\
& 0.025^* & -0.002 & 1.155^* \\
\smash{\raisebox{1.5ex}{Constant}}& (1.22) & (2.22) & (0.56)\\
& 0.025^* & -0.002 & 1.155^* \\
\smash{\raisebox{1.5ex}{Log(assets)\textsuperscript{\itshape a}}}& (1.22) & (2.22) & (0.56)\\
\hline
\end{tabular}
\caption{Number of turns and distance between top and bottom.}
\label{turns}
\end{table}


\end{document}

I've made also some other improvements, so that the minus signs appear as they should.

enter image description here

share|improve this answer

Your Answer

 
discard

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