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

horizontal alignmenttables

I'm trying to create a table and I've got the error you can see in the title.

The (minimal) code is :

\begin{table}
\begin{center}
\begin{tabular}{%
|>{\centering}p{0.20\columnwidth}%
|>{\centering}p{0.19\columnwidth}%
|>{\centering}p{0.11\columnwidth}%
|>{\centering}p{0.17\columnwidth}%
|>{\centering}p{0.11\columnwidth}|}
\hline
a & b & c & d & e \\
a & b & c & d & e \\
\end{tabular}
\end{center}
\end{table} 

The number of column is okay, the end of line also …
I also get an if I insert an \hline between the two lines

The error in this case is Misplaced \noalign \hline

So far, I could correct it by having the last column without >{\centering}.

Any help greatly appreciated 🙂

Best Answer

You have to use \arraybackslash for the last column:

 |>{\centering\arraybackslash}p{0.11\columnwidth}|}

to restore the \\ after \centering.

Code:

\documentclass{article}
\usepackage{array}
\begin{document}
  \begin{table}
\begin{center}
\begin{tabular}{%
|>{\centering}p{0.20\columnwidth}%
|>{\centering}p{0.19\columnwidth}%
|>{\centering}p{0.11\columnwidth}%
|>{\centering}p{0.17\columnwidth}%
|>{\centering\arraybackslash}p{0.11\columnwidth}|}
\hline
a & b & c & d & e \\
a & b & c & d & e
\end{tabular}
\end{center}
\end{table}
\end{document}
Related Question