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}
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
orallmath
, results do not worsen then.Expansion. Setting
expansion
toall
orallmath
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) andall
, 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:
Second point, about 'microtyping' super- and subscripts.
I hoped that setting protrusion to
all
orallmath
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 ofallmath
but that gives warning: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:
So I don't think I have to worry about this warning. Indeed, Latex font encodings manual says about OMX:
Solution to the warnings: switch from font set
all
toallmath
, 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):
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
The
step=1
is to ensure my preference for quality over file size when handing over the tex file to someone else.