announcement

Share the latest technology trends or photos of gadgets you love.

How to Create a LaTeX Table

How to Create a LaTeX Table

If you are looking for guidelines on designing a basic LaTeX table, a glance through this article will clarify the matter for you. Read to know all about it.
Omkar Phatak
If you are an academician who is researching in physics, mathematics, chemistry, or any other field of research, mastering LaTeX is a must. It 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 one, 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 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 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 them, with different formatting and column/row layouts.
Example
There are extended features for creating a table of almost any type. Here, I present the most basic version 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 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 span across columns, make columns span across rows, and format data within table cells. You will find a detailed explanation of all these commands and their usage in any introductory manual. For more advanced editing options, refer a LaTeX manual.