[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#470141: [todo.sty] bug and suggested fix



Hi,

On the Debian bug tracking system, it was reported that the \todo command from
your todo.sty package sometimes unexpectedly complains about a 'bad space
factor', when used in vertical mode. I checked this out, and I think the
problem arises when the \@bsphack at the beginning of the \todo command is
executed in vertical mode, but the \@esphack at the end is executed in
horizontal mode. This happens if and only if the default option 'superscript'
is used, and the \todo command is used in vertical mode.

I think the following is a way to fix this:

\newcommand\@todoleavevmode{} %new
\DeclareOption{superscript}{%
  \renewcommand\@todomark{\@todosupermark}%
  \renewcommand\@todoleavevmode{\leavevmode}} %new
\DeclareOption{marginpar}{%
  \renewcommand\@todomark{\@todomarginpar}%
  \renewcommand\@todoleavevmode{}} %new
\DeclareOption{nothing}{\let\@todomark\@gobble
  \renewcommand\@todoleavevmode{}} %new

\newcommand{\todo}[2][\todomark]{\@todoleavevmode\@bsphack\@todohide{%
% the rest as in the current code (only the \@todoleavevmode added above)

This make the \leavevmode happen earlier than in \@todosupermark with the
super, and in any case either no happen at all, or before the
\@bsphack/\@esphack couple. (I think hard-coding the \leavevmode at the
beginning of \todo is not a good idea since it makes unwanted vertical space
when using \todo with the 'nothing' option in vertical mode, for example.)

Of course you can also think that \todo should not be used in vertical mode
with the 'superscript' option and not fix this, but maybe it would be a good
idea to mention this restriction in the documentation then.

Best,
Manuel.



Reply to: