12

I thought that \raggedright is used to get text: 1) not exceeding certain width, 2) with natural interword spaces, 3) without hyphenation. But it turns out that hyphenation is done with \raggedright. So, what this macro was conceived for? Why was not it defined as \myraggedright, instead of \actualraggedright? (see examples below)

And why is it bad to use \rightskip=0pt plus 1fil in \myraggedright for ragged right effect (as said in the following passage from TeXbook, page 101, second paragraph)? It seems to work flawlessly.

For example, a person can set \rightskip=0pt plus1fil, and every line will be filled with space at the right. But this isn't a particularly good way to make ragged-right margins, because the infinite stretchability will assign zero badness to lines that are very short.

Example 1:

\def\actualraggedright{%
  \rightskip=0pt plus 2em
  \spaceskip .3333em \xspaceskip .5em\relax
}
\magnification=\magstep5
\actualraggedright
\frenchspacing
\noindent
There are not many different types of question that can be asked on Fourier series so, if you practice,
you should not have any surprises in the exam. In addition to the questions in the mock exam papers
and the blue book, there are many Fourier series questions available in maths text books or on-line.
\bye

Example 2:

\def\myraggedright{%
  \rightskip=0pt plus 1fil
  \spaceskip .3333em \xspaceskip .5em\relax
}
\magnification=\magstep5
\myraggedright
\frenchspacing
\noindent
There are not many different types of question that can be asked on Fourier series so, if you practice,
you should not have any surprises in the exam. In addition to the questions in the mock exam papers
and the blue book, there are many Fourier series questions available in maths text books or on-line.
\bye
1
  • 4
    Usually it is better to allow some hyphenation rather than allow lines with just one letter to be followed by a line that is full, for latex for example the ragged2e package is set up specifically to restrict the rightskip and allow hyphenation in contrast to the latex default \raggedright that does allow arbitrary stretch. Sep 28 '15 at 9:50
11

\raggedright is for cases especially narrow text blocks where full justification will not produce a good result.

If you allow arbitrary stretch then you can get very ragged text which can usually be improved by restricting the raggedness.

Compare these two settings of the same text.

enter image description here

\magnification=\magstep5
\noindent X\hrulefill X

\frenchspacing
{\raggedright

\noindent
There are not many different types of question
that\-can\-be\-asked\-on\-Fourier\-series\-so,\-if you
practice, you\-should\-not\-have\-any\-surprises\-in\-the exam.
In addition to the questions in the mock exam papers
and the blue book, there are many Fourier series
questions available in maths text books or online.

}
\def\myraggedright{%
  \rightskip=0pt plus 1fil
  \spaceskip .3333em \xspaceskip .5em\relax
}

\bigskip

{\myraggedright
\noindent
There are not many different types of question
that\-can\-be\-asked\-on\-Fourier\-series\-so,\-if you
practice, you\-should\-not\-have\-any\-surprises\-in\-the exam.
In addition to the questions in the mock exam papers
and the blue book, there are many Fourier series
questions available in maths text books or online.

}
\bye
2
  • 3
    is there not a one sentence explanation of what it does? Just an intuition. Nov 21 '17 at 17:32
  • @CharlieParker isn't clear what extra you need, the second one allows the white space to grow arbitrarily large (so allowing arbitrarily short lines) the first one as shown in the question only allows the white space to grow to 2em, so may need hyphenation to achieve that, but generally makes better looking output. Nov 21 '17 at 17:36

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.