Table in LaTeX: Make, Center, Caption and Merge Cells
November 11, 2026 · 12 min read
Table in LaTeX: How to Make, Center, and Caption Tables
A table in LaTeX has two layers. The tabular environment draws the grid, and the table float wraps it to add centering, a caption, a label and page placement. Get that split right and most table problems disappear. Below you'll see how to make a table in LaTeX step by step, then merged cells, alignment, footnotes and long tables.
How Do You Make a Table in LaTeX? Start With tabular
Every grid starts the same way. Open a tabular environment and give it a column spec: one letter per column. l aligns left, c centers, r aligns right, and p{3cm} makes a fixed-width column whose text wraps. A | between letters draws a vertical rule.
Inside the environment, & separates cells and \\ ends a row. \hline draws a rule across the full width, and \cline{2-3} draws one under columns 2 to 3 only.
\documentclass{article}
\begin{document}
\begin{tabular}{|l|c|r|}
\hline
Item & Qty & Price \\
\hline
Apples & 5 & 0.99 \\
Pears & 3 & 1.25 \\
\hline
\end{tabular}
\end{document}
That compiles to a boxed three-column grid: names flush left, quantities centered, prices flush right, with a rule above the header, under it and under the last row. Spaces around & are ignored, so line the source up however you like.
Characters with a special meaning need a backslash inside cells: write \&, \%, \_ and \#. A bare % silently hides the rest of the line, a bare & starts a new cell, and a bare _ or # stops the compile with an error.
Two details from the LaTeX2e reference for tabular save debugging time. The \\ after the last row is optional unless an \hline follows it. LaTeX also pads each column with \tabcolsep (6pt by default) on both sides, and an empty @{} in the spec removes that padding at the table's edges.
How Do You Center a Table on the Page in LaTeX?
A bare tabular sits in the text like a big word, so it starts at the paragraph indent. To center it, wrap it in a table float and put \centering on the first line inside. The float is also where the caption, the label and the placement options live.
\begin{table}[htbp]
\centering
\caption{Fruit prices per kilogram}
\label{tab:fruit}
\begin{tabular}{lcr}
\hline
Item & Qty & Price \\
\hline
Apples & 5 & 0.99 \\
Pears & 3 & 1.25 \\
\hline
\end{tabular}
\end{table}
Use \centering rather than \begin{center} inside a float. The center environment adds vertical space above and below its content, and \centering doesn't, so you avoid a gap between the caption and the grid. Our LaTeX text alignment guide compares the two for ordinary text.
The [htbp] argument lists where LaTeX may put the float: here (h), the top of a page (t), the bottom (b) or a separate float page (p). The default for table in the article and book classes is tbp. LaTeX treats a lone h as too restrictive, so it changes it to ht and prints a warning.
Adding ! lifts, for that float only, the limits on how many floats a page holds and how much of it they fill. If a table must stay exactly where you typed it, load the float package and use [H].
Caption in LaTeX Tables: Labels and Cross-References
\caption does two jobs. It prints "Table 1: Fruit prices per kilogram" and it steps the table counter. \label then records the current number under a key you choose, and \ref prints that number anywhere in the document.
Order matters. The \label must come after \caption, or it usually grabs the number of the current section instead. If your reference prints something like 2.1 where you expected a table number, this is the usual cause. The reference manual's rule is short: put labels after captions in figures and tables.
As Table~\ref{tab:fruit} shows, pears cost more per kilogram.
The ~ is a non-breaking space, so "Table" and its number never split across lines. If you load hyperref, \autoref{tab:fruit} prints the word "Table" for you and makes it a link. The tab: prefix isn't required, but it keeps table keys apart from fig: and sec: keys.
Where should the caption go? LaTeX puts it wherever you write it. Most style guides place table captions above the table and figure captions below, which is why the example puts \caption before tabular. Every captioned table also appears in \listoftables, which works like \tableofcontents for tables. Our LaTeX table of contents guide covers both commands.
Multicolumn and Multirow: Merging Cells in a LaTeX Table
A header that spans two columns is the classic multicolumn table in LaTeX. \multicolumn{2}{c}{Sales} replaces two cells with one centered cell. It's core LaTeX, so no package is needed, and its middle argument overrides the column spec for that cell, vertical rules included.
Merging down a column needs the multirow package. Its basic form is \multirow{2}{*}{North}: the number of rows, a width (* means the text's natural width) and the text. Leave the matching cells in the rows below empty, or \multirow writes over them.
% preamble: \usepackage{booktabs, multirow}
\begin{tabular}{llrr}
\toprule
& & \multicolumn{2}{c}{Sales} \\
\cmidrule(lr){3-4}
Region & Store & 2025 & 2026 \\
\midrule
\multirow{2}{*}{North} & Leeds & 120 & 135 \\
& York & 98 & 104 \\
\midrule
South & Bath & 87 & 91 \\
\bottomrule
\end{tabular}
The result has a "Sales" heading centered over the two year columns, a short rule under it, and "North" vertically centered beside its two stores. \cmidrule(lr){3-4} is the booktabs version of \cline, trimmed slightly at both ends so neighboring rules don't touch.
Prefer filling in a grid? Our LaTeX Table Generator builds the plain tabular for you from a grid editor. Booktabs rules are on by default, special characters are escaped, and you save the result as a .tex file. It doesn't output merged cells, so add \multicolumn and \multirow by hand afterwards.
LaTeX Table Vertical Alignment: p, m and b Columns
LaTeX table vertical alignment depends on the column type. A p{width} column works like a top-aligned paragraph box, so a short cell next to a long, wrapped cell sits at the top of the row. The array package adds m{width}, which centers the cell vertically against the rest of the row, and b{width}, which aligns it to the bottom.
% preamble: \usepackage{array}
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{m{2.5cm} m{6cm}}
\hline
Short label & A longer description that wraps onto two or three lines inside its 6 cm column. \\
\hline
\end{tabular}
Here "Short label" lines up with the middle of the wrapped text instead of its first line. \arraystretch multiplies the row height; its default is 1, and values around 1.2 to 1.3 give dense tables room to breathe.
Don't confuse column types with the optional [t], [b] or [c] argument on tabular itself. That one aligns the whole table against the baseline of surrounding text, and it has no visible effect on a table alone inside a centered float. One more trap: \\ inside a p cell ends the whole row, so use \newline for a line break within the cell. For a table that must fill an exact width, the tabularx package adds X columns that stretch to fit.
Adding a Footnote in LaTeX Table Cells
A plain \footnote inside tabular fails quietly: the mark appears in the cell, but the note text never prints. Putting a footnote in LaTeX table cells therefore needs a workaround.
Our preferred fix is the threeparttable package. You mark the cell with \tnote{a} and write the notes in a tablenotes list directly under the grid, matched to the table's width.
% preamble: \usepackage{threeparttable, booktabs}
\begin{table}[htbp]
\centering
\begin{threeparttable}
\caption{Survey responses}
\label{tab:survey}
\begin{tabular}{lr}
\toprule
Group & Responses \\
\midrule
Students\tnote{a} & 412 \\
Staff & 86 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[a] Includes part-time students.
\end{tablenotes}
\end{threeparttable}
\end{table}
The output shows a superscript "a" after "Students" and the note itself under the bottom rule. The notes aren't numbered automatically, so you pick each marker yourself.
Without a package, put \footnotemark in the cell and \footnotetext{...} right after \end{table}. The note joins the page's normal footnotes, but the float can drift to another page and leave its note behind. The tablefootnote package is a third route for floating tables. Inside longtable, covered next, \footnote works in body rows, though not in the repeated head or foot. Our guide to LaTeX footnote commands covers the \footnotemark and \footnotetext pair in more detail.
Long Table in LaTeX: Break It Across Pages With longtable
A tabular can't break across pages, so a long table in LaTeX runs off the bottom. The longtable package fixes that. Its environment replaces both table and tabular, so you don't wrap it in a float. The \caption goes inside, ended with \\.
% preamble: \usepackage{longtable, booktabs}
\begin{longtable}{lrr}
\caption{Monthly rainfall by city}\label{tab:rain} \\
\toprule
City & Month & mm \\
\midrule
\endfirsthead
\multicolumn{3}{l}{\emph{Table \thetable, continued}} \\
\toprule
City & Month & mm \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{\emph{Continued on next page}} \\
\endfoot
\bottomrule
\endlastfoot
Leeds & Jan & 71 \\
Leeds & Feb & 52 \\
% ...hundreds more rows
\end{longtable}
Everything before \endfirsthead prints on the first page only. The block ending in \endhead repeats at the top of every later page, \endfoot prints at the bottom of each page that continues, and \endlastfoot closes the final page. The longtable documentation warns that columns may not line up until you've run LaTeX several times, so compile again before you worry.
If your tables start life in Markdown, pandoc already writes them as longtable; our Markdown to LaTeX guide covers that conversion.
Cleaner Rules With booktabs, and Rotating a Wide Table
The booktabs package replaces \hline with three weights of rule: \toprule, \midrule and \bottomrule, plus \cmidrule for partial rules. It also adds sensible spacing around each rule, which \hline lacks. The booktabs manual is blunt about the rest. Its first rule says "Never, ever use vertical rules" and the second bans double rules.
We prefer that style for almost every table: no vertical lines, three horizontal rules, @{} at both edges, and \arraystretch slightly above 1. Readers scan rows, not columns, and vertical rules mostly add clutter. The boxed |l|c|r| grid from the first example is fine for a worksheet, but it looks dated in a paper or thesis. Here's the template we start every table from:
% preamble: \usepackage{booktabs}
\begin{table}[htbp]
\centering
\caption{Fruit prices per kilogram}
\label{tab:fruit}
\begin{tabular}{@{}lrr@{}}
\toprule
Item & Qty & Price \\
\midrule
Apples & 5 & 0.99 \\
Pears & 3 & 1.25 \\
\bottomrule
\end{tabular}
\end{table}
It prints a heavy rule above the header, a thinner one below it and another heavy rule at the bottom. There are no vertical lines and no extra padding at the outer edges.
When a table is too wide for the page, rotate it. The rotating package's sidewaystable environment works like table but turns the whole float 90 degrees, landscape style. To rotate entire pages of content, use the landscape environment from pdflscape. It also sets the PDF's page rotation, so viewers show the page upright on screen.
Which Table Commands Work in Markdown Math (KaTeX)?
Our editor renders math with KaTeX inside $$ blocks, and KaTeX is a math renderer, not a document compiler. It has no tabular, table, \caption, \label or longtable. Its array environment is the closest stand-in: it takes the same l, c, r column spec, | for solid rules, : for dashed ones, \hline and \hdashline.
Per KaTeX's supported functions list, array doesn't support \cline or \multicolumn. Its column spec accepts only l, c, r, | and :, so a p{width} column raises a parse error. Wrap words in \text{...} so they don't render as italic math variables, and use $$ delimiters, because our preview doesn't support \[ ... \]. Try the column spec and rules below.
The limitation is real: the preview can't show float placement, numbered captions, cross-references or page breaks, so check final layout in an actual LaTeX compile. For plain data on the web, a pipe table is simpler than array, and our Markdown table guide covers that syntax. For matrices and augmented matrices, see how to write a matrix in Markdown.
A table in LaTeX gets easier once you treat the two layers separately: tabular for the grid, table for centering, the caption, the label and placement. Add booktabs for clean rules, multirow for merged rows, threeparttable for notes and longtable once a table outgrows a page. To sketch the grid fast, start in the LaTeX table tool, then add captions and merged cells by hand.