# Setting the word space with ragged2e

I am working on Lyx with Preamble, I used to set the word space with everysel as below:

\usepackage{everysel}
\EverySelectfont{%
\fontdimen2\font=0.3em% interword space
}


However, the design I am working on has to perform well in a very small format, hence I opt to use ragged2e to set ragging right with hyphenation:

\usepackage{ragged2e}
\RaggedRight


With a sense of despondency, this seems to disable the everysel, the manual said when ragged2e is called upon, the everysel is automatically loaded, however, I don't seem to be able to get it working.

So to sum up, my question is, how to set the text ragging right, with hyphenation and maintaining the control of word space?

-
Move the call of \EverySectFont after \usepackage{ragged2e}. Otherwise add a minimal working example (MWE) that illustrates your problem. – Speravir Sep 3 '12 at 17:28
stupid me! it is working now. sorry about this. – Shi Yuan Sep 3 '12 at 17:43
As the author of ragged2e I'm curious if you think code for this should be added to the package. – Martin Schröder Sep 3 '12 at 19:56

From what I can see, \RaggedRight performs \@raggedtwoe@everyselectfont before your \EverySelectfont can act; this macro sets the space skip to \fontdimen2\font, so your setting is ignored, because TeX uses \spaceskip if non zero, rather than \fontdimen2\font for the interword spacing.

\documentclass{article}
\usepackage{everysel,ragged2e,etoolbox}

% Let's add something before \spaceskip is set
\makeatletter
\preto{\@raggedtwoe@everyselectfont}{\fontdimen2\font=.3em }
\makeatother

\begin{document}
\RaggedRight abc def

\Large abc def

\end{document}


Another way is to set \EverySelectfont before loading ragged2e:

\documentclass{article}

\usepackage{everysel}
\EverySelectfont{\fontdimen2\font=.3em }

\usepackage{ragged2e}

\begin{document}
\selectfont

\RaggedRight abc def

\Large abc def

\end{document}


Don't forget \selectfont after \begin{document}.

-
Brilliant, many thanks! – Shi Yuan Sep 11 '12 at 18:30