# Colored cells in a table and multicol

Is it be relatively easy to create a table with colored cells, many columns on a particular row and text centered in each box to produce the following output

I'm having trouble understanding how to create tables, having read various tutorials I cannot seem to produce a table like the one above. I'd be grateful of any help constructing the table.

\documentclass{article}
\usepackage{caption}
\usepackage[table]{xcolor}
\newcommand{\mcsix}[1]{\multicolumn{6}{l|}{#1}}

\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|>{\columncolor{blue!45}}l | *{6}{l|}}
\hline
text    &   &   &   &   &   &   \\ \hline
proof   & \mcsix{}              \\ \hline
begin   & \mcsix{}              \\ \hline
gray    & \mcsix{}              \\ \hline
\end{tabular}
\end{table}
\end{document}


For coloring of one column is sufficient to define for example >{\columncolor{blue!45}}l. cellcolor is dedicated for coloring particular cell, however use >{\cellcolor{blue!45}}l gives the same result as above MWE.

• Thank you very much for cite of my name. With you and the other users here I am learning new commands. Thanks again and Merry Christmas to you and your family. Dec 24, 2016 at 16:13
• @Sebastiano, you are welcome! And Merry Christmas and Happy and Prosper New Year to you and your family! Happy TeX-ing! Dec 24, 2016 at 16:18

In ConTeXt MKIV you can use Natural Tables for the job.

\starttext

\setupTABLE[option=stretch]
\setupTABLE[each][each][align=middle]
\setupTABLE[column][first][background=color,backgroundcolor=cyan]
\startTABLE
\NC TEXT \NC \NC \NC \NC \NC \NC \NC\NR
\NC TEXT \NC[nx=6] \NC\NR
\NC TEXT \NC[nx=6] \NC\NR
\NC TEXT \NC[nx=6] \NC\NR
\stopTABLE

\stoptext


• Very good. My compliments. Dec 24, 2016 at 13:31

I hope to help you. Sincerely my source is very simple and poor.

\documentclass{article}
\usepackage{mathtools,caption}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[hhh]
\centering
\captionsetup{skip=0cm}
\caption{My table}
\begin{tabular}{|
>{\cellcolor{blue!45}}l |l|l|l|l|l|l|}
\hline
\cellcolor{blue!45} text &   &   &   &   &   &   \\ \hline
\cellcolor{blue!45} proof & \multicolumn{6}{l|}{} \\ \hline
\cellcolor{blue!45} begin & \multicolumn{6}{l|}{} \\ \hline
\cellcolor{blue!45} gray & \multicolumn{6}{l|}{} \\ \hline
\end{tabular}
\end{table}
\end{document}

• Thanks a lot for your suggestion. I learned something new. Dec 24, 2016 at 13:32

You can use the\columncolor command, from colortbl (loaded by the [table] option of xcolor). I added some padding to the cells, changing the value of \arraystretch.

Added: A second solution, with tabularx can fill the whole line width. \documentclass{article} \usepackage[showframe]{geometry} \usepackage{mathtools} \usepackage{array, tabularx, caption}% \usepackage[table, svgnames]{xcolor}

\begin{document}

\begin{table}[!htb]
\centering%
\renewcommand{\arraystretch}{1.6}
\caption{My table}
\begin{tabular}{|>{\centering\bfseries\columncolor{RoyalBlue!80}}m{2cm} |*{8}{m{3mm}|}}
\hline
TEXT &   &   &   &   &   &   &   &   \\ \hline
TEXT & \multicolumn{8}{l|}{} \\ \hline
TEXT & \multicolumn{8}{l|}{} \\ \hline
TEXT & \multicolumn{8}{l|}{} \\ \hline
\end{tabular}
\end{table}

\begin{table}[!htb]
\renewcommand{\arraystretch}{1.6}
\renewcommand{\tabularxcolumn}[1]{>{\arraybackslash}m{#1}}
\caption{My table}
\begin{tabularx}{\linewidth}{|>{\centering\bfseries\columncolor{RoyalBlue!80}\hsize =3\hsize}X |*{8}{ >{\hsize=0.75\hsize}X|}}
\hline
TEXT &   &   &   &   &   &   &   &   \\ \hline
TEXT & \multicolumn{8}{l|}{} \\ \hline
TEXT & \multicolumn{8}{l|}{} \\ \hline
TEXT & \multicolumn{8}{l|}{} \\ \hline
\end{tabularx}
\end{table}

\end{document}


• Is there a way of stretching the table so that it is textwidth? Dec 24, 2016 at 14:27