Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
I've added the tags 'indentation' and 'ragged2e'. –  Mico Jun 21 at 21:30

2 Answers 2

up vote 10 down vote accepted

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.

share|improve this answer

It is common practice to typeset flush-left (aka ragged-right) paragraphs without indentation of the first lines of paragraphs. To compensate for this, one usually also inserts a bit of extra whitespace between paragraphs. You could get this effect (i.e., the extra spacing between paragraphs) by loading the parskip package.

To restore indentation of the first line of a paragraph, you could issue the command

\setlength\parindent{2em} % or whatever length you desire

after issuing the command \raggedright.


If you really need to typeset entire paragraphs in ragged-right mode, you should consider loading the ragged2e package and issuing the command \RaggedRight (notice the capitalization of the two Rs), either in the preamble or at the start of the material you want to get typeset ragged-right (flush-left). Doing so will (re)enable hyphenation, making the right-hand edges of paragraphs look much less ragged looking (pun intended) than if you used \raggedright. As @MartinSchröder -- the author of the ragged2e package -- has pointed out in a comment, the package provides the parameter \RaggedRightParindent. You could set this parameter equal to the basic \parindent parameter to re-enable indentation of the first line of every paragraph. Hote that you should set the value of this length parameter before issuing the command \RaggedRight.

\documentclass{article}
\usepackage{lipsum}
\usepackage{ragged2e}
\setlength\RaggedRightParindent{\parindent} % default value of this parameter is `0pt`
\RaggedRight % if invoked in preamble, entire document is set Ragged-Right
\begin{document}
\lipsum[1-3]
\end{document}
share|improve this answer
    
Ehm. ragged2e offers \RaggedRightParindent. –  Martin Schröder Jun 22 at 12:02
    
@MartinSchröder - Thanks for this; I've revised the final paragraph of my answer to mention this parameter and how it might/should be modified to re-enable indentation of the first line of paragraphs. –  Mico Jun 22 at 13:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.