1

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?

Cragfelt
  • 4,005
Abulurd
  • 113
  • 1
  • 5

1 Answers1

3

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}
Cragfelt
  • 4,005
  • 2
    Perhaps you could mention *{3}{c} as an alternative to ccc here as well (which is not a reduction concerning the number of characters but in case of having cccccccccccc *{12}{c} it would be simpler ;-) –  Dec 29 '17 at 06:28
  • 1
    @ChristianHupfer Of course! I will include it. In the post. Thank you for the feedback. – Cragfelt Dec 29 '17 at 06:48
  • @ChristianHupfer Is there any question of yours that I can mention in the further edit, that contains what you mentioned in your comment? – Cragfelt Dec 29 '17 at 06:52
  • No question concerning the *{}{c} syntax by me. But there are a lot of them, I am pretty sure –  Dec 29 '17 at 07:03
  • @ChristianHupfer A shame. Ok, I will search for an appropiate one. – Cragfelt Dec 29 '17 at 07:20