The ragged2e package

Sets ragged text that still hyphenates words (\RaggedRight, \Centering, \RaggedLeft) and returns to justified text with \justifying.

Loading the package

\usepackage{ragged2e}

\raggedright, \centering and \raggedleft switch hyphenation off. In a narrow column this leaves lines that are much shorter than the others. The commands of ragged2e have the same names with capital letters and allow hyphenation, so the right edge is more even.

Plain LaTeX has no command that switches back to justified text inside a group. \justifying does that, for example in a \parbox or a table cell inside a ragged document.

Main commands

\RaggedRightLeft-aligned text with hyphenation, until the end of the group.
\CenteringCentred text with hyphenation.
\RaggedLeftRight-aligned text with hyphenation.
\justifyingBack to justified text.
\begin{FlushLeft} ... \end{FlushLeft}Environment forms: FlushLeft, Center, FlushRight and justify.
>{\RaggedRight}p{4cm}Ragged-right table column of fixed width; the >{...} syntax needs the array package.
\usepackage[document]{ragged2e}Sets the whole document ragged right.

Complete example

\documentclass{article}
\usepackage{ragged2e}
\usepackage{array}
\begin{document}
\begin{tabular}{l >{\RaggedRight}p{4cm}}
Device & Description \\
\hline
Spectrometer & Measures the wavelength distribution of the incoming light. \\
Thermocouple & Measures temperature differences between two junctions. \\
\end{tabular}

\bigskip
\begin{minipage}{5cm}
\RaggedRight
A narrow column of ragged-right text. A long word such as
internationalization is hyphenated at the end of a line.
\end{minipage}
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages