2

This question already has an answer here:

I have created a table in the following way:

\documentclass{article}
\usepackage[table,xcdraw]{xcolor} %Tables
\usepackage{array,multirow}
\usepackage{booktabs}

\begin{document}
\begin{table}\centering
\begin{tabular}{>{\columncolor[HTML]{EFEFEF}}l>{\columncolor[HTML] 
{EFEFEF}}l>{\columncolor[HTML]{EFEFEF}}l>{\columncolor[HTML]{EFEFEF}}l> 
{\columncolor[HTML]{EFEFEF}}l>{\columncolor[HTML]{EFEFEF}}l> 
{\columncolor[HTML]{EFEFEF}}l>{\columncolor[HTML]{EFEFEF}}l}
\toprule
&  \multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}\textbf{Estimates}} & 
&\multicolumn{3}{c}{\cellcolor[HTML]{EFEFEF}\textbf{\begin{tabular}[c] 
{@{}l@{}}$\varepsilon$ s. d. and\\ correlation\end{tabular}}} \\\cmidrule{2- 
4}\cmidrule{6-8}
& $\hat{b},\hat{\phi}$ & $\sigma(\hat{b})$ & implied&  & $r$ & $\Delta d$ & 
$dp$ \\
\midrule
$r$  & 0.32324 & 2 & & & & &\\
$\Delta d$  & 0.32324 & 2 & & & & &\\
$dp$  & 0.32324 & 2 & & & & &\\

\bottomrule
\end{tabular}
\caption{Test}
\end{table}
\end{document}

And the problem is that not everything is filled in the color. It comes without everything being colored:

enter image description here

marked as duplicate by JouleV, Stefan Pinnow, Kurt, Marijn, marmot Apr 23 at 15:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

If you are just looking for a uniform bg color, then this seems a lot easier. I removed the column and cell colors, and wraped the entire table ina colored background. The \fboxsep to zero is to make the colored box go to the edge.

\documentclass{article}
\usepackage[table,xcdraw]{xcolor} %Tables
\usepackage{array,multirow}
\usepackage{booktabs}
\definecolor{mycolor}{HTML}{EFEFEF}
\begin{document}
\begin{table}\centering
  \setlength{\fboxsep}{0pt}
\colorbox{mycolor}{\begin{tabular}{llllllll}
\toprule
&  \multicolumn{3}{c}{\textbf{Estimates}} & 
&\multicolumn{3}{c}{\textbf{\begin{tabular}[c] 
{@{}l@{}}$\varepsilon$ s. d. and\\ correlation\end{tabular}}} \\\cmidrule{2- 
4}\cmidrule{6-8}
& $\hat{b},\hat{\phi}$ & $\sigma(\hat{b})$ & implied&  & $r$ & $\Delta d$ & 
$dp$ \\
\midrule
$r$  & 0.32324 & 2 & & & & &\\
$\Delta d$  & 0.32324 & 2 & & & & &\\
$dp$  & 0.32324 & 2 & & & & &\\

\bottomrule
\end{tabular}}
\caption{Test}
\end{table}
\end{document}
  • Can you use this construct with longtables? – Bernard Apr 23 at 12:09
  • 2
    @Bernard as longtable supports line breaks and colorbox does not, no. But then I'd probably just have a look at the tcolorbox package, it should probably be able to do something similar – daleif Apr 23 at 12:11
  • Yeap, just wanted to color everything. Your code worked exactly as I wanted, thanks. – Jennifer Apr 23 at 12:33

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