[Tex/LaTex] Increase word space between words in small caps

fontspecsmall-capsspacing

With tracking activated for small caps, it can be a little bit hard to detect interword spaces. Cf. below.

\documentclass{article}
\usepackage{fontspec}
    \setmainfont{Libertine Serif}[
        SmallCapsFeatures = {Letters = SmallCaps, LetterSpace = 5}]
\begin{document}
The title of my article is \textsc{This is the moment your life changed forever}.
\end{document}

enter image description here

I'd like to increase the space between words in small caps, therefore, but only when words on either side are in small caps (i.e. there should be no extra space before the first word written in small caps or after the last word).

I would've thought I could do this by adding WordSpace = <> to SmallCapsFeatures, but this will change the interword space everywhere.

\documentclass{article}
\usepackage{fontspec}
    \setmainfont{Libertine Serif}[
        SmallCapsFeatures = {Letters = SmallCaps, LetterSpace = 5, WordSpace = 5}]
\begin{document}
The title of my article is \textsc{This is the moment your life changed forever}.
\end{document}

enter image description here

Best Answer

You want to set \spaceskip to a non null value (and perhaps also \xspaceskip).

\documentclass{article}
\usepackage{fontspec}
\usepackage{xpatch}

\setmainfont{Linux Libertine O}[
  SmallCapsFeatures = {
    Letters = SmallCaps,
    LetterSpace = 20,
  }
]

\xapptocmd{\scshape}
  {\spaceskip=3\fontdimen2\font plus 3\fontdimen3\font minus \fontdimen4\font
   \xspaceskip=2\fontdimen7\font}
  {}{}


\begin{document}

The title of my article is \textsc{This is the moment your life changed forever}.
Here the space is normal.

\end{document}

enter image description here

The values are of course exaggerated: here the interword space is set to three times the normal value.

When \spaceskip has a nonzero value, it is used for the interword space instead of the default font defined one. The relevant font parameters are

  1. \fontdimen2\font (the natural width of the interword space)
  2. \fontdimen3\font (the stretch component)
  3. \fontdimen4\font (the shrink component)

Thus, specifying

\spaceskip=3\fontdimen2\font plus 3\fontdimen3\font minus \fontdimen4\font

we're telling to use three times the normal interword space, stretchable three times as much it is normally and shrinking it the same as the default. The parameter \xspaceskip is related to the space factor: when the space factor is >2000, TeX adds its value to the normal interword space (this is how the space is increased after periods); by default TeX uses \fontdimen7\font, but it uses \xspaceskip if it is nonzero.

Related Question