# Collect the input of all \TODO commands used in the document at the end

I have a command \TODO (and \FIXME) that display a review note in the document. I'd like to collect all those notes at the end of the document as well, like a list of figures.

Is there some easy way to do this with the remark and the page number? Extra points for listing the section as well.

• Do you know the package todonotes? – Mensch Apr 2 '13 at 18:26

## 2 Answers

tocloft

You can define new lists using the tocloft package.

For example:

\newlistof{todo}{lotd}{TODO List}


Then, in your TODO command:

\newcommand*{\TODO}{%
\refstepcounter{todo}
\addcontentsline{lotd}{todo}{TODO \thetodo}
% Your TODO command
}


Finally, at the end of the document, you can run:

\listoftodo


to print a table of todo's similar to the table of contents or list of figures. More info in the tocloft documentation.

todonotes

As someone else suggested, the todonotes package also looks good. It works in a similar manner, and you can insert a list using:

\listoftodos


The question has been marked as community wiki in case there are other packages like this I've missed.

As you see, I flag the todo in the text itself. If you don't wish to disturb your formatting, you could eliminate that feature, but it might then be hard to locate the todo in the original document. (EDITED to remove spurious whitespace)

\documentclass{article}
\usepackage{ifthen}
\newcounter{todoindex}
\setcounter{todoindex}{0}
\newcommand\TODO[1]{%
\addtocounter{todoindex}{1}%
\expandafter\def\csname todo\roman{todoindex}\endcsname{#1}%
(TODO \arabic{todoindex})%
}
\newcounter{index}
\newcommand\showTODOs{%
\vspace{5ex}%
\rule{10ex}{.5ex}TO-DO LIST\rule{10ex}{.5ex}\\%
\setcounter{index}{0}%
\whiledo{\value{index} < \value{todoindex}}{%
\addtocounter{index}{1}%
\arabic{index}):  \csname todo\roman{index}\endcsname\\%
}%
}
\begin{document}

I start hear \TODO{Fix this bug} and do some work

THen I do thiis \TODO{Get spelling fixed, too} which I have to get back
to

and then I am done

\showTODOs

\end{document}


• Looks interesting, but it yielded just a list of numbers, but no text for me. I'll be using Sam Whited's answer, since it is shorter. – Martin Ueding Apr 2 '13 at 18:09
• @queueoverflow When using it, did you pass an argument to the \TODO command? It saves the argument for regurgitation later. – Steven B. Segletes Apr 2 '13 at 18:12