[Tex/LaTex] Spacing capitals in section headings

microtypesectioningtitlesec

I'm using titlesec to customise my section headings.
I want to have my subsections in capitals, which I can achieve with the \uppercase function, but all typographic style guides suggest that caps should have increased space.

The microtype package can apply increased letter spacing, according to:
Enlarging tracking (= letter spacing)

The thread mentions a command of \textls which I have tried inserting into the titlesec options, but TexShop throws up an error when typesetting.

Alternatively, using the switch \lsstyle doesn't work either.

Here's MWE:

\documentclass{article}

\usepackage[letterspace=150]{microtype}

\usepackage{titlesec}
\titleformat{\section}{\large}{\thesection}{1em}{}
\titlespacing{\section}{0pt}{2.5ex}{2.5ex}
\titleformat{\subsection}{\small\uppercase\lsstyle}{\thesubsection}{1em}{}
\titlespacing{\subsection}{0pt}{2.5ex}{0ex}
\titleformat{\subsubsection}{\sffamily\itshape}{\thesubsubsection}{1em}{}
\titlespacing{\subsubsection}{0pt}{1.5ex}{0ex}
\titleformat{\paragraph}[runin]{\normalfont\normalsize}{\theparagraph}{1em}{}
\titleformat{\subparagraph}[runin]{\normalfont\normalsize}{\thesubparagraph}{1em}{}

\title{Minimal Working Example}
\date{}
\author{Author}

\begin{document}
\maketitle

\section{Section 1}
Content

\subsection{Subsection, my friend}

\end{document} 

Edit: am using XeLaTeX in my non-MWE to access system fonts. The error I get (see comment to an answer below) occurs in XeLaTeX.

Best Answer

You should be using \MakeUppercase, not \uppercase, although they're almost equivalent in a XeLaTeX or LuaLaTeX context.

The letterspacing for microtype option cannot be used with XeLaTeX, but it can be replaced by \addfontfeatures{LetterSpace=...}.

So, here is a working example; one might redefine \lsstyle when XeLaTeX is used, but I believe it's better not to and use a personal command.

\documentclass{article}
\usepackage{ifluatex}
\usepackage{fontspec}
\usepackage{microtype}

\setmainfont[Ligatures=TeX]{Linux Libertine O}

\ifluatex
  \microtypesetup{letterspace=150}
  \newcommand{\myletterspacing}{\lsstyle}
\else
  \newcommand{\myletterspacing}{\addfontfeatures{LetterSpace=20}}
\fi

\usepackage{titlesec}
\titleformat{\section}{\large}{\thesection}{1em}{}
\titlespacing{\section}{0pt}{2.5ex}{2.5ex}
\titleformat{\subsection}{\small\myletterspacing\MakeUppercase}{\thesubsection}{1em}{}
\titlespacing{\subsection}{0pt}{2.5ex}{0ex}
\titleformat{\subsubsection}{\sffamily\itshape}{\thesubsubsection}{1em}{}
\titlespacing{\subsubsection}{0pt}{1.5ex}{0ex}
\titleformat{\paragraph}[runin]{\normalfont\normalsize}{\theparagraph}{1em}{}
\titleformat{\subparagraph}[runin]{\normalfont\normalsize}{\thesubparagraph}{1em}{}

\usepackage{lipsum}

\title{Minimal Working Example}
\date{}
\author{Author}

\begin{document}
\maketitle

\section{Section 1}
Content

\subsection{Subsection, my friend}

\lipsum[1]

\myletterspacing
\lipsum[2]

\end{document} 

enter image description here