Aligning figures and tables is a common challenge when typesetting documents in LaTeX. Unlike text, these elements can span the entire page width and need to be consciously positioned. Improper alignment can disrupt the reading flow and appear unprofessional. LaTeX provides environments like figure and table to contain these elements, but they are aligned left by default. Manual adjustment is required to center them on the page or get the desired vertical position. Several techniques exist for centering, including:
Table of Contents ToggleHowever, no single method works for every scenario. The optimum approach depends on elements like caption usage, column layouts, and page dimensions.
This article offers best practices for intelligently centering figures, tables, and related elements in complex LaTeX documents.
The center environment is the primary LaTeX method for horizontally centering figures, tables, and other content on the page.
Any content inside \begin and \end gets centered between the current margins. This works well for single figures, tables, math expressions, algorithms, code snippets, and similar content that should appear centered rather than left or right aligned.
\begin \includegraphics \end
Here, the \includegraphics command to display an image is wrapped inside center . So the final rendered diagram gets horizontally centered.
The same applies for tables:
\begin \begin < |c|c| >\hline Cell 1 & Cell 2 \\ \hline \end \end
This ensures the tabular content inside is centered as well. Centered positioning persists until \end .
When finer control over horizontal spacing is needed, the \hspace command can help. It lets you insert custom space that moves an element's position left or right.
Syntax options like:
\hspace
Will add 2cm of horizontal space, effectively pushing the next element over. Negative values like \hspace adjust positioning the other way.
For example, to get a figure perfectly centered on a custom page layout, calculate the required offset manually between margins. Then apply \hspace spacing before or within the figure environment.
This kind of micro-level spacing tune is useful to position oddly sized figures or elements spanning multiple text columns.
Latex floats like figure and table offer placement specifiers for vertical adjustability.
Position the element at the top of the page. Similarly,
Moves it to the bottom. This provides high-level control over vertical placement within the current page margin boundaries.
\begin[b] \centering \begin . tabulated data. \end \end
Puts the entire table environment at the bottom of the page. Figures behave similarly as needed.
The \vspace command adds precise spacing along the vertical axis. This fine tunes position for a figure, table, or any other page element.
Basic options like:
\vspace
Inserts 1cm of vertical space above the elements current position, moving it down. Negative values like
\vspace
Shifts elements up instead. When utilized within floats or custom page geometry, precise vertical readjustments are possible.
\begin[h] \centering \vspace \begin . \end \end
Nudges the table up by 3mm to fine tune its ultimate vertical position.
Aim for consistency in alignment styles for all figures, tables, diagrams and similar additive visuals. Center floating elements the same way throughout a LaTeX work for cohesive appearance.
For example, make all table captions left-aligned while figures are captioned centered. Or universally apply top-[t] and bottom-[b] positioning to floats rather than a random mix.
This consistency in alignment approach prevents readers from being distracted by irregular or disjointed document styles from one section to the next.
How figures, tables, and other page elements are centered inevitably depends on the document's margins, columns, and usable page space.
For example, in two-column layouts, content width is limited. So utilize width-spanning [h] environments for more horizontally room. Rely more on precise vertical tuning with [t] , [b] and \vspace for granular adjustments.
On pages with a single wide text block, center provides excellent horizontal centering. But watch out for orphaned elements stranded by themselves at the very bottom or top with too much vertical space.
So consider page geometry demands when tuning alignment of floats and visuals for centering needs in a given paper, report, book or article.
Occasionally, an element can be too wide for the normal text area, like an oversized diagram or ultrawide table.
In these cases, allow the content to spill out of the center and width-span margins by deliberately breaking alignment. Essentially extending a special element outside the margins to give it required horizontal space.
Just be sure to reset default alignment for subsequent blocks by closing such custom groups.
This way, a necessarily wide element gets proper showcase without affecting central alignment of other figures/tables in the document.
The following demonstration centers a math expression horizontally:
\begin $x = \frac>$ \end
Output would showcase the quadratic formula equation authentically centered on the resulting page when compiled.
To center an entire table + caption unit, wrap the table environment in center :
\begin \begin \centering \caption \begin < c c c >\hline & Column 1 & Column 2 \\ \hline Row 1 & values & data \\ Row 2 & values & data \\ \hline \end \end \end
This keeps both tabular data and caption text centered as one unit.
For precise vertical positioning of a figure, set a default top/bottom location, then microadjust:
\begin[b] \centering \vspace \includegraphics[width=0.9\linewidth] \caption \label \end
First position at bottom with [b]. Then apply negative \vspace to nudge the entire figure 5mm up from there. This combines macro and micro adjustments.