This produces a 2x2 table whose first row is blue with white text and whose second row is white with black text. Although it works fine it does repeat \textcolor{white}
in each cell of the row where the cells are to have white text. Is there some way of specifying that the text in the first row should be white without having to repeatedly specify it over again for each cell of that row? Its not so bad in this small example but I am concerned that it will get tiresome on larger tables.
\documentclass{article}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{colortbl}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\begin{document}
\begin{center}\Large
\noindent\begin{tabularx}{1\textwidth}{|L|L|}
\hline
% NEXT LINE REPEATS WHITE FOR EACH CELL
\rowcolor{blue}\textcolor{white}{Jan}&\textcolor{white}{Feb}\\
Mar&Apr\\
\hline
\end{tabularx}
\end{center}
\end{document}
EDIT: This question has already been answered and accepted with an answer directly addressing the tabularx
environment in the question's example code but since then I found that the tabu
package can do this.
As this involves using a different package than that presented in the original question I am not going to put this as an answer but am just adding the following example of how to implement this using tabu
in case anyone is interested in another approach.
\documentclass{article}
\usepackage{tabu}
\usepackage{colortbl}
\begin{document}
\begin{center}\Large
\noindent\begin{tabu} to \textwidth{|X[l,m]|X[l,m]|}
\tabucline-
\rowfont{\color{white}}\rowcolor{blue}Jan&Feb\\
Mar&Apr\\
\tabucline-
\end{tabu}
\end{center}
\end{document}