# Conflict between microtype, LuaLaTeX, and otf fonts when typesetting material in small-caps

I'm using the microtype package (microtype beta 2.5 build 08) to modify my document and I'd like to retain its functionality across all font shapes with the exception of small-caps (\scshape). How do I do this?

I'm asking this because microtype is not preserving the (\scshape) of section names listed in my table of contents whenever I use otf fonts (adobe caslon pro, adobe garamond pro, etc) that are loaded via fontspec. Instead, it's changing them to regular text. Whenever I don't load micro type, the text reverts to scshape. I'd like to keep the (\scshape) of the section names intact while using microtype without having to abandon use of the aforementioned otf fonts.

Here is what my toc looks like when microtype is enabled:

Here it is with microtype disabled:

I'm building my documents with Lualatex to facilitate loading of otf fonts and their usage with microtype. I notice this issue doesn't occur when using normal latex fonts.

Here is my code:

\documentclass[dotinlabels,nohyper]{tufte-book}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Minion Pro}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage[unicode=true,
bookmarks=true,bookmarksnumbered=true,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=true]
{hyperref}
\usepackage{titletoc}
\usepackage{titlesec}
\usepackage{tocloft}
% If you do not load micro type below, small caps are preserved.
\usepackage[activate={true,nocompatibility},final,tracking=true,factor=1100,stretch=10,shrink=0]{microtype}

\hypersetup{linktocpage=true}

\setcounter{secnumdepth}{1}

\setcounter{tocdepth}{2}

%formatting for toc entries
\renewcommand{\cftsecfont}{\large\scshape\MakeLowercase}
\renewcommand{\cfttoctitlefont}{\scshape\MakeUppercase}
\renewcommand{\cftsecdotsep}{\cftdotsep}
\renewcommand{\cftsecpagefont}{\scshape}
%

\titleformat{\section}{\titlerule\vspace{.8ex}%
\Large\bfseries}{\Large\thesection.}{.5em}{}

\renewcommand{\sectionmark}[1]{%
\markboth{}{\thesection.\ #1}}

\newcommand{\hsp}{\hspace{20pt}}

%Chapter title Formatting
\definecolor{gray75}{gray}{0.75}
\titlespacing{\chapter}{0pt}{*0}{*5}
\titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\huge\bfseries}
%

\begin{document}
\fancyhf{} % clear all header/footer fields
\fancyhead[RO]{\scshape\normalsize\MakeLowercase{\rightmark}}
\fancyfoot[R]{\thepage}

\tableofcontents{}

\chapter{Preliminaries}
\section{Mathematical Induction}
text goes here...
\newpage{}
test
\newpage{}
test
\end{document}

-
As per this answer, you should probably load the font with Renderer=Basic: \setmainfont[Ligatures=TeX,Renderer=Basic]{Minion Pro}. –  Robert Jan 6 '13 at 18:38
@Robert thanks. This actually fixed my problem. I'm not sure exactly what it does, but I'd like to know if there are any compromises made when setting the renderer to basic. You should post your comment as an answer that way I can put a check beside and up vote your input. Thanks again. –  Black Milk Jan 6 '13 at 23:16

## 3 Answers

The reason why the small caps font is changed to the regular one is that microtype's tracking feature does not work flawlessly with lualatex. At the moment, the only fix (apart from not using tracking altogether) is to load the font with Renderer=Basic instead of (the default) Full:

\setmainfont[Ligatures=TeX,Renderer=Basic]{Minion Pro}


Unfortunately, this may have side effects, as switching to the basic renderer means losing some OpenType features. In the case of small caps, for example, less kerning pairs will be defined. While more problems may still be uncovered, there is also the one or the other bug with Renderer=Full.

[I was going to suggest to restrict this to the small caps font:

\setmainfont[Ligatures=TeX,SmallCapsFeatures={Renderer=Basic}]{Minion Pro}


but this does not work.]

-
Similar to my way to deactivate microtype, one could add \addfontfeature{Renderer=Basic} to \scshape, or even \microtypesetup{tracking=false} (as this seems to be the problem altogether): \expandafter\def\expandafter\scshape\expandafter{\scshape\microtypesetup{tracki‌​ng=false}} –  Qrrbrbirlbel Jan 7 '13 at 2:19
@Qrrbrbirlbel By default, tracking is enabled only for small caps, therefore patching \scshape as you propose is tantamount to disabling tracking for each and every font. In that case it would seem easier to simply remove tracking=true from the package options. However, adding \addfontfeature... instead might indeed be an option. –  Robert Jan 7 '13 at 2:50
Oh! I’m not so firm on microtype. But in that case, I’d opt for Renderer=Basic in the ToC (because it actually looks good there), and for tracking=false for normal text. On that note: Apparently tufte-book redefines \textsc, there might be even more discrepancy with my patching way … –  Qrrbrbirlbel Jan 7 '13 at 3:04
@Robert: Rather than setting Renderer=Basic for small caps in the in the initialization of the font in the preamble, I just added it to the formatting at the place in the document where I was using it (a centered title) as on option to \addfontfeatures in this way: \begin{center}{\textls*[100]{\rmfamily \addfontfeatures{Scale=4,Letters=UppercaseSmallCaps,Renderer=Basic}THE TITLE]}\end{center} and it worked fine. I added the brackets to limit the scope of the formatting, though maybe being inside of the centering environment might have done that anyway, but I wasn't sure. –  Stonefeather Grubbs Sep 6 '13 at 0:04

The microtype package offers to define sets of fonts. There is even a pre-defined set name called smallcaps, though it is not of much use as one can apparently only include sets for activated micro-typography.

Excluding small caps would be the same like including everything else.

### Code

\documentclass{article}
\usepackage[
protrusion=false,
expansion=false,
]{microtype}
\DeclareMicrotypeSet{non Small Caps}{shape={it*,up*,sl*}}
\microtypesetup{activate=non Small Caps}
\usepackage{lipsum}
\begin{document}
{\scshape\lipsum}
{\itshape\lipsum}
\end{document}


But as I understand it, this would overwrite every default settings made by microtype; therefore it seems easier to just patch \scshape.

### Code

\documentclass{article}
\usepackage{microtype}
\expandafter\def\expandafter\scshape\expandafter{\scshape\microtypesetup{activate=false}}
\usepackage{lipsum}
\begin{document}
{\scshape\lipsum}
{\itshape\lipsum}
\end{document}

-
Thank you for your answer but I still have a problem that persists, I will elaborate on this issue later with an mwe and pictures. Unfortunately that last piece of code didn't do the trick either. –  Black Milk Jan 5 '13 at 21:42
isn't it easier to \usepackage{etoolbox} \appto\scshape{\microtypesetup{activate=false}}? –  kahen Jan 6 '13 at 0:07
@kahen Well, define “easier”. It is essentially just an etoolbox-sans version. –  Qrrbrbirlbel Jan 6 '13 at 0:15

I'm not sure which aspects of microtype you wish to disable when it comes to dealing with small-caps fonts. I'll assume that it's the tracking (inter-letter and inter-word spacing) that you want to disable. (Somehow, I don't think you want to disable character protrusion optimization for small-caps glyphs.)

To disable microtype's action with regard to tracking for small-caps characters only, you could issue the following command (after loading the microtype package, obviously):

\SetTracking[spacing = {0,0,0}]{encoding=*,shape=sc}{0}

-
I've updated my post to specify exactly what my issue with scshape and micro type is. It pertains to how it formats my entries listed in my toc. –  Black Milk Jan 5 '13 at 23:19
@EdwinMontufar - thanks for clarifying your objective(s). Please consider posting a MWE (minimum working example) that generates the problem behavior you're trying to fix. Without this information, it's going to be hard to pinpoint the source of the problems. –  Mico Jan 5 '13 at 23:32
Thank you. I've posted an mwe alongside images portraying my problem. –  Black Milk Jan 6 '13 at 13:05