0

In xelatex or lualatex, how can I get pararaphs to stretch words with tiny spaces within words as the last resort of typesetting? It seems that everyone just wants tiny little hspace of fixed size between capital letters, but I want a space like 0em plus 0.05em within each word - but I still need hyphenation to work, and I want normal kerning and ligatures when the stretch within the word is zero!

In the example, you'll see that for the underfull hbox of the first line, the spaces are as large as they can get, and the words start getting spaced out. In the same paragraph, the word appears again, with regular spacing. And the ligature for "fl" in "flesh" is present.

Here's what I need to do

I thought that TeX did this by default!

Here's latex failing at it:

\documentclass{article}    
\begin{document}
\rightskip=0.65\linewidth
23\hspace{1ex}And Abraham took Ishmael his son, and all that
were born in his house, and all that were bought with his 
money, every male among the men of Abraham's house; and 
circumcised the flesh of their foreskin in the selfsame day,
as God had said unto him.
\end{document}

enter image description here

3
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – DG'
    Commented Mar 7 at 9:05
  • 1
    you can use \sloppy or \emergencystretch, but better don't do it for a full document, only for bad paragraphs, see tex.stackexchange.com/a/241355/2388. microtype often improves paragraphs too. Commented Mar 7 at 9:34
  • Note: microtype activates font expansion by default. You can deactivate it, if you don't want it. Tracking (adding small spaces in words) can be activated with option tracking. All features depend on the engine (and output mode). XeLaTeX support it not the best, but some features are also available using fontspec instead. See the user manuals for more information.
    – cabohah
    Commented Mar 7 at 9:42

2 Answers 2

3

This is only to complete the excellent answers of cabohah (+1).

With xelatex you can use also some like \usepackage[shrink=20, stretch=30]{microtype} which could be a solution while you maintain these parameters in reasonably low values (he effect should be hardly noticed, or better not noticed at all).


mwe


But to answer exactly to your question (add space between letters) you can also set a some value to the option letterspace, for instance, letterspace=150 and then type \textls{Abraham}:


mwe


(the value of 150 is deliberately exaggerated to see easily the effect. In this case, really letterspace=2 is enough).

3
  • Thank you for the flowers.
    – cabohah
    Commented Mar 7 at 10:47
  • Okay, this is fun, but it's not really what I need: \usepackage[shrink=20, stretch=30]{microtype} stretches the letters themselves, but doesn't act on the spaces between the letters. I want to adjust the spacing between the letters, not the stretch of the letters themselves. Some other random text formatting system has got it right ...
    – Tad Pole
    Commented Mar 7 at 12:46
  • @TadPole So you want the tracking or kerning option of microtype. These are only available with LuaLaTeX or PDFLaTeX, but not with XeLaTeX (see my answer). Adjusting the shrink and stretch value is the best, you can do using microtype with XeLaTeX, if you don't want letterspacing (which is also also shown in Fran's answer). BTW: Using any kind of letter spacing for justifying text is very controversial. Several typographers vote against.
    – cabohah
    Commented Mar 7 at 15:22
2

Following works with pdfLaTeX and LuaLaTeX:

\documentclass{article}
\usepackage[tracking]{microtype}
\begin{document}
\rightskip=0.65\linewidth
\emergencystretch=1pt
23\enspace And Abraham took Ishmael his son, and all that
were born in his house, and all that were bought with his 
money, every male among the men of Abraham's house; and 
circumcised the flesh of their foreskin in the selfsame day,
as God had said unto him.
\end{document}

with pdfLaTeX or LuaLaTeX

With XeLaTeX the tracking feature is not available. Therefore you have to increase the \emergencystretch value:

\documentclass{article}
\usepackage{microtype}
\begin{document}
\rightskip=0.65\linewidth
\emergencystretch=1em
23\enspace And Abraham took Ishmael his son, and all that
were born in his house, and all that were bought with his 
money, every male among the men of Abraham's house; and 
circumcised the flesh of their foreskin in the selfsame day,
as God had said unto him.
\end{document}

xelatex + emergencystretch

or have to use something like sloppypar:

\documentclass{article}
\usepackage{microtype}
\begin{document}
\rightskip=0.65\linewidth
\begin{sloppypar}
23\enspace And Abraham took Ishmael his son, and all that
were born in his house, and all that were bought with his 
money, every male among the men of Abraham's house; and 
circumcised the flesh of their foreskin in the selfsame day,
as God had said unto him.
\end{sloppypar}
\end{document}

xelatex + sloppypar

For more information about the features and which engine they need, please see the microtype user manual. You will find there also a note about using fontspec's LetterSpace (as a replacement of tracking) with XeLaTeX.

You must log in to answer this question.

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