# Table alignment

I'm not an expert with the tabular environment...I have some problems:

1. I got an error "Extra alignment tab has been changed to \cr."
2. I would like to have the professor name completely to the right.

 \documentclass[12pt,a4paper,oneside]{book}
\usepackage{array,booktabs,siunitx}
\begin{document}
\noindent
\begin{tabular}{@{}l@{\hspace{.5em}}l r}
Students: &                    &Professor: &\\
Name1     &\textsc{Surname}    &Name       &\textsc{Surname} \\
Name2     &\textsc{Surname}    &           &       \\
Name3     &\textsc{Surname}    &           &
\end{tabular}
\end{document}


Can somebody help me?

-
You are specifying 3 columns but actually use 4. add a column like \begin{tabular}{@{}l@{\hspace{.5em}}l r l}. See the last l. –  Harish Kumar Feb 17 '13 at 11:41

you had only specified 3 columns but had 4 columns of data, I changed to just use three columns but other layouts are possible depending on how you want it to look...

 \documentclass[12pt,a4paper,oneside]{book}
\usepackage{array,booktabs,siunitx}
\begin{document}
\noindent
\begin{tabular}{@{}l@{\hspace{.5em}}l@{\hspace{2em}} r}
Students: &                    &Professor: \\
Name1     &\textsc{Surname}    &Name   \textsc{Surname} \\
Name2     &\textsc{Surname}    &             \\
Name3     &\textsc{Surname}    &
\end{tabular}
\end{document}


or the version with a full width table and 4 columns

 \documentclass[12pt,a4paper,oneside]{book}
\usepackage{array,booktabs,siunitx}
\begin{document}
\noindent
\begin{tabular*}{\textwidth}
{@{}
l@{\hspace{.5em}}l
@{\extracolsep{\fill}}
r@{\extracolsep{0pt}\hspace{.5em}}r
@{}}
\multicolumn{2}{c}{Students:}&
\multicolumn{2}{c}{Professor:} \\
Name1     &\textsc{Surname}    &Name&   \textsc{Surname} \\
Name2     &\textsc{Surname}    &             \\
Name3     &\textsc{Surname}    &
\end{tabular*}
\end{document}

-
Ok, but I would like to have the professor's name completely to the right side of the page, like with \flushright command. And then, I did 4 coloumns for having the same space between names and surnames: with yours commands the space between professor's name en surname is smaller than between the students name... –  Ford Prefect Feb 17 '13 at 11:56
oh currently it the prof name is flush right of the table but the table is not the width of the page. You can make the prof name two columns if you wish but then you need to specify four columns in the table preamble. I'll put a full width table in the answer... –  David Carlisle Feb 17 '13 at 11:58
If one inserts >{\scshape} in front of the location specifiers of the 2nd and 4th columns (l and r, respectively) of the tabular or tabular* setup, it won't be necessary to provide the instruction \textsc for the surnames in each and every subsequent row of the table. –  Mico Feb 17 '13 at 13:55

And then there's the plain TeX halign solution - whenever I see a complex tabular arrangement I can't help thinking how much simpler Knuth's halign is...

\documentclass{article}
\begin{document}