Firstly, start off your table in http://www.tablesgenerator.com/.

Tables Generator will do a lot for you. Its most useful features are importing from .csv and merging cells. The Booktabs table style (alternative to default table style from the menu) looks a bit nicer and is “publication quality”. Note that publication quality tables should not contain vertical lines.

Screen shoti of Tables Generator
Screen shot of Tables Generator
Code#1

Code #1 is the code from Tables Generator with the addition of caption, label and Latex document begin-end (so it’s compilable). Continuing from that table, let’s centre the contents of columns 1-3 and the whole table in your document, by adding \centering and changing the table specs from l’s to c’s: Code #2.

Code#2

Finally, if your cell contents are long and need wrapping:

table 3

 Note that if your table is too wide for your document margins, then LaTex issues a warning, not an error. So you need check for warnings like “Overfull \hbox (9.75735pt too wide) in paragraph at lines 55–63” in your compilation log. A quick solution to wide cells is like this (Code#4):

Code#4
Code#4

But this solution does not include decent central alignment. Using m (so m{2cm} instead of p{2cm}) would do the vertical centering (e.g. look how the first row is alligned), but still not horizontal. So following this StackOverflow post, I started defining column types and widths using the array package. See Code#5.

Code#5
Code#5

Next time I might write a post on how to add extra space between lines.