Creating Tables
Learn how to build, format, and align tables in LaTeX using the tabular environment.
Tables in LaTeX are built using the tabular environment. Unlike Word where you draw a table visually, in LaTeX you specify the layout of the columns and then enter the data row by row.
Basic Table Structure
To create a table, you must declare how many columns it has and how they should be aligned.
l= left-alignedc= center-alignedr= right-aligned|= vertical line border
\begin{tabular}{|l|c|r|}
\hline
Item & Quantity & Price \\
\hline
Apples & 5 & \$2.50 \\
Oranges & 10 & \$5.00 \\
\hline
\end{tabular}Anatomy of the Code
{|l|c|r|}tells LaTeX to create 3 columns (Left, Center, Right) separated by vertical borders.\hlinedraws a horizontal line across the table.&is the column separator. It moves the text into the next column.\\is the row separator. It tells LaTeX to start a new row.
Floating Tables (The Table Environment)
The tabular environment just draws the grid. If you want your table to float (meaning LaTeX will automatically place it at the top or bottom of the page for optimal layout) and if you want to add a caption, you must wrap it in the table environment.
\begin{table}[ht]
\centering
\caption{Fruit Prices for Q1 2026}
\begin{tabular}{lcr}
\hline
Item & Quantity & Price \\
\hline
Apples & 5 & \$2.50 \\
Oranges & 10 & \$5.00 \\
\hline
\end{tabular}
\label{tab:fruits}
\end{table}The [ht] tells LaTeX where to place the table. h means "here" (exactly where the code is written), t means "top of the page", and b means "bottom of the page".
Advanced Formatting: booktabs
For academic publishing, vertical lines (|) are generally frowned upon. Standard practice involves using the booktabs package, which provides beautiful, professionally spaced horizontal rules.
Add \usepackage{booktabs} to your preamble, and use these rules instead of \hline:
\begin{tabular}{llr}
\toprule
Item & Category & Price (\$) \\
\midrule
Apple & Fruit & 1.50 \\
Bread & Bakery & 2.00 \\
\bottomrule
\end{tabular}