Modifying (i.e., partially overriding) microtype's character protrusion settings for specific characters

I would like to disable or modify character protrusion (enabled by microtype) for specific characters.

Let me illustrate the issue with the en-dash, which protrudes far too wide for my taste:

(left: without protrusion; right: with protrusion)

I am however unable to disable protrusion with \SetProtrusion:

\documentclass{memoir}
\usepackage{mathptmx}
\usepackage[T3,T1]{fontenc}
\usepackage{microtype}
%\usepackage[protrusion=false]{microtype}
\SetProtrusion
{ encoding = T1,
family   = ptm }
{ \textendash = {,0} }

\begin{document}

Word word word word word word word word word word word word word word -- word
word word word word word word word word word word word word word word word
word word word word word word word word word word word word word word word
word word word word word word ...

\end{document}


I also get the following warning:

Package microtype Warning: protrusion codes list ptm-T1' will override list
(microtype)                q.tex/9' for font T1/ptm///' on input line 105.


According to How do I call microtype's \SetProtrusion in the preamble?, including a line \LoadMicrotypeFile{ptm} just before \SetProtrusion helps; if I try this, this does seem to address the issue for -- (\textendash), but (1) the annoying warning stays and (2) my code disables all protrusion (by overriding the whole list of protrusion values with my short list). What is the right way to partially override default character protrusion settings? Ideally there will be a way that does away with any warnings while not disabling important microtype functionality.

• \LoadMicrotypeFile{ptm}\SetProtrusion[name=myptm,load=ptm-T1]{ encoding = T1 , family = {ptm,ptmx,ptmj} }{ \textendash = {,0} } seems to work. and as this loads ptm-T1 before it overrides it I guess you can ignore the warning. – cgnieder Jul 14 '13 at 17:12

This is how you can extend or alter existing settings:

1. Make sure that the settings you want to change are already loaded; in the preamble, this isn't guaranteed to be the case, so you need \LoadMicrotypeFile.

2. Create new settings that load the default settings by way of the load key.

3. If you want set protrusion for any glyph to zero, you explicitly have to do that – declaring empty protrusion values (e.g. \textendash = {,}) will not change anything.

4. If the warning you receive disturbs you, you can suppress it by loading the package with verbose=silent; note, however, that this will also suppress all other microtype warnings. (I guess something like a override key for settings would be useful, but for now it is how it is.) EDIT: Since version 2.7, you will no longer receive a warning if the overridden list is the same as the one that's been loaded.

So, to turn this into code:

\usepackage[verbose=silent]{microtype}
\SetProtrusion
[ name = ptm-adapted, % the name is optional
{ encoding = T1,
family   = {ptm,ptmx,ptmj} }
{
\textendash = { ,0},      % left protrusion will remain untouched,
% right protrusion set to zero
%\textendash = {150,150},  % this would set protrusion on both sides to 150
}


To adjust settings for more than one font, you have to do the same again (loading the settings and creating new ones), i.e. issue \SetProtrusion (with \LoadMicrotypeFile) multiple times:

\LoadMicrotypeFile{ppl}
\SetProtrusion
{ encoding = T1,
family   = {ppl,pplx,pplj} }
{ ... }


Another, simpler but less fine-grained, possibility might be to load the package with a factor less than 1000; this will scale the protrusion values for all glyphs of all fonts. For example,

\usepackage[factor=500]{microtype}


would halve all protrusion values.

• You could use the silence package to specifically mute this one warning: \WarningFilter{microtype}{protrusion codes list} – languitar May 19 '17 at 7:58

I presently load microtype with protrusion adjustments as follows. Perhaps someone is interested in using my values, especially for Times (ptm), which imho has too much protrusion. Please note that my selection of adjustments is not an attempt at being exhaustive.

\usepackage[verbose=silent]{microtype}
\SetProtrusion
{ encoding = T1,
family   = {ptm,ptmx,ptmj} }
{ f = { ,-200},
r = { ,-100},
\textquoteleft     = {300, }, % default uses 500
\textquoteright    = { ,300}, % default uses 500
\textquotedblleft  = {75, }, % default uses 300
\textquotedblright = { ,75}, % default uses 400
\textendash = {0,0}, % default is 300/300
\textemdash = {0,0}, % default is 200/200
/           = { ,-100}, % default uses 200
(           = {67, }, % default uses 100
)           = { ,67}, % default uses 200
{,}         = { ,167}, % default uses 500
:           = { ,167}, % default uses 500
;           = { ,100}, % default uses 300
.           = { ,233}, % default uses 700
?           = { ,33} } % default uses 100
\SetProtrusion
{ encoding = T1,
family   = {ptm,ptmx,ptmj},
shape    = {it,sl} }
{ f = { ,-300},
: = { ,0}, % default uses 500
. = { ,233} } % default uses 700
\SetProtrusion
{ encoding = T1,
family   = {ppl,pplx,pplj} }
{ \textquoteleft     = {150, }, % default uses 500
\textquoteright    = { ,150}, % default uses 700
\textquotedblleft  = {75, }, % default uses 300
\textquotedblright = { ,75}, % default uses 400
\textendash = {0,0}, % default is 300/300
\textemdash = {0,0}, % default is 200/200
/           = { ,100}, % default uses 300
(           = {50, }, % default uses 100
)           = { ,150}, % default uses 300
{,}         = { ,250}, % default uses 500
:           = { ,250}, % default uses 500
;           = { ,250}, % default uses 500
.           = { ,350}, % default uses 700
?           = { ,100} } % default uses 200
\SetProtrusion
[ name = txtt ]
{ encoding = T1,
family   = txtt,
shape    = {it,sl} }
{ f = { ,-120},
- = { ,300} } % in order to match ordinary hyphens' protrusion in body text
`