2

I would like to see the number of todos I have left. Therefor I tried to redefine the todo command as follows:

\newcounter{todocounter}
\renewcommand{\todo}[2][]{\stepcounter{todocounter}\todo[#1]{#2}}

However this seems to cause an infinite loop (the todo inside the definition seems to use the todo in the declaration). Searching only yielded this which does not help in my case. Is there a trick to make this work? (etoolbox/ can I use some expansion time wizardry/would an alias help)

I do not want to replace all todos with numberedTodo or similar.

ted
  • 3,377
  • You can see this question : http://tex.stackexchange.com/questions/88001/when-to-use-letltxmacro (it isn't a duplicate in my opinion, though). – T. Verron Jul 23 '13 at 08:12
  • @T.Verron: thanks, that was the hint I was looking for. – ted Jul 23 '13 at 08:29

1 Answers1

4

With T.Verrons hint it becomes obvious. The infinite recursion can be solved by creating a copy of the macro with a different name.

\usepackage{letltxmacro}
...
\newcounter{todocounter}
\LetLtxMacro{\oldTodo}{\todo}
\renewcommand{\todo}[2][]{\stepcounter{todocounter}\oldTodo[#1]{#2}}
...
\thetodocounter

If anyone finds this and wants to print the total number of todos before the end of the document check out this answer: How to display the final value of a counter at the beginning of a document?

ted
  • 3,377