I'm trying to combine a tabularx table with centered text using colortbl to colour the columns.
I wish to equally space the columns so I'm using the column type X for each column header.
With this I'm trying to using \centering with the \columncolor as follows:
Code: Select all
\newcolumntype{y}{>{\columncolor{LightGray}\centering}X}
When I centre the columns or color them individually it works (see example code)! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \let \hskip \vskip \let \vrule \hrule \let...
l.62 \end{tabularx}
Many thanks for your assistance!
Kevin (Long time reader, first time poster)
--- Example code ---
Code: Select all
\documentclass[10pt,a4paper]{report}
%
\usepackage{color}
\definecolor{LightGray}{rgb}{0.83,0.83,0.83}
%
\usepackage{colortbl}
\usepackage{tabularx}
%
\newcolumntype{z}{>{\columncolor{LightGray}}X}
\newcolumntype{y}{>{\columncolor{LightGray}\centering}X}
%
\begin{document}
%
\begin{table}[h!]
%
\centering
\caption{ABC}
%
\begin{tabularx}{1.0\columnwidth}{X X X}
A & B & C \\ \hline
1 & P & I \\
2 & Q & J \\
3 & R & K
\end{tabularx}
%
\end{table}
%
\begin{table}[h!]
%
\centering
\caption{XYZ}
%
\begin{tabularx}{1.0\columnwidth}{z z z}
A & B & C \\ \hline
1 & P & I \\
2 & Q & J \\
3 & R & K
\end{tabularx}
%
\end{table}
%
\begin{table}[h!]
%
\begin{tabularx}{1.0\columnwidth}{y y y}
A & B & C \\ \hline
1 & P & I \\
2 & Q & J \\
3 & R & K
\end{tabularx}
%
\end{table}
%
%
\end{document}