Here is the code:


It renders as such (notice a small indentation at the first line):

enter image description here

If I remove microtype, it renders correctly. Why and how to fix this? I love microtype and don't want to get rid of it.

  • There is a very related question: Microtype and quote environment leads to different indent of first line. You can put \microtypesetup{protrusion=false} before the environment, as suggested in one of the answers there, or redefine the environment to do that automatically.
    – dexteritas
    Oct 26, 2022 at 16:11
  • 4
    \AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}} Oct 26, 2022 at 16:12
  • see also the "Hints and Caveats" section in the microtype documentation (which suggests a different line; @UlrikeFischer's solution is actually more up to date).
    – Robert
    Oct 26, 2022 at 17:01
  • OpTeX disables prortusion in verbatim environment by default. Why LaTeX does not do this?
    – wipet
    Oct 26, 2022 at 19:10
  • @wipet well, I wasn't thinking about it. But I'll probably do this with the next update (microtype, not latex).
    – Robert
    Oct 26, 2022 at 20:08

1 Answer 1


As has been noted in the comments, this is due to the fact that protrusion is applied to all lines in the verbatim block except the first one (because of some intricacies of the verbatim environment). In principle, you wouldn't want protrusion in verbatim text anyway, so it's the best idea to switch it off there. Ulrike's solution (as well as the one given in the "Hints and caveats" section of the microtype documentation), however, have the disadvantage that they will also affect the preceding paragraph if it's not separated by an empty line.

Therefore, I suggest to add the following after the package has been loaded (and this will also be included in the next release of microtype):


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .