The ragged2e-package^{∗}

Martin Schröder

Crüsemannallee 3 28213 Bremen Germany martin@oneiros.de

2003/03/25

Abstract This package provides new commands and environments for setting ragged text which are easy to configure to allow hyphenation. An earlier attempt to do this was the style raggedright[8] by the same author.

Contents

1 The problem 1

2 Old “solutions” 2 2.1 L^{A}TEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2 plain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

3 Our solution 2 3.1 The macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.2 The parameters . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.3 The environments . . . . . . . . . . . . . . . . . . . . . . . 4

4 Options 5

5 Required packages 5

6 Acknowledgements 6

1 The problem

L^{A}TEX has three commands

(\centering, \raggedleft,
and \raggedright) and three

environments (center, flushleft, and flushright) to typeset ragged text. The environments are based upon the commands (center uses \centering, flushleft \raggedright, and flushright

                                \raggedleft).

These commands have, however, one serious flaw: they render hyphenation almost impossible, and thus the text looks too ragged, as 2 OLD “SOLUTIONS” 2

∗The version number of this file is v2.04, last revised 2003/03/25.

the following example shows:

\raggedright:

“The L^{A}TEX document preparation system is a special version of Donald Knuth’s TEX program. TEX is a sophisticated program designed to produce high-quality typesetting, especially for mathematical text.” [5, p. xiii]

\RaggedRight:

“The L^{A}TEX document preparation system is a special version of Donald Knuth’s TEX program. TEX is a sophisticated program designed to produce high-quality typesetting, especially for mathematical text.” [5, p. xiii]

2 Old “solutions”

2.1 L^{A}TEX

L^{A}TEX defines e. g. \raggedright as follows:

1 ⟨∗latex⟩

2 \def\raggedright{%
3 \let\\=\@centercr
4 \@rightskip\@flushglue
5 \rightskip\@rightskip
6 \leftskip\z@
7 \parindent\z@}

Initially, \@flushglue is defined as

8 \@flushglue = 0pt plus 1fil

9 ⟨/latex⟩

Thus the \rightskip is set to 0pt plus 1fil. Knuth, however warns [4, p. 101]:

“For example, a person

can set \rightskip=0pt

plus 1fil, and every line will be filled with space to the right. But this isn’t a particularly good way to make ragged-right margins, because the infinte stretchability will assign zero badness to lines that are very short. To do a decent job of ragged-right setting, the trick is to set \rightskip so that it will stretch enough to make line breaks possible, yet not too much, because short lines should be considered bad. Furthermore the spaces between words should be fixed so that they do not stretch or shrink.”

2.2 plain

plain TEX defines an special version of \raggedright, which operates the way Knuth describes it; but which can not be used whith L^{A}TEX, because L^{A}TEX redefines

\raggedright.

10 ⟨∗plain⟩

11 \def\raggedright{%
12 \rightskip\z@ plus2em
13 \spaceskip.3333em
14 \xspaceskip.5em\relax}

plain provides also a version of \raggedright for typewriter fonts

15 \def\ttraggedright{%
16 \tt
17 \rightskip\z@ plus2em\relax}

18 ⟨/plain⟩

3 Our solution

Since the plain solution can not be used with L^{A}TEX, we have to redefine it and make it possible to configure it for personal preferences.

3.1 The macros

\Centering  \Centering, \RaggedLeft, and \RaggedRight can be used in the same
\RaggedLeft
\RaggedRight

way as \centering, \raggedleft, and \raggedright: Just type the

command, and after that the whole text will be set centered, ragged-left or ragged-right.

For example, we switched on \RaggedRight on the top of this text, and consequently this text was set ragged-right.^{∗}

\justifying \justifying switches back to justified text after ragged text has been

New feature 2003/01/04

switched on.

The new commands \Centering, \RaggedLeft, and \RaggedRight

are fully compatible with their counterparts in L^{A}TEX, but implement the plain solution and can be easily configured using the following parameters:

3.2 The parameters

Command  Uses

 \Centering    \CenteringLeftskip, \CenteringRightskip,
               \CenteringParfillskip, \CenteringParindent
 \RaggedLeft   \RaggedLeftLeftskip, \RaggedLeftRightskip,
               \RaggedLeftParfillskip, \RaggedLeftParindent
 \RaggedRight  \RaggedRightLeftskip, \RaggedRightRightskip,
               \RaggedRightParfillskip, \RaggedRightParindent

 \justifying   \JustifyingParfillskip, \JustifyingParindent

All Parameters can be set with \setlength, e. g.

     \setlength{RaggedRightRightskip}{0pt plus 1em}
sets \RaggedRightRightskip to 0pt plus 1em.
\CenteringLeftskip These are the \leftskips inserted by \Centering, \RaggedLeft, and
\RaggedLeftLeftskip
\RaggedRightLeftskip

\RaggedRight.

“\leftskip (glue at left of justified lines)” [4, p. 274]

\leftskip must be set to a finite value, to make hyphenation possible. Setting it to infinite values like 0pt plus 1fil makes hyphenation almost impossible.

\CenteringRightskip These are the \rightskips inserted by \Centering, \RaggedLeft, and
\RaggedLeftRightskip
\RaggedRightRightskip

\RaggedRight.

“\rightskip (glue at right of justified lines)” [4, p. 274]

\rightskip must be set to a finite value, to make hyphenation possible. Setting it to infinite values like 0pt plus 1fil makes hyphenation almost impossible.

\CenteringParfillskip These are the \parfillskips inserted by \Centering, \RaggedLeft,
\RaggedLeftParfillskip
\RaggedRightParfillskip

\JustifyingParfillskip

\RaggedRight, and \justifying.

“\parfillskip (additional \rightskip at end of paragraphs)” [4, p. 274]

The normal setting for \parfillskip is 0pt plus 1fil; the parameters are provided for testing combinations of \{left|right}skip and

\parfillskip.
\CenteringParindent These are the \parindents used by \Centering, \RaggedLeft,
\RaggedLeftParindent
\RaggedRightParindent
\JustifyingParindent

\RaggedRight, and \justifying.

“\parindent (width of \indent)” [4, p. 274]

\parindent is the indent of the first line of a paragraph and should be set to 0pt, since indented lines in ragged text do not look good. The parameters have the following initial setting:

Parameter  L^{A}TEX setting  ragged2e setting

\CenteringLeftskip       0pt plus 1fil     0pt plus 2em
\RaggedLeftLeftskip      0pt plus 1fil     0pt plus 2em

\RaggedRightLeftskip     0pt plus 0pt
                         minus 0pt

                                            0pt plus 0pt
                                            minus 0pt

\CenteringRightskip      0pt plus 1fil     0pt plus 2em

\RaggedLeftRightskip     0pt plus 0pt
                         minus 0pt

                                            0pt plus 0pt
                                            minus 0pt

\RaggedRightRightskip    0pt plus 1fil     0pt plus 2em

\CenteringParfillskip    0pt plus 0pt
                         minus 0pt

                                            0pt plus 0pt
                                            minus 0pt
\RaggedLeftParfillskip   0pt plus 0pt
                         minus 0pt

                                            0pt plus 0pt
                                            minus 0pt

\RaggedRightParfillskip  0pt plus 1fil     0pt plus 1fil
\CenteringParindent      0pt               0pt
\RaggedLeftParindent     0pt               0pt
\RaggedRightParindent    0pt               0pt
\JustifyingParfillskip                      0pt plus 1fil
\JustifyingParindent                        \parindent

3.3 The environments

Center Center is fully compatible with center, but uses \Centering instead of

\centering.

FlushLeft FlushLeft is fully compatible with flushleft, but uses \RaggedRight instead

of \raggedright.

FlushRight FlushRight is fully compatible with flushright, but uses \RaggedLeft

∗Actually we also set \RaggedRightRightskip higher than usual (0pt plus 4em)

because of all the long command names which make linebreaking difficult.

∗For proportional and monospaced fonts.

instead of \raggedleft.

justify justify is like the other environments but uses \justifying.

New feature 2003/01/04

E. g. FlushLeft can be used in the same way as flushleft:

\begin{FlushLeft}

⟨text, which is set ragged-right⟩

\end{FlushLeft}

4 Options

This package has the following options:

originalcommands The L^{A}TEX-commands \centering, \raggedleft, and \raggedright and the L^{A}TEX-environments center, flushleft, and flushright remain unchanged.

It is the default.

newcommands The L^{A}TEX-commands \centering, \raggedleft, and \raggedright and the L^{A}TEX-environments center, flushleft, and flushright are set equal to their counterparts defined by ragged2e. Thus \raggedright invokes \RaggedRight. The original commands can be accessed unter the Names \LaTeX⟨original name⟩, e. g.

\LaTeXraggedright.

originalparameters The parameters used by the commands implemented by ragged2e are initialized with the default settings used by L^{A}TEX.

newparameters The parameters used by the commands implemented by ragged2e are initialized with the default settings defined by ragged2e.

It is the default.

raggedrightboxes All \parboxes, minipages, \marginpars and p-columns of

New feature 2003/01/18

tabulars and arrays are automatically set using \RaggedRight.

footnotes This options sets all footnotes ragged-right by loading the

New feature 2003/01/18

footmisc[2] package with the ragged option.

document This options sets the complete document ragged-right by exe-

New feature 2003/01/18

cuting a \RaggedRight at \begin{document} and the raggedright-

boxes and the footnotes options.

All other options are passed to the footmisc package if the footnotes option is selected.

5 Required packages

This package requires the following package: everysel[7] It is used to distinguish between monospaced and proportional

fonts.

footmisc[2] It is used by the footnotes option; at least version 5.00 (2002/08/28) is needed.

6 Acknowledgements

A first version of this package for L^{A}TEX2.09 was named raggedri[8]. Laurent Siebenmann (lcs@topo.math.u-psud.fr) with his style ragged.sty[9] provided the final impulse for this new implementation. The code for \justifying, justify and the overloading of \@arrayparboxrestore is incorporated from the raggedr[3] package

by James Kilfinger (mapdn@csv.warwick.ac.uk).

Without the constant nagging of Rainer Sieger (rsieger@ awi-bremerhaven.de) this package might not be. Markus Kohm (markus.kohm@gmx.de) provided the code for \@gnewline.

Frank Mittelbach (frank.mittelbach@latex-project.org) provided the

impetus for version 2.00. Rolf Niepraschk (Rolf.Niepraschk@ptb.de) and Hubert Gäßlein found many bugs and provided fixes for them and code for new features.

References

[1] Johannes Braams, David Carlisle, Alan Jeffrey, Leslie Lamport, Frank Mittelbach, Chris Rowley, and Rainer Schöpf. ltmiscen.dtx. Part of the L^{A}TEX-distribution.

[2] Robin Fairbairns. footmisc — a portmanteau package for customising

   footnotes in L^{A}TEX 2ε. CTAN:tex-archive/macros/latex/contrib/
   supported/footmisc/footmisc.dtx.
[3] James Kilfiger. CTAN:tex-archive/macros/latex/contrib/other/
   misc/raggedr.sty. L^{A}TEX 2ε package.

[4] Donald E. Knuth. The TEXBook, volume A of Computers & Typesetting. Addison-Wesley, Reading, MA, USA, 1986.

[5] Leslie Lamport. L^{A}TEX: A Document Preparation System. Addison-Wesley, Reading, MA, USA, first edition, 1986.

[6] Frank Mittelbach and Rainer Schöpf. The file cmfonts.fdd for use with L^{A}TEX 2ε. Part of the L^{A}TEX-distribution.

[7] Martin Schröder. The everysel-package. CTAN:tex-archive/macros/

   latex/contrib/supported/ms/everysel.dtx. L^{A}TEX 2ε package.

[8] Martin Schröder. The raggedri document option. Was in CTAN:

   tex-archive/macros/latex209/contrib/raggedright. L^{A}TEX2.09

style, outdated.

Index 7

[9] Laurent Siebenmann. ragged.sty. CTAN:tex-archive/macros/

generic/ragged.sty. generic macro file for plain and L^{A}TEX.

Index

Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.

Symbols

\@centercr . . . . . . . . . . . . . . . . . 3 \@flushglue . . . . . . . . . . . . . . . 4, 8 \@rightskip . . . . . . . . . . . . . . . 4, 5 \\ . . . . . . . . . . . . . . . . . . . . . . . . 3

C

Center (environment) . . . . . . . . . 4 \Centering . . . . . . . . . . . . . . . . 2

\CenteringLeftskip . . . . . . . . . . 3
\CenteringParfillskip . . . . . . . 3
\CenteringParindent . . . . . . . . . 3
\CenteringRightskip . . . . . . . . . 3

D

\def . . . . . . . . . . . . . . . . . 2, 11, 15

E

environments:

Center . . . . . . . . . . . . . . . . . 4 FlushLeft . . . . . . . . . . . . . . . 4 FlushRight . . . . . . . . . . . . . . 4 justify . . . . . . . . . . . . . . . . 4

F

FlushLeft (environment) . . . . . . 4 FlushRight (environment) . . . . . . 4

J

justify (environment) . . . . . . . . 4 \justifying . . . . . . . . . . . . . . . . 2

\JustifyingParfillskip . . . . . . 3
\JustifyingParindent . . . . . . . . 3

L

\leftskip . . . . . . . . . . . . . . . . . . 6 \let . . . . . . . . . . . . . . . . . . . . . . . 3

P

\parindent . . . . . . . . . . . . . . . . . 7

R

\RaggedLeft . . . . . . . . . . . . . . . . 2

\RaggedLeftLeftskip . . . . . . . . . 3
\RaggedLeftParfillskip . . . . . . 3
\RaggedLeftParindent . . . . . . . . 3
\RaggedLeftRightskip . . . . . . . . 3

\RaggedRight . . . . . . . . . . . . . . . 2 \raggedright . . . . . . . . . . . . . 2, 11

\RaggedRightLeftskip . . . . . . . . 3
\RaggedRightParfillskip . . . . . 3
\RaggedRightParindent . . . . . . . 3
\RaggedRightRightskip . . . . . . . 3

\relax . . . . . . . . . . . . . . . . . 14, 17 \rightskip . . . . . . . . . . . 5, 12, 17

S

\spaceskip . . . . . . . . . . . . . . . . 13

T

\tt . . . . . . . . . . . . . . . . . . . . . . 16 \ttraggedright . . . . . . . . . . . . . 15

X

\xspaceskip . . . . . . . . . . . . . . . . 14

Z

\z@ . . . . . . . . . . . . . . . 6, 7, 12, 17

Change History

v1.00

General: New from raggedright V 1.21 . . . . . . . . . . . . . . . 1 v1.01

General: Documentation improved . . . . . . . . . . . . . . . 1

Change History 8

v1.02

General: Moved to LPPL . . . . . 1 v2.00

General: Allow all-lowercase versions of options and removed documentation of mixed-case versions. . . . . . 4 Incorporated raggedr . . . . . . 1 New command \justifying . 2 New environment justify …. 4 New option document . . . . . . 5 New option footnotes . . . . . . 5 New option raggedrightboxes . 5

Removed \RaggedSpaceskip
 and \RaggedXSpaceskip . . 3