todonotes icon indicating copy to clipboard operation
todonotes copied to clipboard

Scrbook: inline todonotes and parfillskip lead to overfull \hbox

Open kiryph opened this issue 6 years ago • 4 comments

Consider this MWE todonotes-2019.tex:

\documentclass[
  % parskip=half,  % 1em; overfull \hbox \hbox (10.45003pt)
  % parskip=half*, % .25\linewidth; Overfull \hbox (104.06389pt too wide)
  parskip=half+,   % 0.33333\linewidth; Overfull \hbox (138.90363pt too wide)
  % parskip=half-, % No overfull \hbox
  % parskip=false, % No overfull \hbox (default)
]{scrbook}
\usepackage{todonotes}

\begin{document}
\the\parfillskip
\todo[inline]{hello}
\end{document}

Run pdflatex and filter output with texfot (perl program preinstalled with TeXLive 2018)

❯ texfot pdflatex todonotes-2019.tex
/Library/TeX/texbin/texfot: invoking: pdflatex todonotes-2019.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex)
Overfull \hbox (138.90363pt too wide) in paragraph at lines 14--14
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Output written on todonotes-2019.pdf (1 page, 15440 bytes).

❯ grep "Package: todonotes" *.log
Package: todonotes 2019/01/24 v1.1.2 Todonotes source and documentation.
Package: todonotes 2018/11/22

❯ grep "Document Class: scrbook" *.log
Document Class: scrbook 2018/12/30 v3.26a KOMA-Script document class (book)

IMHO the overfull \hbox is an unnecessary overfull \hbox which is probably only produced because the inline todonotes take the full linewidth and then \parfillskip is added.

Can this easily be fixed?

kiryph avatar Jan 27 '19 08:01 kiryph

Any updates on this? Running into the same problem. It makes it a real hassle to use the package.

Mastermindaxe avatar Aug 21 '19 12:08 Mastermindaxe

This also affects me. Any updates on this?

Sebastian-Maier avatar Jun 02 '20 14:06 Sebastian-Maier

Not checked what scrbook really does, but the fact the the todonotes use \linewidth seems technically correct.

\makeatletter
\tikzstyle{inlinenotestyle} = [%
    notestyle,%
    text width=\@todonotes@inlinewidth -\parfillskip - 1.6 ex - 1 pt]%
\makeatother

The above avoids the overfull box, but this is not something I think todonotes should set in this way. My guess is that whatever happens here is confusing tikz and todonotes is just the carrier.

FrankMittelbach avatar Jun 02 '20 15:06 FrankMittelbach

Since I was bothered by another effect where the inlinewith led to an overfull \hbox, I looked at the package and found a quick solution: You can define the inlinewidth as an option for the todo \todo[inline,inlinewidth=0.9\textwidth]{this is the todo text}. Not wanting to repeat this every time, I searched a little further and found that I can set a default key for this property.

TLDR; you might not want to try this if your inline todonotes are creating overfull hboxes:

\presetkeys{todonotes}{inlinewidth=0.9\linewidth}{}

You could also use an xpatchcmd ... but the presetkey is imho much cleaner.

\makeatletter
\xpatchcmd{\@todo}{\setkeys{todonotes}{#1}}{\setkeys{todonotes}{inlinewidth=\linewidth-13pt,#1}}{}{}
\makeatother

Hope this helps someone ^^ ~Horo

HoroTW avatar Mar 19 '22 15:03 HoroTW