2

I want to disable the protrusion for endashes and emdashes. The line filling does not look good there ...

But how to do so? According to the answers here, I tried to manipulate the font packages but it does not have any effect.

Which is the correct font package I have to load while using lmodern – is it lmr? What are the settings to take single characters out from protrusion?

Here is a MWE to see whats going wrong, seen at the beginning of line 2 and the end of line 5, and below the same text with protrusion disabled at all.

enter image description here

Protrusion should remain enabled for other characters, it is only about -- and ---.

Do you have some suggestions? :)

\documentclass[a4paper, 12pt, headsepline]{scrreprt}
\setlength{\parindent}{0pt}
\usepackage{geometry}
  \geometry{left=3.5cm, right=2cm, top=2.5cm, bottom=2cm}
\usepackage{setspace}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{microtype}
  \LoadMicrotypeFile{lmr} % Which file do I need?
  \SetProtrusion
    [ name = lmr-adapted,
      load = lmr-T1 ]
    { encoding = T1,
      family   = {lmr,lmrx,lmrj} }
    { 
      \textendash = {0,0},
      \textemdash = {0,0}, % does not have any effect
      -- = {0,0},
      --- = {0,0} % does not have any effect
    }

\begin{document}

Hello world, bli bla blubb, how are you, I'm fine -- well, I need some stupid text. Damn... -- Maybe I should write a really loooooooooooooooooooooooooooooooooooooooooooooo\-ooooooooong line to fill the space. A chemist walks into a pharmacy and asks the pharmacist, “Do you have any acetylsalicylic acid?” “You mean aspirin?” asked the pharmacist. “That’s it! I can never remember that word.” \dots Well, that's some text ---
But how can I suppress that annoying protrusion for emdashes? 1 2 3 4 5 6 7 8 9 10 11\\

\microtypesetup{protrusion=false}
Hello world, bli bla blubb, how are you, I'm fine -- well, I need some stupid text. Damn... -- Maybe I should write a really looooooooooooooooooooooooooooooooooooooooooooo\-ooooooooong line to fill the space. A chemist walks into a pharmacy and asks the pharmacist, “Do you have any acetylsalicylic acid?” “You mean aspirin?” asked the pharmacist. “That’s it! I can never remember that word.” \dots Well, that's some text ---
But how can I suppress that annoying protrusion for emdashes? 1 2 3 4 5 6 7 8 9 10 11

\end{document}
  • 1
    You're close: \LoadMicrotypeFile{cmr} (and remove the -- and --- lines) – Robert Feb 14 at 16:13
  • @Robert: Are you sure? cmr is also not working for me. (I changed all lmr commads to cmr respectively.) – Max16hr Feb 14 at 16:36
  • 1
    Don't change the other lmrs. The family is called lmr but its settings are in mt-cmr.cfg. – Robert Feb 14 at 16:40
  • Uff. That is hard to find out by yourself. Thanks a lot, it is working now! You should make that to a real answer, so I can accept it. – Max16hr Feb 14 at 16:43
1

tl;dr

Change the last l in LoadMicrotypeFile{lmr} to c.


This might seem tricky to find but it's often helpful to consult the log file. Running your example yields two warnings:

Package microtype Warning: Configuration file mt-lmr.cfg
(microtype)                does not exist on input line 11.

This tells us that we are loading the wrong file -- but which would be the right one? A clue is given by the second warning (with a bit of context):

File: mt-cmr.cfg 2013/05/19 v2.2 microtype config. file: Computer Modern Roman 
(RS)

Package microtype Warning: protrusion codes list `lmr-T1' will
(microtype)                override list `lmr-adapted' for 
(microtype)                font `T1/lmr///' on input line 138.

saying that the adapted settings are overridden by some other settings (the ones shipped with the package), which means that the adapted settings will never come in effect. And the line immediately preceding this warning tells us in which file the settings are defined: mt-cmr.cfg.

So, we change \LoadMicrotypeFile{lmr} to LoadMicrotypeFile{cmr} and see what happens:

First of all, the dashes are no longer protruded, so we're good.

But then, there are two new warnings:

Package microtype Warning: Unknown slot number of character
(microtype)                `--'
(microtype)                in font encoding `T1'.
(microtype)                Make sure it's a single character
(microtype)                (or a number) in protrusion list
(microtype)                `lmr-adapted'.

Package microtype Warning: Unknown slot number of character
(microtype)                `---'
(microtype)                in font encoding `T1'.
(microtype)                Make sure it's a single character
(microtype)                (or a number) in protrusion list
(microtype)                `lmr-adapted'.

which is a good sign in a way, because it means that the right settings are loaded, but of course also bad because it's a warning. To get rid of them, just delete the two corresponding lines in the settings.

It is also often helpful to load microtype with the verbose option, which allows checking which settings are loaded. In the log file we then find:

Package microtype Info: Setting up font `T1/lmr/m/n/12' on input line 24.
Package microtype Info: ... Loading protrusion list `lmr-adapted'.
Package microtype Info: ... : First loading protrusion list `lmr-T1'.
Package microtype Info: ... : First loading protrusion list `cmr-T1'.
Package microtype Info: ... : First loading protrusion list `cmr-default'.

So, to summarise, the following will do what you want:

  \LoadMicrotypeFile{cmr} 
  \SetProtrusion
    [ name = lmr-adapted,
      load = lmr-T1 ]
    { encoding = T1,
      family   = {lmr} } % lmrx and lmrj don't exist
    { 
      \textendash = {0,0},
      \textemdash = {0,0}, 
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.