2

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

\documentclass[parskip=half]{scrartcl}
\usepackage{fontenc}
\usepackage[boxed]{algorithm2e}

\begin{document}
\begin{algorithm}
    \KwData{test}
\end{algorithm}
\end{document}

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?

5
  • Unrelated: It's pretty pointless to load fontenc without option(s).
    – campa
    Commented Feb 4, 2020 at 8:58
  • Of course, this is just for the MWE. In the real document, I use T1.
    – gerw
    Commented Feb 4, 2020 at 8:59
  • Interesting fact: it depends on the loading order. Loading fontenc after algorithm2e works too.
    – campa
    Commented Feb 4, 2020 at 9:01
  • You can also replace \usepackage{fontenc} by \selectfont and you will observe the same...
    – gerw
    Commented 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. Commented Feb 4, 2020 at 9:10

1 Answer 1

0

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 .