1

As you can see on the picture, the algorithm environment (from package algorithm2e) does not respect the text width when it is used inside exam questions. Actually, it exceeds the right margin:

\documentclass[12pt]{exam}

\usepackage[margin=1in]{geometry} \usepackage{lipsum} \usepackage[boxed]{algorithm2e} \pagestyle{headandfoot} \header{Lorem}{Ipsum}{Lorem Ipsum} \footer{\textsc{Ipsum Lorem}}{}{Page \thepage\slash \pageref{LastPage}} \headrule \footrule \begin{document} \section{Exercise 1} \begin{questions} \question \lipsum[1] \newline \begin{algorithm}[H] \SetAlgoLined $n \longleftarrow 0$; $u \longleftarrow 280$; \While{$u\geq 205$}{ $n \longleftarrow n+1$; $u \longleftarrow 0,8u+40$; } \Return n \end{algorithm} \end{questions} \end{document}

enter image description here

Lava
  • 11

0 Answers0