[Tex/LaTex] “misplaced \noalign” error and missing column separator in “\tabular” environment

errorstables

I am trying to a make a simple table in a document and I am having a few problems. I am somewhat new to LaTeX, so this is probably a stupid question!

1) I am trying to have a vertical line separating each column, but for whatever reason, it never draws the line between the first and second columns.

2) When I try to limit the size of a column with the p{<column width>} option, it simply doesn't work.

Here is a simplified version of my table:

\documentclass{report}
\begindocument
\begin{tabular}{l p{2cm} | c p{3cm} | c p{2cm} |}
\hline
First Column Description & Second Column Description & Third Column Description
\hline
\hline
First Column First Row Contents & Second Column First Row Contents & Third Column First Row Contents \\[3pt]
\hline
First Column Second Row Contents & Second Column Second Row Contents & Third Column Second Row Contents \\[3pt]
\hline
First Column Third Row Contents & Second Column Third Row Contents & Third Column Third Row Contents \\[3pt]
\hline
First Column Fourth Row Contents & Second Column Fourth Row Contents & Third Column Fourth Row Contents \\[3pt]
\hline
First Column Fifth Row Contents & Second Column Fifth Row Contents & Third Column Fifth Row Contents \\[3pt]
\hline
First Column Sixth Row Contents & Second Column Sixth Row Contents & Third Column Sixth Row Contents
\hline
\end{tabular}
\end{document}

Also, when I tried to run this sample through LaTeX, there are even more errors and it looks even more jumbled than in the original document. I can provide the original table also, although apart from the content, I am pretty sure they are identical

Also, here are the errors I am getting:

Misplaced \noalign.
\hline ->\noalign 
                  {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.111 \hline

? 
./chapters/chapter2.tex:111: You can't use `\hrule' here except with leaders.
\hline ->\noalign {\ifnum 0=`}\fi \hrule 
                                         \@height \arrayrulewidth \futurelet...
l.111 \hline

? 
./chapters/chapter2.tex:111: Missing number, treated as zero.
<to be read again> 
                   \futurelet 
l.111 \hline

? 
./chapters/chapter2.tex:111: Illegal unit of measure (pt inserted).
<to be read again> 
                   \futurelet 
l.111 \hline

Best Answer

  1. You need braces in \begin{document}.
  2. You have three columns, but {l p{2cm} | c p{3cm} | c p{2cm} |} tells tabular to expect six.
  3. You need \\ at the end of the first and last rows.

EDIT

To adjust the alignment of the text inside a p column, you can use \centering, \raggedleft and \raggedright inside the table entries. Note that you need braces if you do this in the final column. To change the alignment for an entire column, you can use the array package, as suggested by @Bernard in the comments.

\documentclass{report}
\begin{document}
\begin{tabular}{p{2cm}|p{3cm}|p{2cm}|}
\hline
\centering First Column Description & \raggedright Second Column Description & {\raggedleft Third Column Description} \\
\hline
\hline
First Column First Row Contents & Second Column First Row Contents & Third Column First Row Contents \\[3pt]
\hline
First Column Second Row Contents & Second Column Second Row Contents & Third Column Second Row Contents \\[3pt]
\hline
First Column Third Row Contents & Second Column Third Row Contents & Third Column Third Row Contents \\[3pt]
\hline
First Column Fourth Row Contents & Second Column Fourth Row Contents & Third Column Fourth Row Contents \\[3pt]
\hline
First Column Fifth Row Contents & Second Column Fifth Row Contents & Third Column Fifth Row Contents \\[3pt]
\hline
First Column Sixth Row Contents & Second Column Sixth Row Contents & Third Column Sixth Row Contents \\
\hline
\end{tabular}
\end{document}
Related Question