5

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?

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

1 Answer 1

6

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}.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .