# Error in making table with multiple columns

I try to make a table with more than two columns as follows

\begin{center}\begin{tabular}{cc}
Sub & $A_i$ & $B_i$ & $C_i$ & $D_i$ & $E_i$ & $F_i$ & $G_i$ & $H_i$ \\ \hline
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline
\end{tabular} \end{center}


But it shows

[4]
! Extra alignment tab has been changed to \cr.

l.228         Sub & $A_i$ &
$B_i$ & $C_i$ & $D_i$ & $E_i$ & $F_i$ & $G_i$ & ...

?


I want to know how to solve the error. It seems nothing wrong to me. And when I reduce the number of columns to 2, it works fine. It shows me an error when there are more than 2 columns.

• Load array and use in the table preamble *{9}{c}, not cc. May 23 at 22:17
• {cc} means two centred columns. May 23 at 23:04
• Welcome to TeX.SE.
– Mico
May 24 at 4:45
• problem solved! thank you May 24 at 6:59

I suggest you employ a matrix environment (provided by the amsmath package) in an unnumbered displayed equation instead of a tabular environment embedded in a center environment.
\documentclass{article}
$\begin{matrix} % Note: No need for '' symbols to initiate and terminate inline math mode... \mathrm{Sub} & A_i & B_i & C_i & D_i & E_i & F_i & G_i & H_i \\ \hline 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline \end{matrix}$