Text Alignment in LaTeX

In typesetting, alignment refers to text positioning within a specified space. Text alignment is an important aspect of document layout, and LaTeX provides several environments to control it.

Default Text Alignment in LaTeX

LaTeX’s default alignment is fully justified, meaning text is aligned to the left and right margins, creating a smooth and consistent appearance. In other words, the text is stretched to fill the entire page width, and spaces between words are adjusted so that each line starts from the left margin and ends at the right margin. For example:

\documentclass{article}

\begin{document}

A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.

\end{document}

Output

Left Alignment

The left edge is aligned along a common margin or reference point in left-aligned text. The right side of the text may appear uneven or ragged.

Method 1: Using ‘flushleft’ Environment

You can use flushleft environment for the left alignment of the text. For example:

\documentclass{article}

\begin{document}

\begin{flushleft}
  A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.
\end{flushleft}

\end{document}

Output

Method 2: Using ‘\raggedright’ command

The \raggedright command is used to left-align the text. It means that the text will be aligned along the left margin, and the right margin will be uneven.

\documentclass{article}

\begin{document}

\raggedright
A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.

\end{document}

Output

Right Alignment

The right edge is aligned along a common margin or reference point in right-aligned text. The left side of the text may appear uneven or ragged.

Method 1: Using ‘flushright’ Environment

You can use flushright environment for the right alignment of the text. For example:

\documentclass{article}

\begin{document}

\begin{flushright}
  A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.
\end{flushright}

\end{document}

Output

Method 2: Using ‘\raggedleft’ command

The \raggedleft command is used to right-align the text. It means that the text will be aligned along the right margin, and the left margin will be uneven.

\documentclass{article}

\begin{document}

\raggedleft
A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.

\end{document}

Output

Center Alignment

The text is symmetrically centered in the center-aligned text between the left and right margins. This creates an even appearance on both sides of the text.

Method 1: Using ‘center’ Environment

You can use center environment for the center alignment of the text. For example:

\documentclass{article}

\begin{document}

\begin{center}
  A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.
\end{center}

\end{document}

Output

Method 2: Using ‘\centering’ command

The \centering command is used to center-align the text. The text will be centered between the left and right margins.

\documentclass{article}

\begin{document}

\centering
A garden is a cultivated space, often adjacent to a home or in a public area, where plants, flowers, and sometimes vegetables are grown. Gardens serve aesthetic and practical purposes, providing a harmonious blend of nature and human design. They come in various forms, from small backyard gardens to expansive botanical gardens.

\end{document}

Output

Summary

The above text alignment environments and commands are essential in document layout and design, allowing you to control the visual presentation of your text. In LaTeX, these alignment environments (flushleft, flushright, and center) and commands (\raggedright, \raggedleft, and \centering) are often used within larger structures like sections, paragraphs, or tables to align the desired text.

1 thought on “Text Alignment in LaTeX”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.