Welcome to the UK List of
TeX Frequently Asked Questions
on the Web

Searching

The index of Frequently Asked Questions about TeX is searchable.

Please enter your keyword here:   then press here: ,    or:
Google

Cancelling \ragged commands

LaTeX provides commands \raggedright and \raggedleft, but none to cancel their effect. The \centering command is implemented in the same way as the \ragged* commands, and suffers in the same way.

The following code (to be inserted in a package of your own, or as internal LaTeX code) defines a command that restores flush justification at both margins:

\def\flushboth{%
  \let\\\@normalcr
  \@rightskip\z@skip \rightskip\@rightskip
  \leftskip\z@skip
  \parindent 1.5em\relax}
There’s a problem with the setting of \parindent in the code: it’s necessary because both the \ragged commands set \parindent to zero, but the setting isn’t a constant of nature: documents using a standard LaTeX class with twocolumn option will have 1.0em by default, and there’s no knowing what you (or some other class) will have done.

Any but a really old copy of Martin Schröder’s ragged2e package has a \justifying command to match its versions of the LaTeX ‘ragged’ commands. The package also provides a justify environment, which permits areas of justified text in a larger area which is ragged.

ragged2e.sty
Distributed as part of macros/latex/contrib/ms (or browse the directory); catalogue entry


Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=flushboth

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.27, released on 2013-06-07.