16

Question

How can I \renewcommand{\todo} to give single spacing in the todonotes of an otherwise double spaced document?

What I have tried

The documentation (p. 11, section 1.8.6) suggests that something like this should work (with todonotes.sty in the proper directory), but it doesn't:

\documentclass[12pt]{article}              
\usepackage{setspace}
\doublespacing
\usepackage[backgroundcolor=white,textsize=tiny]{todonotes}
\newcommand{\smalltodo}[2][] 
    {\todo[caption={#2}, #1]
    {\begin{spacing}{0.5}#2\end{spacing}}} 
\begin{document}
\smalltodo[inline]{testing todonotes here with single spacing}
\end{document}

giving the following error:

Runaway argument?
{\todo [caption={##2}, ##1] {\begin {spacing}{0.5}##2\end {spacing}} \ETC.
! File ended while scanning use of \@xargdef.

But I can't figure out the error.

Once I get this to work, can I just replace \newcommand{\smalltodo} with \renewcommand{\todo} ?

6
  • Your example compiles fine on my system (both with TeX Live 2010 and 2009). What versions of todonotes and setspace are you using?
    – Caramdir
    Jan 5, 2011 at 17:26
  • @Caramdir I was trying to compile the test case on LaTeXLab, I see that it does compile on my desktop installation, but am not sure how to tell what versions of the packages I am using. Jan 5, 2011 at 17:54
  • on your desktop you can see the version in todonotes.sty (the optional argument to \ProvidesPackage at the top) for LaTeXLab I have no idea.
    – Caramdir
    Jan 5, 2011 at 20:20
  • @Caramdir okay, this provides me with a date: \ProvidesPackage{todonotes}[2009/04/02], I was looking for a version number. Jan 5, 2011 at 20:25
  • This is the same version I have installed and it works for me. Strange.
    – Caramdir
    Jan 5, 2011 at 21:12

1 Answer 1

20

While I don't know why it doesn't compile for you, here is an answer to your second question:

No, you can't just use \renewcommend as that would create an infinite loop; every call to \todo would have another call to \todo inside it. However, \todo is actually just an alias for \@todo (apparently the author thought that people might want to redefine it), so you can simply do the following:

\makeatletter
\renewcommand{\todo}[2][]{%
    \@todo[caption={#2}, #1]{\begin{spacing}{0.5}#2\end{spacing}}%
} 
\makeatother 
3
  • thanks for your help. What does \makeatletter, \makeatother do? Jan 5, 2011 at 17:55
  • 2
    @David: per default, @ does not work in command names in the “end user” document, but only works in internal (class/package) files. The \makeatletter changes that and \makeatother resets it.
    – Caramdir
    Jan 5, 2011 at 20:15
  • @Caramidir Thanks for your answer and explanation Jan 5, 2011 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .