I have a problem with scrarticle (and its option parskip=half), fontenc and algorithm2e:



If you compile this document (with pdflatex), then there is no padding between the text and the frame of the algorithm. If you remove parskip=half or \usepackage{fontenc} (or both), then everything is fine.

What is happening here? Did I do anything wrong? How to fix this problem?

  • Unrelated: It's pretty pointless to load fontenc without option(s).
    – campa
    Feb 4, 2020 at 8:58
  • Of course, this is just for the MWE. In the real document, I use T1.
    – gerw
    Feb 4, 2020 at 8:59
  • Interesting fact: it depends on the loading order. Loading fontenc after algorithm2e works too.
    – campa
    Feb 4, 2020 at 9:01
  • You can also replace \usepackage{fontenc} by \selectfont and you will observe the same...
    – gerw
    Feb 4, 2020 at 9:04
  • 2
    The margin is calculated with \parindent, and algorithm2e obviously doesn't expect this to be zero when the package is loaded. Feb 4, 2020 at 9:10

1 Answer 1


To solve the problem, I manually set the margin of the algorithm via \setlength{\algomargin}{1em}.

You must log in to answer this question.

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