6

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.

4 Answers 4

5

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

1
  • I can make this work just fine on my MWE, but going to my non-MWE I get compile error on the first instance of \subsection - where \myletterspacing occurs. I have tried copying and pasting your \titlesec commands to make sure I have it right, but it's not going. Must be clashing with some other command/package I have.
    – Pwdr
    Jun 11, 2014 at 11:29
4

You need to place the \lsstyle before the \uppercase command, not after.

Sample output

\documentclass{article}

\usepackage[letterspace=150]{microtype}

\usepackage{titlesec}
\titleformat{\section}{\large}{\thesection}{1em}{}
\titlespacing{\section}{0pt}{2.5ex}{2.5ex}
\titleformat{\subsection}{\small\lsstyle\uppercase}{\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]

\lsstyle
\lipsum[2]

\end{document} 

Update This particular feature of microtype does not work with XeLaTeX. But there you can use the font features via fontspec. In particular \addfontfeature{LetterSpace=15} seems to be the sort of thing you are after:

xelatex sample

\documentclass{article}

\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Times}

\usepackage{titlesec}
\titleformat{\section}{\large}{\thesection}{1em}{}
\titlespacing{\section}{0pt}{2.5ex}{2.5ex}
\titleformat{\subsection}{\small\addfontfeature{LetterSpace=15}\uppercase}{\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]

\end{document} 
5
  • I get the following response in the console when hitting H for help: Run pdftex or luatex, or run 'soul' package instead. But I'm typesetting under pdftex
    – Pwdr
    Jun 11, 2014 at 9:05
  • The above compiles fine under pdflatex for me. What error message are you getting? Jun 11, 2014 at 12:21
  • As I said above: "Run pdftex or luatex, or use the `soul' package instead."
    – Pwdr
    Jun 11, 2014 at 12:24
  • Which suggests you have not run pdflatex... Jun 11, 2014 at 13:32
  • Ah yes. While it does compile under pdflatex, see my edit to original post and my own answer below - I'm using XeLaTeX for font control which clashes various attempts to get letterspaced, capitalised section headings. I have given up now, it's far more effort than it's worth.
    – Pwdr
    Jun 11, 2014 at 13:45
0

Use

\titleformat{\subsection}{\small\lsstyle\uppercase}{\thesubsection}{1em}{}

it changes the order of \lsstyle and \uppercase

1
  • I get the following response in the console when hitting H for help: Run pdftex or luatex, or run 'soul' package instead. But I'm typesetting under pdftex.
    – Pwdr
    Jun 11, 2014 at 9:02
0

It appears my issue is/was with XeLaTex.

Gonzalo Medina provides an answer to this similar question: Letterspacing memoir section headers

In his second MWE he provides an example of using the soul package with titlesec.

In the MWE below I have applied spacing to section headings in a similar manner.

In addition to calling and defining the soul package, note the use of [explicit] prior to titlesecand invoking soul at the end of each format line.

Again, this is for XeLaTex typesetting with fontspec defining fonts.

According to the soul documentation: http://texdoc.net/texmf-dist/doc/latex/soul/soul.pdf the parameters are as follows:

\sodef⟨cmd⟩{⟨font⟩}{⟨inter-letter space⟩}{⟨inner space⟩}{⟨outer space⟩}

\documentclass{article}

\usepackage{fontspec,xltxtra,xunicode,setspace}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Arno Pro}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Century Gothic}
\setmonofont[Scale=MatchLowercase]{Inconsolata}

\usepackage{lipsum}

\usepackage{soul}
\sodef\soSection{}{.1em}{.5em plus.1em}{.1em plus.1em minus.1em}
\sodef\soSubsection{}{.1em}{.5em plus.1em}{.1em plus.1em minus.1em}
\sodef\soSubsubsection{}{.1em}{.5em plus.1em}{.1em plus.1em minus.1em}

\usepackage[explicit]{titlesec}
\titleformat{\section}{\large}{\thesection}{1em}{\soSection{#1}}
\titlespacing{\section}{0pt}{2.5ex}{2.5ex}
\titleformat{\subsection}{\small\uppercase}{\thesubsection}{1em}{\soSubsection{#1}}
\titlespacing{\subsection}{0pt}{2.5ex}{0ex}
\titleformat{\subsubsection}{\sffamily\itshape}{\thesubsubsection}{1em}{\soSubsubsection{#1}}
\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}
\lipsum[1]

\subsection{Subsection, my friend}
\lipsum[2]

\subsubsection{Subsubsub}
\lipsum[3]

\end{document} 
1
  • Too good to be true. This answer (possibly the soul package) is incompatible with \tableofcontents.
    – Pwdr
    Jun 11, 2014 at 9:42

You must log in to answer this question.

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