Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a larger document and I use the todonotes package to add reminders. For some reason, when I add a note, the space after the note's insertion point is removed. Here's minimal example:

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[textsize=scriptsize,textwidth=2cm,shadow]{todonotes}
\begin{document}
Lorem ipsum dolor sit amet,\todo{stolen space} consectetuer adipiscing elit.
\end{document}

And here's the result I'm getting:

Image of a line with a todo note

And a blown up section of the missing space:

Blown up section, where the space is missing

I thought this might just be an artifact experienced while the notes are active, which would be acceptable since the final document will not have any notes, so I tried to disable them by \usepackage[disable,textsize=scriptsize,textwidth=2cm,shadow]{todonotes}. Now the notes are gone, but the space is still missing. It's bad.

Am I doing something wrong, or is this a shortcoming of the todonotes package?

Also, I have noticed when I add {} to the end of the note (\todo{correct? spacing}{}), the missing space magically re-appears. However, I'm not sure it's a good solution.

share|improve this question
    
Please see the answer of @egreg and the comments to the question tex.stackexchange.com/questions/223596/… and consider to change your accept. –  Kurt Jan 17 at 14:31

4 Answers 4

up vote 16 down vote accepted

I short look in the source of todonotes reveals that both the enabled and disabled version have a \ignorespaces at the end, so yes, it is a feature not a bug. Apparently this is the preference of the package author.

The manual doesn't mention anything about spaces and there is no option to disable the \ignorespaces. Therefore you will need to add the space manually by yourself (as long you don't use your own copy of todonotes.sty with both \ignorespaces removed).

Possible ways to keep the space (some already mentioned in the other answers):

lorem ipsum \todo{...}dolor sit amet
lorem ipsum \todo{...} dolor sit amet
lorem ipsum\todo{...}\ dolor sit amet
lorem ipsum{\todo{...}} dolor sit amet
share|improve this answer
    
... and lorem ipsum \todo{...} dolor sit amet, which I'd prefer. –  Hendrik Vogt Feb 23 '11 at 9:06
    
@Hendrik: Yes, you are right. I added that. I think now that this is the preferred form of the package author and the reason he added \ignorespaces. –  Martin Scharrer Feb 23 '11 at 9:07
    
@MartinScharrer Please, remove the suggestion of using \xspace; it does more damages than it helps. –  egreg Jan 17 at 14:19
    
@egreg: Ok, done! –  Martin Scharrer Jan 20 at 22:54
2  
@MartinScharrer The current version of the todonotes manual lists it as a known issue, so I don't think this is the choice of the author: See 1.6.2: ctan.math.ca/tex-archive/macros/latex/contrib/todonotes/… –  Canageek May 13 at 20:05

My best guess is that this is a feature of todonotes and that you're supposed to put a space between the , and \todo. I've tested: This gives correct spacing.

share|improve this answer
    
I was under the impression \todo worked the same way as \footnote so I never even tried to add a space in front of the command... Thanks for opening my eyes. –  Heisenb0rg Feb 23 '11 at 8:55
1  
@Heisenb0rg: Ah, the analogy with \footnote is good. Didn't think of that. –  Hendrik Vogt Feb 23 '11 at 9:04
    
@HendrikVogt The current version of the todonotes manual lists it as a known issue, so I don't think this is the choice of the author: See 1.6.2: he current version of the todonotes manual lists it as a known issue, so I don't think this is the choice of the author: See 1.6.2: –  Canageek May 13 at 20:05

You can also wrap \@bsphack ... \@esphack around \todo as described in Patching commands to remove surrounding whitespace and the answers explaining how to properly patch commands :)

Concretely, adding

\usepackage{xpatch}
\makeatletter
\xpretocmd{\todo}{\@bsphack}{}{}
\xapptocmd{\todo}{\@esphack}{}{}
\makeatother

to the preamble unintrusively converts \todo to a command that does not take up any space.

share|improve this answer

This might be a result also observed after commands such as \LaTeX where spaces are 'killed'. So even with the disable option the command is still in the code and apparently somehow interpreted.

A solution might be to add the xspace package and to use

\newcommand{\mytodo}[1]{\todo{#1}\xspace}

(untested)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.