Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
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
add comment

1 Answer

up vote 6 down vote accepted

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

share|improve this answer
    
Brilliant, many thanks! –  Shi Yuan Sep 11 '12 at 18:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.