about posts github email

Letter-spacing for headlines in LaTeX

Posted on 2017-03-25

Recently I wanted to increase the letter spacing for upper-case headlines in a LaTeX document, and I was surprised how complicated this was. Here I want so summarize some of the solutions I came across. I have to warn you: I am not a LaTeX expert, so if you know about any better solutions please let me know.

Blanks

Obviously the simplest solution: just insert a blank after each letter:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}

\begin{document}
    \section*{H E A D L I N E}
\end{document}

This will add spacing between letters as if they were separate words. There are two problems with this solution:

  1. One cannot alter the amount of inter-letter space.
  2. It does not work for multi-word headlines.

The first problem cannot be overcome by this solution, the second one can with a little modification:

\section*{W H I T E\hspace{0.5em}S P A C E S}

\hspace

This most inelegant solution follows here:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}

\begin{document}
    \section*{W\hspace{0.1em}
              H\hspace{0.1em}
              I\hspace{0.1em}
              T\hspace{0.1em}
              E\hspace{0.1em}
               \hspace{0.5em}
              S\hspace{0.1em}
              P\hspace{0.1em}
              A\hspace{0.1em}
              C\hspace{0.1em}
              E\hspace{0.1em}
              S\hspace{0.1em}}
\end{document}

It does the trick and is most flexible, but honestly: it hurts.

\usepackage{soul}

soul is a LaTeX package that provides several markup directives, amongst them \so (for spacing out) that increases letter-spacing:

\documentclass[11pt]{article}
\usepackage{soul}
\usepackage[T1]{fontenc}

\begin{document}
     \section*{\so{WHITE SPACES}}
\end{document}

The macro \sodef can be used to customize the amount of inter-letter space. Make sure you use soulutf8 if you need support for non-ASCII characters.

\usepackage{microtype}

Another LaTeX package that can accomplish the task is microtype. It is definitely worth a look for what it has to provide besides what is shown here, as it claims to no less than to offer sublimial refinements towards typographical perfection.

\documentclass[11pt]{article}
\usepackage{microtype}

\begin{document}
    \section*{\lsstyle WHITE SPACES}
\end{document}

The amount of inter-letter space can be customized:

\usepackage[letterspace=500]{microtype}

If nothing else but letterspacing commands are needed, the letterspace package provides this subset of commands:

\usepackage[letterspace=500]{letterspace}

Programming LaTeX

At one point I tried to roll out my own LaTeX macro, inspired by this post. This I just include because it is instructive and taught me about how to write LaTeX macros. It is not meant for productive use, as especially the use of \obeyspaces, which is needed to correctly show white spaces, can introduce problems with other packages.

\documentclass[11pt]{article}

\def\spacedlettersspace{0.1em}

\def\spacedlettersloop<#1#2>{%
    \ifx\relax#1%
    \else%
        #1\hspace{\spacedlettersspace}\spacedlettersloop<#2>%
    \fi%
}

\def\spacedletters#1{%
    \spacedlettersloop<#1\relax>}
\obeyspaces

\begin{document}
    \section*{\spacedletters{WHITE SPACES}}
\end{document}

Searchability

Be careful when you create a PDF document that has to be searchable. Depending on the PDF reader I found different issues:

Comments

© 2018 Johannes Tax (johannes@johannes.tax)