How to Create a LaTeX Table


If you are an academician who is researching in physics, mathematics, chemistry or any other field of research, mastering LaTeX is a must. LaTeX is a document creation system and markup language that has been developed for researchers to create elegantly formatted documents ranging from research papers, reports to even books.

Syntax
To present any kind of data in a research paper, report or a book, you need to create tables. LaTeX has a facility for creating clear tables. To create a LaTeX table, you need to know how to create its associated environment. Any environment in LaTeX is devoted to the formatting of a specific kind of text. Accordingly to create a table you need to switch to the ‘Tabular Environment’. The syntax for beginning or ending any tabular environment is the following:

\begin {Name of Environment}
. . . . .
\end {Name of Environment}

For the tabular environment, the beginning and ending of syntax will be:

\begin {tabular}
. . . . .
\end {tabular}

After the declaration of the tabular environment, to describe the formatting and alignment of data, you need to specify arguments. The number of columns in the table need not be explicitly specified. It is inferred from the number of arguments provided. Here are some of the symbols and associated commands used in a LaTeX table:

  • c – Centered Column
  • l – Left Justification of Column
  • r – Right Justification of Column
  • | – Vertical Lines Between Data
  • || – Double Vertical Lines Between Data
  • \hline – Horizontal Line
  • & – Column Separator
  • \\ – Begins New Row
  • \caption – Used to Specify Table Caption

These are the commands that you need to create the simplest of tables. There are many more complex commands for creating tables with different formatting and column/row layouts.

LaTeX Table Example
There are extended features in LaTeX for creating a table of almost any type. Here I present the most basic table that you could create using LaTeX. Begin with creating simple tables like these and then refer to LaTeX guides to use more advanced features as you learn more. Here is an example for the syntax of a table:

\begin {tabular} {| l | c | r |}
\hline
A & B & C \\
\hline
D & E & F \\
\hline
G & H & I \\
\hline
\end {tabular}

This is how the LaTeX table corresponding to the above data will look like:

A
B
C
D
E
F
G
H
I

There are various other commands that let table rows to span across columns, columns to span across rows, and format data within table cells. You will find a detailed explanation of all these commands and their usage in any LaTeX introductory manual.

For more advanced editing options, refer to a LaTeX manual. As you can see, LaTeX is quite simple to use, once you get a hang of the syntax. There are advanced LaTeX editors available which function according to the WYSIWYG (what you say is what you get) principle and are ideal for people who don’t want to write the LaTeX code in detail. However, it helps if you know the LaTeX syntax when you are correcting typesetting errors. The only way to get better at LaTeX formatting is to practice using it frequently.