Text alignment is an important part of formatting documents. By default, LaTeX justifies text, which means it stretches spaces so that both left and right margins are even.
But sometimes you may want left, right, center, or fully justified alignment.
This tutorial explains all alignment methods in LaTeX with proper examples.
Standard LaTeX Environments and Commands
LaTeX provides specific environments and commands for text alignment.
Environment | LaTeX command |
---|---|
center | \centering |
flushleft | \raggedright |
flushright | \raggedleft |
justify | \justifying |
Note that justification requires the ragged2e
package because LaTeX does not provide a built-in justify environment.
Single Column Alignment
Left Align
The flushleft
environment is used to align text along the left margin. This keeps text on the left side without stretching spaces.
\begin{flushleft} ... \end{flushleft}
\begin{flushleft} ... \end{flushleft}
- This environment ensures all text inside is aligned with the left margin. Unlike justification, spaces are not adjusted to equalize line lengths.
\documentclass{article}
\usepackage[document]{ragged2e}
\begin{document}
\begin{flushleft}
\section{What is Lorem Ipsum?}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
\subsection{Why do we use it?}
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution.
\end{flushleft}
\end{document}
Output :
Right Align
The flushright
environment aligns all text to the right margin of the page. This is useful for specific headings or side notes.
\begin{flushright} ... \end{flushright}
\begin{flushright} ... \end{flushright}
- This environment forces all enclosed text to align on the right side of the page. It does not adjust space between words.
\documentclass{article}
\usepackage[document]{ragged2e}
\begin{document}
\begin{flushright}
\section{What is Lorem Ipsum?}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
\subsection{Why do we use it?}
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution.
\end{flushright}
\end{document}
Output :
Center Align
The center
environment places text in the middle of the page horizontally. It is commonly used for headings, equations, or figures.
\begin{center} ... \end{center}
\begin{center} ... \end{center}
- This environment centers the text block horizontally on the page. It is ideal for titles or standalone content.
\documentclass{article}
\usepackage[document]{ragged2e}
\begin{document}
\begin{center}
\section{What is Lorem Ipsum?}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
\subsection{Why do we use it?}
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution. Proin et massa et nisl porttitor tempor. Vestibulum volutpat enim nec orci egestas, sed iaculis lorem dignissim. Mauris nec lorem varius, malesuada nulla sit amet, posuere leo. Integer id risus et ligula tempus sagittis eu sit amet leo. Vestibulum maximus turpis aliquam neque ultrices imperdiet.
\end{center}
\end{document}
Output :
Justify Align
Justification ensures text is aligned evenly on both margins. For this, you must use the ragged2e
package.
\begin{justify} ... \end{justify}
\begin{justify} ... \end{justify}
- This environment aligns text to both left and right margins by stretching word spacing where necessary. It creates a clean block-like appearance.
\documentclass{article}
\usepackage[document]{ragged2e}
\begin{document}
\begin{justify}
\section{What is Lorem Ipsum?}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
\subsection{Why do we use it?}
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution. Proin et massa et nisl porttitor tempor. Vestibulum volutpat enim nec orci egestas, sed iaculis lorem dignissim. Mauris nec lorem varius, malesuada nulla sit amet, posuere leo. Integer id risus et ligula tempus sagittis eu sit amet leo. Vestibulum maximus turpis aliquam neque ultrices imperdiet.
\end{justify}
\end{document}
Output :
Multi-Column Alignment
The multicol
package lets you split text into multiple columns. You can apply left, right, center, or justify alignment inside it just like in single-column cases.
Left Align Multi-Column
The left-aligned multi-column layout combines multicol
with flushleft
.
\begin{multicols}{2} ... \end{multicols}
\begin{multicols}{2}
- This command splits the text into two columns. The number inside braces defines how many columns to create.
\documentclass{article}
\usepackage{multicol,lipsum}
\begin{document}
\begin{flushleft}
\begin{multicols}{2}
\section{What is Lorem Ipsum?}
\lipsum[1][1-7]
\subsection{Why do we use it?}
\lipsum[2][1-4]
\end{multicols}{2}
\end{flushleft}
\end{document}
Output :
Right Align Multi-Column
Similar to single-column right alignment, but combined with multicols
.
\documentclass{article}
\usepackage{multicol,lipsum}
\begin{document}
\begin{flushright}
\begin{multicols}{2}
\section{What is Lorem Ipsum?}
\lipsum[1][1-7]
\subsection{Why do we use it?}
\lipsum[2][1-4]
\end{multicols}{2}
\end{flushright}
\end{document}
Output :
Center Align Multi-Column
This combines multicols
with the center
environment to place two columns in the middle.
\documentclass{article}
\usepackage{multicol,lipsum}
\begin{document}
\begin{center}
\begin{multicols}{2}
\section{What is Lorem Ipsum?}
\lipsum[1][1-7]
\subsection{Why do we use it?}
\lipsum[2][1-4]
\end{multicols}{2}
\end{center}
\end{document}
Output :
Fully Justified Align Multi-Column
For multi-column justification, use ragged2e
with multicol
.
\documentclass{article}
\usepackage[document]{ragged2e}
\usepackage{multicol,lipsum}
\begin{document}
\begin{justify}
\begin{multicols}{2}
\section{What is Lorem Ipsum?}
\lipsum[1][1-7]
\subsection{Why do we use it?}
\lipsum[2][1-4]
\end{multicols}{2}
\end{justify}
\end{document}
Output :
Using Commands Instead of Environments
Instead of environments, LaTeX also provides commands that can be applied before paragraphs. They require the ragged2e
package.
\RaggedRight, \Centering, \RaggedLeft, \justifying
\RaggedRight
- Aligns text to the left margin like
flushleft
. \Centering
- Centers the following text, similar to
center
environment. \RaggedLeft
- Aligns text to the right margin like
flushright
. \justifying
- Fully justifies the text by adjusting word spacing. Requires
ragged2e
.
\documentclass{article}
\usepackage[document]{ragged2e}
\usepackage{xcolor}
\begin{document}
\RaggedRight {\color{red} \verb|\RaggedRight| }\\ It has survived not only five centuries...
\Centering {\color{red}\verb|\Centering| }\\ Lorem Ipsum is simply dummy text...
\RaggedLeft {\color{red}\verb|\RaggedLeft|} \\It has survived not only five centuries...
\justifying {\color{red}\verb|\justifying| }\\ Lorem Ipsum is simply dummy text...
\end{document}
Output :
Best Practice
For small portions of text, use environments like flushleft
, flushright
, or center
.
For inline usage, commands such as \RaggedRight
and \Centering
are faster.
Always load ragged2e
for justification, since it gives better results than the default TeX engine.
When creating multi-column layouts, use multicol
with the same alignment rules.