6

Here is the code:

\documentclass{article}
\usepackage{microtype}
\begin{document}
\begin{verbatim}
+++
+++
+++
+++
\end{verbatim}
\end{document}

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.

yegor256
  • 12,021

1 Answers1

4

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):

\makeatletter
\MT@define@patch{verbatim}
  {\MT@append@patch\@verbatim{\microtypesetup{activate=false}}}{}
\makeatother
Robert
  • 14,181
  • 1
  • 52
  • 77