# How to design the columns in a table

I've copied this source code from the section "Professional tables" in this page LaTeX/Tables, but the original source code is only for a table with 3 columns. I want to extend it to 5 columns, but only concatenate & does not work.

 \begin{tabular}{llr}
\hline

Gastro   & Grade 1 & Grade 2   & Grade 3   & Grade 4  \\
\hline
Gnat      & per gram    & 13.65    & Grade 3   & Grade 4  \\
& each        & 0.01     & Grade 3   & Grade 4  \\
Gnu       & stuffed     & 92.50    & Grade 3   & Grade 4  \\
Emu       & stuffed     & 33.33     & Grade 3   & Grade 4 \\
Armadillo & frozen      & 8.99      & Grade 3   & Grade 4 \\
\hline
\end{tabular}


The last two columns overlap with the other columns. Do anyone have idea how to extend this source code to more columns?

• The set of braces after \begin{tabular} sets the number of columns for the table. Since your table has llr it has only 3 columns. Adding more columns won't help unless you add more columns to that: {llllr} will give you 5. This is pretty basic stuff. Try [Q: What are good learning resources for a LaTeX beginner? ](tex.stackexchange.com/questions/11/…) – Alan Munn Jun 30 '17 at 1:40
• Also, when asking a question you shouldn't post code fragments, but complete minimal compilable documents. See I've just been asked to write a minimal example, what is that?. – Alan Munn Jun 30 '17 at 1:43
• – Alan Munn Jun 30 '17 at 1:46

Tables in LaTeX require a specification for the exact number of columns the table has. This is given in the argument to the \begin{tabular} environment.

In your table, you have specified {llr} which means the table has three columns. If you want five columns you need something like {llrll} (since your decimal column is the one you want right-aligned.)

For most tables, the booktabs package is really useful. It provides nicer vertical spacing and different width rules for tops and middle parts of the table. I've used it in the code below.

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{llrll}
\toprule
Gastro   & Grade 1 & Grade 2   & Grade 3   & Grade 4  \\
\midrule
Gnat      & per gram    & 13.65    & Grade 3   & Grade 4  \\
& each        & 0.01     & Grade 3   & Grade 4  \\
Gnu       & stuffed     & 92.50    & Grade 3   & Grade 4  \\
Emu       & stuffed     & 33.33     & Grade 3   & Grade 4 \\
Armadillo & frozen      & 8.99      & Grade 3   & Grade 4 \\
\bottomrule
\end{tabular}
\end{document}


Possible values for the column specification are:

l = left aligned column
r = right aligned column
c = center aligned column
p{<width>} = left aligned column of <width>


There are more complex column specifications, but these are the basics. See the following questions for some more details: