[Tex/LaTex] A four column table shows an extra column

columnsmulticolumntables

I am planning on using a piece of code from https://www.sharelatex.com website. It is a table with four columns.

Here is the code snippet:


\begin{tabular}{ |p{3cm}||p{3cm}|p{3cm}|p{3cm}|  }
 \hline
 \multicolumn{4}{|c|}{Country List} \\
 \hline
 Country Name     or Area Name& ISO ALPHA 2 Code &ISO ALPHA 3 Code&ISO numeric Code\\
 \hline
 Afghanistan   & AF    &AFG&   004\\
 Aland Islands&   AX  & ALA   &248\\
 Albania &AL & ALB&  008\\
 Algeria    &DZ & DZA&  012\\
 American Samoa&   AS  & ASM&016\\
 Andorra& AD  & AND   &020\\
 Angola& AO  & AGO&024\\
 \hline
\end{tabular}

enter image description here

My question is, how do I get rid of this extra column right after the first as illustrated in the image above?

Best Answer

Despite of this question has been answered in comments and questions like this have been discused before in this community many times, I am amswering it just in order to improve a little bit the code and to show a couple of things regarding tables:

  1. It is strongly recommended to avoid vertical lines (see Small Guide to Making Nice Tables).
  2. The table can be placed in table environment to make it float, like in figure environment, so it also can have its own caption. (See Tables in LaTeX2ε: Packages and Methods).
  3. The \usepackage{booktabs} loads array and it is a ver powerful package for tables. It also permits the usage of rules in other array-like environments (ibidem, page 9.).
  4. The arguments !htpb between brackets, specify placement in float objects like tables. (See this answer).
  5. To avoid repetitive and tedious declarations in case of multiple columns like {cccccccccccc}, one can write a brief and simple notation *{12}{c}. (See this answer)

Improved visualization of table

enter image description here

The code

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}[!htpb]
\centering
\begin{tabular}{@{}lccc@{}}
\toprule
\multicolumn{4}{c}{\textbf{Country List}} \\ \midrule
\multicolumn{1}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Country Name \\ or Area Name\end{tabular}}} & \textbf{\begin{tabular}[c]{@{}c@{}}ISO ALPHA\\ 2 Code\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}ISO ALPHA\\ 3 Code\end{tabular}} & \textbf{ISO numeric Code} \\ \midrule
Afghanistan                                                                              & AF                                                         & AFG                                                        & 004              \\
Aland Islands                                                                            & AX                                                         & ALA                                                        & 248              \\
Albania                                                                                  & AL                                                         & ALB                                                        & 008              \\
Algeria                                                                                  & DZ                                                         & DZA                                                        & 012              \\
American Samoa                                                                           & AS                                                         & ASM                                                        & 016              \\
Andorra                                                                                  & AD                                                         & AND                                                        & 020              \\
Angola                                                                                   & AO                                                         & AGO                                                        & 024              \\ \bottomrule
\end{tabular}
\end{table}

\end{document}
Related Question