# Last column vertical rule missing

I'm dealing with the powerful tabularx environment. I was able to obtain a nice table, except for the last column. I need seven columns in total, but at the end I got another half column. I can't understand why!

Here the code I used for building the table:

\begin{table}[h!]
\begin{tabularx}{\textwidth}{|l|*{20}{>{\arraybackslash}X|}}

\hline

\thead{\color{RoyalBlue}One\\\color{RoyalBlue} Time} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} \\

\hline

\thead{\color{RoyalBlue}Two\\\color{RoyalBlue} Times} & & & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \\

\hline

\thead{\color{RoyalBlue}Three\\\color{RoyalBlue}Times} & \multicolumn{3}{l|}{} & & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & & \multicolumn{3}{l|}{} \\

\hline

\thead{\color{RoyalBlue}Four\\\color{RoyalBlue} \& Times} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & \\

\hline

\end{tabularx}
\caption{{Caption}}
\end{table}


Which produces the following output:

Does anyone have an idea?

• You really need to be more forthcoming. What does \thead's definition look like? We really want to just copy-and-paste-and-compile an see the problem you're experiencing. At the moment this is not possible. The code you provide should start with \documentclass and end with \end{document}. See how to create a minimal working example (MWE). – Werner Feb 1 '15 at 19:58

For columns with vertical rules, you need to supply sufficient &s so that the cell is actually set. You're missing a last-column & to "enter" the last column, leaving the right-hand vertical rule missing.

In order to drop the seemingly ill-fated last column, you only need 18 columns, yet you've suggested 20 in your tabular preamble. Below this is corrected:

\documentclass{article}

\usepackage{tabularx,colortbl}
\usepackage[dvipsnames]{xcolor}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{|l|*{18}{>{\arraybackslash}X|}}
\hline
\thead{\color{RoyalBlue}One\\\color{RoyalBlue} Time} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} \\
\hline
\thead{\color{RoyalBlue}Two\\\color{RoyalBlue} Times} & & & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} \\
\hline
\thead{\color{RoyalBlue}Three\\\color{RoyalBlue}Times} & \multicolumn{3}{l|}{} & & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & & \multicolumn{3}{l|}{} \\
\hline
\thead{\color{RoyalBlue}Four\\\color{RoyalBlue} \& Times} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & \multicolumn{3}{l|}{} & & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & \cellcolor[HTML]{D3D3D3} & & \\
\hline
\end{tabularx}

\end{document}

• @user51937: I've corrected the answer to reflect your request. – Werner Feb 1 '15 at 21:57
• Oh gaush, 18 and not 20. Now I understood. Thank you very much @Werner! – user51937 Feb 2 '15 at 0:16