Tables in LaTeX
Create tables with the tabular environment. Use booktabs for publication-quality styling.
Quick answer
latex
\begin{tabular}{l c r}
Name & Score & Grade \\
\hline
Alice & 95 & A \\
Bob & 82 & B \\
\end{tabular}Column specifiers
| Specifier | Meaning |
|---|---|
| l | Left-aligned column |
| c | Centered column |
| r | Right-aligned column |
| p{3cm} | Fixed-width paragraph column |
| | | Vertical line between columns |
| @{} | Remove inter-column spacing |
Publication-quality with booktabs
The booktabs package replaces \hline with professional horizontal rules. Vertical lines are intentionally omitted.
latex
\usepackage{booktabs}
\begin{tabular}{lcc}
\toprule
Method & Accuracy & Time (s) \\
\midrule
Baseline & 72.3% & 1.2 \\
Our model & 89.1% & 2.7 \\
\bottomrule
\end{tabular}Floating table with caption
latex
\begin{table}[htbp]
\centering
\caption{Comparison of methods}
\label{tab:comparison}
\begin{tabular}{lcc}
\toprule
Method & Accuracy & Time \\
\midrule
A & 72% & 1.2s \\
B & 89% & 2.7s \\
\bottomrule
\end{tabular}
\end{table}
% Reference it:
As shown in Table~\ref{tab:comparison}, ...Spanning multiple columns
latex
\begin{tabular}{lcc}
\toprule
\multicolumn{3}{c}{Results Summary} \\
\midrule
Name & Score & Grade \\
\midrule
Alice & 95 & A \\
\bottomrule
\end{tabular}Spanning multiple rows
latex
\usepackage{multirow}
\begin{tabular}{llc}
\toprule
Group & Item & Value \\
\midrule
\multirow{2}{*}{Group A} & Item 1 & 10 \\
& Item 2 & 20 \\
\bottomrule
\end{tabular}