13

How to implement word spacing in LaTeX? For websites this is done with CSS:

word-spacing: 0.5em;

This is for reference about other tags

  • paper: custom
  • layout:
  • layoutoffset:(h,v)=(0.0pt,0.0pt)
  • modes:
  • h-part:(L,W,R)=(0.0pt, 72.26999pt, 0.0pt)
  • v-part:(T,H,B)=(0.0pt, 72.26999pt, 0.0pt)
  • \paperwidth=72.26999pt
  • \paperheight=72.26999pt
  • \textwidth=72.26999pt
  • \textheight=72.26999pt
  • \oddsidemargin=-72.26999pt
  • \evensidemargin=-72.26999pt
  • \topmargin=-109.26999pt
3
  • 4
    This question doesn't really make sense: TeX and friends justify text by default. This means that that word spacing varies from word to word...
    – Seamus
    Jul 22, 2011 at 10:23
  • I agree with @Seamus, this is normally not done with LaTeX which is for larger/real documents. However, I like the technical aspect of the question. Jul 22, 2011 at 10:54
  • I recently learned about the existence of \spaceskip (used e.g. by ragged2e), which seem related, but I'm not sure at all. Jul 22, 2011 at 11:00

3 Answers 3

14

Other answers have pointed to \spaceskip: I think an example might be useful. In the first paragraph, TeX is using the usual justified approach. In paragraph two, I've set up to use a ragged-right margin in much the same way as ragged2e does. This uses the interword space taken from the font. In the third paragraph, I've explicitly set the interword space to 0.5 em (the other ragged-right parameters continue to apply).

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\parfillskip 0 pt plus 1 fil\relax
\leftskip    0 pt           \relax
\rightskip   0 pt plus 2 em \relax
\spaceskip \fontdimen 2 \font
\lipsum[1]

\spaceskip   0.5 em         \relax
\lipsum[1]

\end{document}
12

In TeX the spacing between words is ruled by parameters coming from the current font and usually they are adjusted so as to provide a good typographical result.

The default fonts use a word spacing of M/3 (one third of an em), which can be stretched without adding much to the line badness up to M/2 or shrinked up to 2/9 of an em.

The Times font in the TeX distributions uses an interword space of M/4 stretchable to 4/10 of an em and shrinkable to M/5.

There is a parameter called \spaceskip, but it should be used with care. You find details about it in the TeXbook or in TeX by Topic (the latter should be in your TeX distribution).

7

While I agree with Seamus and Martin, word spacing can be adjusted if you really need/want to (in titles or page headers for example).

In PDFTex, you can use the microtype package for that, with the \textls command:

\textls[100]{Spaced text}
\textls[-50]{Compacted text}

You can do finer things with XeTeX by using the fontspec package to select a font:

\newfontfamily\headerfont[LetterSpace=12,WordSpace=2,Ligatures=NoCommon]{Linux Libertine O}

Note that I strongly recommend deactivating ligatures (hence the Ligatures=NoCommon) to prevent uneven spacing of ligatures if you use LetterSpace.

2
  • 2
    Word spacing is not letter spacing.
    – egreg
    Jul 22, 2011 at 11:09
  • 1
    Right @egreg. \textls is mostly about letter spacing, but WordSpace is about word spacing. In most of the cases where I've had to play with word spacing (headers, etc.), I've had to adjust letter spacing, too.
    – raphink
    Jul 22, 2011 at 11:15

You must log in to answer this question.

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