Tables
Last updated
Last updated
Below you can see the simplest working example of a table
The tabular
environment is the default LATEX method to create tables. You must specify a parameter to this environment, in this case {c c c}
. This tells LATEX that there will be three columns and that the text inside each one of them must be centred. You can also use r
to align the text to the right and l
for left alignment. The alignment symbol &
is used to specify the breaks in the table entries. There must always be one less alignment symbol in each line than the number of columns. To go to the next line of your table, we use the new line command \\
. We wrap the entire table inside the center
environment so that it will appear in the center of the page.
The tabular environment is more flexible, you can put separator lines in between each column.
You can add borders using the horizontal line command \hline
and the vertical line parameter |
.
{ |c|c|c| }
: This declares that three columns, separated by a vertical line, are going to be used in the table. The |
symbol specifies that these columns should be separated by a vertical line.
\hline
: This will insert a horizontal line. We have included horizontal lines at the top and bottom of the table here. There is no restriction on the number of times you can use \hline
.
Below you can see a second example.
Creating tables in LATEX can be a bit tricky sometimes, so you may want to use the TablesGenerator.com online tool to export LATEX code for tabulars. The File > Paste table data option lets you copy and paste data from spreadsheet applications.
You can caption and reference tables in much the same way as images. The only difference is that instead of the figure
environment, you use the table
environment.