LaTeX Typesetting – Tables

[This article was first published on Software for Exploratory Data Analysis and Statistical Modelling, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

One area of LaTeX that is not always straightforward is producing tabular material. In this post we will look at some of the basics of creating tables in a LaTeX document.

Fast Tube
Fast Tube by Casper

When creating tables there is a tabular environment that can be used and we need to specify the number of columns using characters to indicate the text alignment in each column. A simple three column table where all columns are centred would be produced like this:


On individual lines of data the ampersand character is used to indicate different columns. So if we wanted to add a heading to the table we might add the following line within the tabular environment:

Name & Description & Frequency \

The end of the line is indicated by the \ and we can move on to the next row of the table on the following line.

We can add vertical lines between the columns by adding information to the column alignment specification. For example to add these vertical lines between all three columns we would write:


Horizontal lines to cover the whole row can be added at the end of each line to get LaTeX to draw them underneath the most recent row of the table.

Name & Description & Frequency \ hline

This draws a line under the title row of our table.

An example of a complete table is given below using data from the International Monetary Fund for the GDP in 2009 for the top ten nations.

begin{tabular}{|l|c|} hline
Country & GDP (USD millions) \ hline
United States & 14,119,050 \
Japan & 5,068,894 \
People's Republic of China & 4,984,731 \
Germany & 3,338,675 \
France & 2,656,378 \
United Kingdom & 2,178,856 \
Italy & 2,118,264 \
Brazil & 1,574,039 \
Spain & 1,467,889 \
Canada & 1,336,427 \ hline

Other useful resources are provided on the Supplementary Material page.

To leave a comment for the author, please follow the link and comment on their blog: Software for Exploratory Data Analysis and Statistical Modelling. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)