12

I'd like to left align my entire document (latex default seems to be center justified). Is there a simple way to do this?

I'm trying to use

\begin{flushleft}
...
\end{flushleft}

but really don't want to have to do that on a paragraph by paragraph basis (and when I try to simply add that to the start and end of my document I get an error.

17

Just use:

\raggedright

right after \begin{document}

The flushleft environment effectively sets text in a ragged right list environment. It is defined as:

\def\flushleft{\trivlist \raggedright\item\relax} 
\def\endflushleft{\endtrivlist}

The \raggedright command does the actual work:

\def\raggedright{%
   \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
   \leftskip\z@skip
   \parindent\z@}

Setting text this way will lead to some ugly looking lines. The ragged2e package provides the \RaggedRight command (and corresponding) FlushLeft environment that solves some of these problems. I would recommend using it instead of just \raggedright.

To see the differences between \raggedright and \RaggedRight here's a small sample document:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=1in]{geometry}
\usepackage{hyphenat}
\usepackage{ragged2e}
\usepackage{blindtext}

\begin{document}
\begin{minipage}[t]{.4\textwidth}
\textbf{raggedright with no hyphenation}\par
\raggedright
\blindtext
\end{minipage}
\hfill
\begin{minipage}[t]{.4\textwidth}
\textbf{RaggedRight with hyphenation}\par
\RaggedRight
\blindtext
\end{minipage}
\end{document}

output of code

Both \raggedright and \RaggedRight set the paragraph indent to zero. With ragged2e this is controllable with the length \RaggedRightParindent which can be set to equal the regular \parindent in the following way:

\setlength{\RaggedRightParindent}{\parindent}

To do this with regular \raggedright you could do the following:

\usepackage{etoolbox}
\newlength{\rrindent}
\setlength{\rrindent}{\parindent}
\apptocmd{\raggedright}{\setlength{\parindent}{\rrindent}}{}{}
  • 1
    Can the same result be achieved by completely disabling hyphenation? – ℝaphink Aug 8 '11 at 21:52
  • @Raphink same result as what? Disabling hyphenation with justified text will just lead to ugly interword spacing, but still justified, not ragged right text. Turning off hyphenation with \RaggedRight will get you the same as \raggedright. – Alan Munn Aug 8 '11 at 22:11
  • You broke the paragraph indent. – Pavel Šimerda Dec 19 '18 at 13:04
  • @PavelŠimerda Yes, both versions reset the \parindent to zero. I've added some comments on how to change them back. – Alan Munn Dec 19 '18 at 15:56
  • Alan Munn suggestion is one of the good one... – MadyYuvi Dec 21 '18 at 6:21
4

You need to use \raggedright to have a flush left typesetting:

\documentclass{article}
\usepackage{lipsum}% dummy text
\raggedright% flush left alignment
\begin{document}
\lipsum[1-10]% 10 paragraphs of summy text
\end{document}​​​​​​​​​​​

Ragged-right aligned document

  • You broke the paragraph indent. – Pavel Šimerda Dec 19 '18 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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