[Tex/LaTex] Extra alignment tab has been changed to \cr

tables

\begin{table}[ht!]
\begin{center}
    \begin{tabular}{p{0.6cm}p{0.6cm}p{2.3cm}p{1.4cm}p{2.3cm}p{1.45cm}}
        \hline
        \bf p & \bf N & \bf $\|u-u_{h}\|_{L^{2}(0,1)}$ & \bf $L^{2}$ Rate & \bf $\|u-u_{h}\|_{H^{1}(0,1)}$ & \bf $H^{1}$ Rate\\
        \hline
        1  & 2  & $1.1735 \times 10^{-2}$ & \centering -- & $2.3671 \times 10^{-2}$ & \centering --\\
        -- & 4  & $3.0549 \times 10^{-3}$ & 1.9416        & $1.1547 \times 10^{-2}$ & 1.0356\\
        -- & 8  & $7.4722 \times 10^{-4}$ & 2.0315        & $5.4262 \times 10^{-3}$ & 1.0895\\
        \hline
    \end{tabular}
\end{center}
\end{table}

So I'm getting that error with the above code and I know it's because in the last column of the second row of entries (i.e. the first row with actual data), I have "centering –". I'm confused why that doesn't work though since it works for the 2nd row, 4th column entry.

Best Answer

If you need only a correction, here you are:

\documentclass{article}
\begin{document}

\begin{table}[ht!]
\begin{center}
    \begin{tabular}{p{0.6cm}p{0.6cm}p{2.3cm}p{1.4cm}p{2.3cm}p{1.45cm}}
        \hline
        \bf p & \bf N & \bf $\|u-u_{h}\|_{L^{2}(0,1)}$ & \bf $L^{2}$ Rate & \bf $\|u-u_{h}\|_{H^{1}(0,1)}$ & \bf $H^{1}$ Rate\\
        \hline
 %       1  & 2  & $1.1735 \times 10^{-2}$ & \centering -- & $2.3671 \times 10^{-2}$ & \centering --\\
       1  & 2  & $1.1735 \times 10^{-2}$ & \multicolumn{1}{c}{ --} & $2.3671 \times 10^{-2}$ & \multicolumn{1}{c}{ --}\\
        -- & 4  & $3.0549 \times 10^{-3}$ & 1.9416        & $1.1547 \times 10^{-2}$ & 1.0356\\
        -- & 8  & $7.4722 \times 10^{-4}$ & 2.0315        & $5.4262 \times 10^{-3}$ & 1.0895\\
        \hline
    \end{tabular}
\end{center}
\end{table}

\end{document}
Related Question