Text Alignment in LaTeX: Center, Left, Right, Justify, and Align Equations

Date Published

Text Alignment in LaTeX: Centering, Flushing, and Justification

LaTeX justifies text by default, and you change the alignment of a block with three environments: center, flushleft, and flushright. The matching switches \centering, \raggedright, and \raggedleft do the same job inside a group, a figure, or a table cell without adding vertical space. For equations, alignment is a separate system: the align environment from amsmath lines up multi-line equations at every & you place.

This guide covers all of it: centering and flushing paragraphs, when to use \centering instead of center, the ragged2e package for better-looking ragged text, \hfill for one-line layouts, column alignment in tables, figures and captions, title pages, and a full section on aligning equations with align, align*, aligned, and alignat.

Quick answer: How do you right align text in LaTeX? Wrap the text in \begin{flushright} ... \end{flushright}. Inside a figure, table cell or group use the declaration {\raggedleft text\par}, and to push a single item to the right margin of a line write \hfill text.

Centering and left align: \begin{center} or \centering centers; \begin{flushleft} or \raggedright left-aligns. Equations are aligned with the align environment from amsmath, putting & before each =.

LaTeX Alignment Cheat Sheet: Right Align, Center, Left and Equations

Every alignment command in one compilable file. Use the copy button and paste it into any LaTeX editor:

1\documentclass{article}
2\usepackage{amsmath}
3\usepackage{array}
4\begin{document}
5
6% Right align a block of text
7\begin{flushright}
8Jane Doe\\
912 March 2026
10\end{flushright}
11
12% Right align inside a group, figure or table cell (end with \par)
13{\raggedleft A right-aligned paragraph.\par}
14
15% Push one item to the right margin on the same line
16\noindent Left side \hfill Right side
17
18% Center a block of text
19\begin{center}
20Centered text
21\end{center}
22
23% Left align (ragged right)
24\begin{flushleft}
25Left-aligned text
26\end{flushleft}
27
28% Table columns: l = left, r = right, fixed-width right-aligned column
29\begin{tabular}{l r >{\raggedleft\arraybackslash}p{3cm}}
30Item & Qty & Price \\
31Pens & 12 & 4.50 \\
32\end{tabular}
33
34% Align equations at the equals sign
35\begin{align}
36 f(x) &= (x+1)^2 \\
37 &= x^2 + 2x + 1
38\end{align}
39
40\end{document}

Try this in Octree — free LaTeX editor with AI, compiles in your browser

Centering Text in LaTeX: center vs \centering

The center environment

center is the right tool for a centered block in the middle of running text. It adds a little vertical space above and below the block (the same amount a list gets), and each \\ inside it starts a new centered line:

1\documentclass{article}
2\begin{document}
3Some normal justified text before the block.
4\begin{center}
5This paragraph is centered.\\
6So is this second line.
7\end{center}
8Normal text resumes.
9\end{document}

\centering

\centering is a declaration: it changes the alignment from the point it appears until the end of the current group or environment. It adds no extra vertical space, which is why it is the correct choice inside figure, table, minipage, and titlepage, where the extra skip from the center environment would look wrong.

1\documentclass{article}
2\usepackage{graphicx}
3\begin{document}
4\begin{figure}[htbp]
5 \centering
6 \rule{4cm}{2cm}
7 \caption{A centered figure; the caption is set by the caption machinery.}
8\end{figure}
9
10{\centering This paragraph is centered inside a group.\par}
11\end{document}

Two rules: wrap \centering in braces when you use it in running text, so it stops at the closing brace, and make sure the paragraph ends (with \par or a blank line) before the group closes. Without the \par, the paragraph is finished after the group ends, with the normal justified setting, and nothing is centered.

\centerline{...} centers a single line without starting a new paragraph. It is a plain TeX command that does not wrap, so limit it to one short line.

Right Align and Left Align in LaTeX: flushright, \raggedleft, flushleft

The flushleft environment and the \raggedright declaration give left-aligned, ragged-right text; flushright and \raggedleft give right-aligned text. The environment-versus-declaration distinction is the same as for centering: environments add vertical space and are for blocks in prose, declarations are for insides of other environments.

1\documentclass{article}
2\begin{document}
3\begin{flushleft}
4Left-aligned text with a ragged right edge. Lines are not stretched to
5the margin, so the inter-word spacing stays even.
6\end{flushleft}
7
8\begin{flushright}
9Right-aligned text, useful for dates,\\
10signatures, and the closing of a letter.
11\end{flushright}
12
13{\raggedleft A right-aligned paragraph inside a group.\par}
14\end{document}

Left-aligning the whole document

Put \raggedright in the preamble (or just after \begin{document}) and every paragraph is set flush left. Standard \raggedright has one flaw: it switches hyphenation off and makes the right margin very ragged. The ragged2e package provides improved versions, \RaggedRight, \RaggedLeft, and \Centering, plus the FlushLeft, FlushRight, and Center environments, that keep hyphenation and allow a small amount of stretch, so the edge is less jagged. It also provides \justifying to switch back to justified text inside a ragged region.

1\documentclass{article}
2\usepackage{ragged2e}
3\RaggedRight
4\begin{document}
5This document is set ragged right with hyphenation still enabled, which looks
6considerably better than the kernel's \verb|\raggedright| over a long paragraph.
7
8{\justifying This paragraph is justified again.\par}
9\end{document}

Many style guides for theses and accessible documents ask for ragged-right text; ragged2e is the way to deliver it.

One-Line Alignment with \hfill

\hfill inserts rubber space that expands to fill the line, so Left\hfill Right puts one word at each margin. Two \hfills produce three evenly spaced items. This is the idiom for a job title on the left and dates on the right in a résumé, or a name and a page number in a header.

1\documentclass{article}
2\begin{document}
3\noindent Senior Engineer \hfill 2021 -- present\\
4\noindent Left \hfill Centre \hfill Right
5\end{document}

\hfill at the very start of a line is discarded unless it is preceded by something (\noindent plus \mbox{}\hfill Right is the usual fix for pushing a lone item right).

Alignment in Tables

The column specifier of tabular controls alignment: l is left, c is center, r is right, and p{3cm} is a justified paragraph column of fixed width. To override a single cell, wrap it in \multicolumn{1}{c}{...}; the first argument is how many columns to span (1 for just this cell), the second is the alignment for that span.

1\documentclass{article}
2\usepackage{array, booktabs}
3\begin{document}
4\begin{tabular}{l c r}
5\toprule
6Item & Qty & Price \\
7\midrule
8Pen & 2 & 1.50 \\
9\multicolumn{1}{c}{Notebook} & 1 & 4.25 \\
10\bottomrule
11\end{tabular}
12
13\medskip
14\begin{tabular}{>{\raggedright\arraybackslash}p{3cm} >{\centering\arraybackslash}p{3cm}}
15A left-aligned paragraph cell that wraps. & A centered paragraph cell that also wraps. \\
16\end{tabular}
17\end{document}

Inside a p{} column, use \raggedright or \centering via the array package's >{...} prefix; \arraybackslash is needed afterwards because \raggedright redefines \\. For vertical alignment of a cell, the array package adds m{width} (middle) and b{width} (bottom) to the default top-aligned p{width}. Numbers are best aligned on the decimal point with siunitx's S column.

Figures, Captions, and Title Pages

Use \centering inside figure and table, as shown above, never the center environment, which adds unwanted space. Captions are centered when they fit on one line and justified when they wrap; the caption package changes this with \usepackage[justification=centering]{caption} or justification=raggedright.

A title page is a titlepage environment with \centering and vertical spacing:

1\documentclass{article}
2\begin{document}
3\begin{titlepage}
4 \centering
5 \vspace*{3cm}
6 {\Huge Thesis Title\par}
7 \vspace{1cm}
8 {\Large Author Name\par}
9 \vfill
10 {\large University Name\\ 2026\par}
11\end{titlepage}
12\end{document}

The \par at the end of each braced block is essential: it closes the paragraph while \centering is still in effect.

How to Align Equations in LaTeX with the align Environment

Display math is centered by default, in equation and \[ ... \]. The [fleqn] class option to amsmath (\usepackage[fleqn]{amsmath}) sets all displays flush left instead, which some journals require.

For multi-line equations, use align from amsmath. Every line ends with \\, and every & marks an alignment point: in the standard pattern you put & just before the = sign on each line so the equals signs line up in a column. Each line gets its own equation number; align* suppresses all numbers, and \nonumber or \notag suppresses the number on a single line.

1\documentclass{article}
2\usepackage{amsmath}
3\begin{document}
4\begin{align}
5f(x) &= (x+1)^2 \\
6 &= x^2 + 2x + 1 \label{eq:expanded} \\
7g(x) &= \sin x \cos x \nonumber \\
8 &= \tfrac{1}{2}\sin 2x
9\end{align}
10Equation~\eqref{eq:expanded} is the expanded form.
11
12\begin{align*}
13a &= b + c & x &= y + z \\
14d &= e & w &= v
15\end{align*}
16\end{document}

Note the second example: align is also a multi-column environment. Alternating & characters mean "align here" and "start the next column", so a &= b & x &= y builds two columns of aligned equations side by side.

aligned, alignat, and gather

  • aligned is a building block that goes inside another display, such as equation, when you want aligned lines to share one equation number. Use it as \begin{equation}\begin{aligned} ... \end{aligned}\end{equation}.
  • alignat{n} works like align with n alignment columns but puts no space between them, giving you full control; it is the environment for lining up a system of equations where the coefficients must be in columns.
  • gather centers each line individually with no alignment points, for a stack of unrelated equations.
  • split behaves like aligned but can only be used inside equation, with a single number for the whole block.
  • cases aligns the branches of a piecewise definition with a left brace.
1\documentclass{article}
2\usepackage{amsmath}
3\begin{document}
4\begin{equation}
5\begin{aligned}
6 2x + 3y &= 7 \\
7 x - y &= 1
8\end{aligned}
9\end{equation}
10
11\begin{alignat}{2}
12 2x &+ 3y &&= 7 \\
13 x &- y &&= 1
14\end{alignat}
15
16\begin{gather}
17 a = b \\
18 c + d = e
19\end{gather}
20
21\[ |x| = \begin{cases} x & \text{if } x \ge 0 \\ -x & \text{otherwise} \end{cases} \]
22\end{document}

Two mistakes account for most align errors. Writing &= on one line and =& on the next misaligns the symbols; keep the & on the same side of = every line. Putting a blank line inside align produces "Paragraph ended before \align was complete": remove the blank line. For how numbers, labels, and \eqref interact with these environments see https://www.useoctree.com/learn/equation-numbering, and for the wider notation toolkit see https://www.useoctree.com/learn/mathematical-expressions.

Paragraph-Level Controls

  • \noindent removes the first-line indent of one paragraph; \setlength{\parindent}{0pt} removes it everywhere.
  • \hangindent=2em \hangafter=1 indents every line after the first, for bibliography-style entries.
  • quote and quotation indent a block on both sides; quotation also indents the first line of each paragraph.
  • minipage[t], [c], and [b] align the box's top, center, or bottom line with the surrounding text, which is how two side-by-side boxes are made to align at the top.

Common Alignment Errors in LaTeX

Right align or centering has no effect inside a group

Writing {\raggedleft Some text} leaves the text justified, because LaTeX applies alignment when the paragraph ends, and here the paragraph ends after the closing brace, when \raggedleft is no longer in force. Fix: end the paragraph inside the group, {\raggedleft Some text\par}. The same applies to \centering and \raggedright.

! LaTeX Error: There's no line here to end.

This appears when \\ comes right after \begin{flushright} or \begin{center}, after a blank line, or is doubled to add space. Fix: only use \\ to end a line that has text on it, and add vertical space with \vspace{1em} instead of empty lines.

! Misplaced \noalign in a right-aligned table column

A column declared as >{\raggedleft}p{3cm} redefines \\, so the next \hline or \midrule fails with "Misplaced \noalign". Fix: restore the row end with \arraybackslash: >{\raggedleft\arraybackslash}p{3cm} (needs the array package).

! Misplaced alignment tab character &

An & only means "align here" inside align, tabular and similar environments. Used in plain text or inside equation it raises this error. Fix: switch the display to align (or wrap the lines in aligned inside equation), and type a literal ampersand in text as \&.

Quick Reference

Goal

Block in text

Inside figure, table, or group

Center

\begin{center}

\centering

Left (ragged right)

\begin{flushleft}

\raggedright or \RaggedRight

Right (ragged left)

\begin{flushright}

\raggedleft or \RaggedLeft

Justify (default)

nothing needed

\justifying (ragged2e)

Table column

l, c, r, p{w}

\multicolumn{1}{c}{...}

Equation column

align, alignat

& before each =

Flush-left displays

\usepackage[fleqn]{amsmath}

Frequently Asked Questions

How do I center text in LaTeX?

Wrap a block in \begin{center} ... \end{center}. Inside a figure, table, or title page, use the \centering declaration instead, which adds no extra vertical space. For one line, \centerline{...} works.

What is the difference between \centering and the center environment?

center is an environment that adds vertical space above and below the block; \centering is a declaration that affects everything until the end of the current group and adds no space. Use center in running text and \centering inside floats.

How do I right-align text in LaTeX?

Use \begin{flushright} ... \end{flushright} for a block, \raggedleft inside a group, or \hfill before the text to push a single item to the right margin on the same line as something else.

How do I align equations at the equals sign?

Use the align environment from amsmath and put & immediately before = on every line, ending each line except the last with \\. Use align* for no numbers, \nonumber to drop one number, and aligned inside equation for one shared number.

How do I make the whole document left-aligned instead of justified?

Load ragged2e and put \RaggedRight in the preamble. The kernel's \raggedright also works but disables hyphenation, which produces a much more ragged edge.

How do I right align text in a table cell?

Use the r column type, as in \begin{tabular}{l r}. For a fixed-width column that wraps and is right-aligned, load array and use >{\raggedleft\arraybackslash}p{3cm}. For a single cell, \multicolumn{1}{r}{text} overrides the column alignment.

How do I center a figure or table in LaTeX?

Put \centering directly after \begin{figure} or \begin{table}. Avoid the center environment there: it adds extra vertical space on top of the float's own spacing.

Write and compile your next document in Octree, the AI LaTeX editor that suggests the right alignment environment as you type: https://www.useoctree.com

Try this in Octree — free LaTeX editor with AI, compiles in your browser