4

I want to create a column in a tabular with column specifier 'p' and centred text. I have tried to achieve this using the example below.

\documentclass{article}

\usepackage{array}

\begin{document}

\begin{table}
  \begin{tabular}{c l >{\centering}p{2cm}}
    a & b & c \\
    a & b & c 
  \end{tabular}
\end{table}

\end{document}

Why does this create the following error, and what is the correct way to do this?

! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.10     a &
             b & c
You have given more \span or & marks than there were
in the preamble to the \halign or \valign now in progress.
So I'll assume that you meant to type \cr instead.

I'm using Miktex 2.9

1 Answer 1

4
\documentclass{article}    
\usepackage{array}
\begin{document}

  \begin{tabular}{ c l >{\centering\arraybackslash}p{2cm}}
    a & b & c \\
    a & b & c 
  \end{tabular}

\end{document}

\centering redefines the double backslash. However, a better choice is to use

\documentclass{article}    
\usepackage{array,ragged2e}
\begin{document}

  \begin{tabular}{ c l >{\Centering}p{2cm}}
    a & b & c \\
    a & b & c 
  \end{tabular}

\end{document}
2
  • Thanks, since you answered I have also discovered another option would be to use the \tabularnewline command instead of \\ in the table but your solution is better.
    – crobar
    Feb 13, 2012 at 14:22
  • tabularnewline does nearly the same as \arraybackslash once
    – user2478
    Feb 13, 2012 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.