[Tex/LaTex] \raggedright removes paragraph indentation

indentationparagraphsragged2e

This code

\documentclass[]{article}
\usepackage{lipsum}

\begin{document}

    \raggedright

    \lipsum[1-3]

\end{document}

produces three paragraphs with a ragged right edge and no paragraph indentation. Why? And how can I get a ragged right edge with paragraph indentation?

Also — please feel free to add tags to this post; I didn't quite know what would be best.

Best Answer

The definition of \raggedright in the LaTeX kernel is

% latex.ltx, line 3974:
\def\raggedright{%
  \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
  \leftskip\z@skip
  \parindent\z@}

Thus you can say in your document preamble

\makeatletter
\newcommand\iraggedright{%
  \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
  \leftskip\z@skip}
\makeatother

removing the last instruction. Now \iraggedright will do what you want.

A different approach is to use ragged2e

\documentclass{article}
\usepackage{lipsum}
\usepackage{ragged2e}
\setlength{\RaggedRightParindent}{\parindent}

\begin{document}
\RaggedRight

\lipsum[1-2]

\end{document}

enter image description here

Note that \RaggedRight is less strict than \raggedright in that it allows hyphenation, so making “less ragged” output.