[Tex/LaTex] Unclarities about Microtype’s default options

kerningletterspacingmicrotypeprotrusion

I delved deeper into the details of the microtype package to get the best results and perhaps not the safest results. Four things are still unclear after reading the manual, hence a post here.

(1) Microtype's options are default applied to the following font sets:

\DeclareMicrotypeSetDefault[protrusion]{alltext}
\DeclareMicrotypeSetDefault[expansion]{basictext}
\DeclareMicrotypeSetDefault[spacing]{basictext}
\DeclareMicrotypeSetDefault[kerning]{alltext}
\DeclareMicrotypeSetDefault[tracking]{smallcaps}

The rationale to choose smallcaps for tracking is explained, nothing unclear about that. But the rest, why not choose all or allmath?
For the record:
alltext contains the conventional font encodings, except the math font encodings.
basictext contains the conventional encodings with some restrictions on the font's series, shape, and size. And again, the math encodings lack.
allmath contains the conventional encodings and the math encodings OML and OMS but not OMX.
all contains everything.

(2) My current document has many symbols with sub- and superscripts in math mode. These symbols also appear in the body of the text and the visual results are often not very appealing if microtype disregards them while taking the rest into account. I would like microtype to take them into account. Or is there is a good reason to let microtype disregard them?

(3) The manual states option spacing may interfere with the ragged2e package but without stating in what manner. Is the interference that complicated? I use the ragged2e package. Can you reveal a bit more where I should be vigilant for if I enable the spacing option?

(4) Microtype's advice from the log file:

Package microtype Info: Loading generic protrusion settings for font
family (microtype) `lmss' (encoding: OT1). (microtype)
For optimal results, create family-specific settings. (microtype)
See the microtype manual for details.

Since I only use T1 and math encodings, I decided to limit the allmath font set to T1 and math encodings:

\DeclareMicrotypeSet{allmathT1}{ encoding = {T1,TS1,OML,OMS} }
\UseMicrotypeSet[protrusion]{allmathT1}

This caused a different protrusion of merely two lines, these two lines started or ended with a math symbol. Still, it did not protrude math symbols in super- and subscript, which is what I want.
I next decided to limit expansion's basictext font set also to T1, i.e.

\DeclareMicrotypeSet{basictextT1}
{ encoding = {T1},
  family = {rm*,sf*},
  series = {md*},
  size = {normalsize,footnotesize,small,large}
}
\UseMicrotypeSet[expansion]{basictextT1}

Then I see sentences containing math become expanded. This should not be the case, since I did not specify math encodings.

MWE

It took me some effort to contrive an example which is still simple, but I think the code snippet and accompanying screenshot below clearly show the problem. The dash and dot in the first line are correctly protruded in the left and right margin, whereas the subscripts in the subsequent lines are not protruded.

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[final,step=1,tracking,spacing]{microtype}
\microtypecontext{spacing=nonfrench}
\DeclareMicrotypeSet{allmathT1}{ encoding = {T1,TS1,OML,OMS} }
\DeclareMicrotypeSet{basicmathT1}
{ encoding = {T1,OML,OMS},
  family = {rm*,sf*},
  series = {md*},
  size = {normalsize,footnotesize,small,large}
}
\DeclareMicrotypeSet{smallcapsT1}
{ encoding = {T1,TS1},
  shape = {sc*,si,scit}
}
\UseMicrotypeSet[protrusion]{allmathT1}
\UseMicrotypeSet[expansion]{basicmathT1}
\UseMicrotypeSet[tracking]{smallcapsT1}
\UseMicrotypeSet[spacing]{basicmathT1}

\usepackage{mathtools}  %For prescript

\begin{document}

\noindent
%First line becomes protruded, whereas the subsequent lines not
-word word word word word word word word word word word word word word.
| \hfill |\\
$\prescript{}{0}{C}$ \hfill word.\\
$\prescript{}{1}{C}$ word word word word word word word word word words words words w$_\text{ord}$
$\prescript{}{2}{C}$ word word word word word word word word word words words words w$_\text{ordd}$
$\prescript{}{3}{C}$ word word word word word word word word word words words words w$_\text{ord}$
$\prescript{}{4}{C}$ word word word word word word word word word words words words w$_\text{ord}$

\end{document}

Subscripts are not protruded

Best Answer

After searching and experimenting I contrived a partial answer. Please expand if you know the answer to the rest.

First point, about why limit the font sets:

Protrusion. Still unclear why not set all or allmath, results do not worsen then.

Expansion. Setting expansion to all or allmath yields sometimes better results and sometimes worse results. It did reduce the size of nasty 'white holes' in a sentence with several wide fractions. Perhaps a reason to exclude math encodings is because a consistent look of your math expressions is deemed more important than a better look with expansion. You sometimes indeed notice this inconsistency between math symbols, in contrast to regular text.

Spacing. Enabling it reduced nasty 'white holes' in the body text, and additionally it got rid of a widow line better than the nowidow package. I like this option. I see no difference in results between basictext (default) and all, microtype either lacks support for the other font sets here or the other font sets make it impossible to support it. With OT1 encoding I got several warnings, not the case with T1 encoding.

Kerning. From the manual:

It should not be neglected to mention a limitation of this feature: words immediately following such a kern (not separated by a space) will not be hyphenated, unless you insert the breakpoints manually, e.g., for kerning after the apostrophe, ‘l’apos-trophe’. Furthermore, additional kerning will not be applied in math mode. These restrictions of pdfTeX will hopefully be lifted some time.

Second point, about 'microtyping' super- and subscripts.

I hoped that setting protrusion to all or allmath would at least protrude my super- and subscripts, but they are not after testing a few examples. This is also still unclear to me. Are super- and subscripts part of the microtype's unsupported OMX math encoding?
Initially I used all instead of allmath but that gives warning:

Package microtype Warning: I cannot find a protrusion list for font (microtype) `OMX/lmex/m/n/12'. Switching off (microtype) protrusion for this font on input line 104.

Same warning for 'OMX/lmex/m/n/8' and 'OMX/lmex/m/n/6'. I think this warning is a consequence of what the manual states as:

We don’t bother about ‘largesymbols’, since it will only be used in display math, where protrusion doesn’t work anyway. It’s declared as: \DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n}

So I don't think I have to worry about this warning. Indeed, Latex font encodings manual says about OMX:

OMX [sic] encodes mathematical symbols with variable sizes, such as the sign, which changes its size if used in displayed formulas, and the construction parts for brackets, braces and radicals, etc., which can stretch to accommodate the thing they’re enclosing.

Solution to the warnings: switch from font set all to allmath, the latter does not include OMX but still the remaining math encodings OML and OMS.

Third point, about how microtype and ragged2e interfere

I found the answer here. I am still wondering whether Robert's suggestion there is a robust solution, and if so, why not include it in the microtype manual? Robert suggests (for RaggedRight):

\setlength\RaggedRightRightskip{1pt plus 2em minus 1pt} % default is: 0pt plus 2em

Fourth point, optimizing microtype by accurately specifying the font set

Still unclear why Microtype does not protrude math expressions with super- and subscripts and why it expands math expressions when the expansion's font set does not include math encodings.

My current usage of the microtype package

\usepackage[T1]{fontenc}  %T1 font encoding
\usepackage{lmodern}  %Latin Modern is Latex's regular T1 font
\usepackage[final,step=1,tracking,spacing]{microtype}
\microtypecontext{spacing=nonfrench}  %Ensures Microtype's interword spacing remains enabled when other packages change the interword spacing
\DeclareMicrotypeSet{allmathT1}{ encoding = {T1,TS1,OML,OMS} }
\DeclareMicrotypeSet{basicmathT1}
{ encoding = {T1,OML,OMS},
  family = {rm*,sf*},
  series = {md*},
  size = {normalsize,footnotesize,small,large}
}
\DeclareMicrotypeSet{smallcapsT1}
{ encoding = {T1,TS1},
  shape = {sc*,si,scit}
}
\UseMicrotypeSet[protrusion]{allmathT1}
\UseMicrotypeSet[expansion]{basicmathT1}
\UseMicrotypeSet[tracking]{smallcapsT1}
\UseMicrotypeSet[spacing]{basicmathT1}

The step=1 is to ensure my preference for quality over file size when handing over the tex file to someone else.

Related Question