1

Feeding

\documentclass{article}
\pagestyle{empty}
\usepackage{algorithm2e}
\usepackage{todonotes}
\overfullrule=2mm
\begin{document}
\begin{algorithm}
  \todo[inline]{Note}
\end{algorithm}
\end{document}

to any of [pdf|xe|lua]latex results in an overfull hbox, though the document doesn't have enough actual contents to get overfull:

output

Why does this happen, who is the culprit, and how to fix this?

The maintainers of todonotes and algorithm2e have been informed.

1 Answer 1

0

Maintainer of the todonotes package checks in here.

The todonotes package relies on the length \linewidth to adjust the width of the inserted inline todo. This seems to work fine inside the itemize environment. As you have demonstrated, this is not the case in the algorithm environment. According to http://latexref.xyz/Page-layout-parameters.html, the linewidth should be decreased when entering environments like itemize, that modify the left and right margins. I think that this should also be the case in the algorithm environment.

One workaround is to specify the option inlinewidth=\linewidth-1.1cm to the todo command, as demonstrated below.

Example of using the inlinewidth option to the todo command.

\documentclass{article}
\pagestyle{empty}
\usepackage{algorithm2e}
\usepackage{todonotes}
\overfullrule=2mm
\begin{document}
\noindent
\rule{\linewidth}{0.1mm}
\begin{algorithm}
\todo[inline]{Note}
\todo[inline, inlinewidth=\linewidth-1.05cm]{Note}
\end{algorithm}

\noindent
\rule{\linewidth}{0.1mm}
\todo[inline]{Note}
\noindent
\rule{\linewidth}{0.1mm}

\begin{itemize}
\item \todo[inline]{Note}
\end{itemize}

\end{document}
1
  • +1 Thx!!! Perhaps, \linewidth-\algomargin-.5cm (instead of \linewidth-1.1cm and \linewidth-1.05cm) could be more general.
    – user224332
    Sep 29, 2022 at 14:47

You must log in to answer this question.