Text Alignment in LaTeX: Center, Flush Left, Flush Right and Justify

Quick answer

  • Center a block: \begin{center} ... \end{center}.
  • Center inside a figure or table: \centering (no extra space).
  • Left or right: flushleft / flushright, or \raggedright / \raggedleft in a group.
  • Justified: the default; \justifying from ragged2e switches it back on.
  • Table cells: l c r columns, or >{\centering\arraybackslash}p{3cm}.
\documentclass{article}
\begin{document}

\begin{center}
  Centred line one\\
  Centred line two
\end{center}

\begin{flushright}
  Right-aligned text
\end{flushright}

\end{document}

LaTeX justifies body text by default: every line runs from the left margin to the right, and the last line of a paragraph is set flush left. This guide is the reference for changing that: the three alignment environments, their declaration forms, the ragged2e package, and alignment in the places it causes trouble (figures, table cells, equations and the vertical centre of a page). For a step-by-step walkthrough, read the text alignment walkthrough on the blog. Every example compiles with pdfLaTeX.

Environments and Declarations

Each alignment has two forms. The environment starts a new paragraph, adds a little vertical space above and below, and ends at \end. The declaration changes alignment from where you write it to the end of the current group, with no added space:

AlignmentEnvironmentDeclarationragged2e version
Centredcenter\centering\Centering, Center
Flush left (ragged right)flushleft\raggedright\RaggedRight, FlushLeft
Flush right (ragged left)flushright\raggedleft\RaggedLeft, FlushRight
Justified(default)(default)\justifying, justify
\documentclass{article}
\begin{document}

Justified text, the default. This paragraph is long enough to wrap, so you can
see both edges line up with the margins of the page.

\begin{flushleft}
Flush-left text keeps a straight left edge and a ragged right edge. This
paragraph is long enough to show the effect.
\end{flushleft}

{\raggedleft
Flush-right text with the declaration inside a group. The paragraph must end
before the closing brace, so it is followed by a par.\par}

{\centering Centred with the declaration.\par}

\end{document}

The declarations act on whole paragraphs, and LaTeX applies the alignment that is in force when the paragraph ends. That is why the examples end with \par before the closing brace: without it, the group closes first and the paragraph comes out justified.

\centering vs the center Environment

Both centre text. The difference is the space: center is built on a list, so it adds a gap above and below like a short quotation. That is right in running text and wrong inside a float, where it pushes the image away from its caption. Inside figure and table, always use \centering:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}[ht]
  \centering
  \includegraphics[width=0.5\linewidth]{example-image}
  \caption{A centred figure.}
\end{figure}

\begin{table}[ht]
  \centering
  \caption{A centred table.}
  \begin{tabular}{lr}
    Item & Value \\
    A    & 1.5
  \end{tabular}
\end{table}

\end{document}

\centering lasts until the float ends, so one line covers the image and the caption. More on figure placement in the figures guide.

Better Ragged Text with ragged2e

\raggedright turns off hyphenation in practice and removes the paragraph indent, so long ragged passages get a very uneven right edge. The ragged2e package adds versions that keep hyphenation, plus \justifying to return to justified text:

\documentclass{article}
\usepackage{ragged2e}
\begin{document}

\RaggedRight
This paragraph is ragged right, but unlike plain raggedright it still
hyphenates long words such as internationalization.

\justifying
This paragraph is justified again, with both edges straight.

\begin{FlushRight}
Right-aligned with ragged2e.
\end{FlushRight}

\end{document}

Put \RaggedRight in the preamble to make a whole document ragged right, a common choice for narrow columns, slides and posters.

Aligning Text in Table Cells

Column letters set the alignment of each column: l, c and r. A p column has a fixed width and wraps its text justified; prefix it with an alignment declaration from the array package to centre or right-align it. \arraybackslash restores \\ as the row end:

\documentclass{article}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\begin{document}

\begin{tabular}{|l|c|r|C{2.5cm}|R{2cm}|}
  \hline
  Left & Centre & Right & Wrapped and centred text & Wrapped, right \\
  \hline
  \multicolumn{1}{|c|}{One centred cell} & x & 10 & a & b \\
  \hline
\end{tabular}

\end{document}

For vertical alignment inside a cell, use m (middle) or b (bottom) instead of p; both need array. The tables guide covers widths, tabularx and multi-row cells.

Aligning Equations Left

Displayed equations are centred. The fleqn class option sets them flush left, indented by \mathindent; leqno moves the numbers to the left. For one left-aligned equation in a centred document, use flalign:

\documentclass[fleqn]{article}
\usepackage{amsmath}
\setlength{\mathindent}{0pt}   % flush with the margin
\begin{document}

\begin{equation}
  E = mc^2
\end{equation}

\end{document}

Without fleqn, flalign pushes its first column pair to the left margin; the trailing && adds an empty pair on the right:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
  \text{centred} = 1
\end{equation}
\begin{flalign}
  a + b &= c &&
\end{flalign}

\end{document}

To line up several equations on their = signs, see multiline equations.

Centering Text Vertically on a Page

Fill the space above and below with \vspace*{\fill}; the starred form keeps the space at the top of the page:

\documentclass{article}
\begin{document}

\thispagestyle{empty}
\vspace*{\fill}
\begin{center}
  {\Huge Centred on the page}\\[1em]
  Horizontally and vertically
\end{center}
\vspace*{\fill}
\clearpage

\end{document}

Common Mistakes

SymptomCauseFix
{\centering text} is not centredThe group closed before the paragraph ended{\centering text\par}
Too much space above a figurecenter environment inside figure\centering
Everything after \centering is centredA declaration lasts until its group endsWrap it in braces or use the center environment
Misplaced \noalign or a broken row in a p column\centering redefined \\ in the last cellAdd \arraybackslash after it
Ugly right edge in ragged text\raggedright barely hyphenates\RaggedRight from ragged2e
Undefined control sequence on \justifyingPlain LaTeX has no justify command; it comes from ragged2e\usepackage{ragged2e}

Frequently Asked Questions

How do I center text in LaTeX?

Wrap it in \begin{center} ... \end{center}, or put \centering at the start of a group or float. Every line is centred, and \\ ends a line. Inside figure and table, use \centering, because the center environment adds extra vertical space around the content.

What is the difference between \centering and \begin{center}?

\centering is a declaration: it centres every paragraph until the end of the current group or environment and adds no space. The center environment is a list-like block that centres its contents and adds a gap above and below, like a paragraph break. Use center in running text and \centering inside figures, tables and boxes.

How do I left-align or right-align text in LaTeX?

Use the flushleft or flushright environment for a block, or the \raggedright and \raggedleft declarations inside a group. For long left-aligned passages, load ragged2e and use \RaggedRight, which keeps hyphenation so the right edge is less jagged.

How do I justify text in LaTeX?

Body text is justified by default, so you only need to undo a change. End the group that set \raggedright or \centering, or, with ragged2e loaded, write \justifying or use the justify environment to switch back to full justification.

How do I center a column in a LaTeX table?

Use c in the column specification, as in \begin{tabular}{lcr}. For a fixed-width column that wraps, load the array package and write >{\centering\arraybackslash}p{3cm}. To centre one cell in a left-aligned column, use \multicolumn{1}{c}{text}.

How do I align equations to the left in LaTeX?

Add the fleqn class option, as in \documentclass[fleqn]{article}, to set every display flush left at the indent \mathindent. For a single equation, use the flalign environment from amsmath with an & at each end of the line.

Next Steps

Free LaTeX Tools

Align anything with AI

Tell Octree's AI to centre a table, right-align a signature block or set your equations flush left, and see the compiled PDF update next to your code.

Try Octree Free →