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 Feb 4 '20 at 8:58
  • Of course, this is just for the MWE. In the real document, I use T1. – gerw Feb 4 '20 at 8:59
  • Interesting fact: it depends on the loading order. Loading fontenc after algorithm2e works too. – campa Feb 4 '20 at 9:01
  • You can also replace \usepackage{fontenc} by \selectfont and you will observe the same... – gerw Feb 4 '20 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. – Ulrike Fischer Feb 4 '20 at 9:10
0

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

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.