10

When I write a document in Latex I usually use my custom \todo{<my note>}-command to not forget things that I will have to come back to. Something like

\newcommand{\todo}[1]{{\color{red}\textbf{TODO:}~{#1}}}

jumps into the eye well enough.

But I would like it even better, if I had a list of all todos that are sprinkled around a document. I.e. a command like \todolist that generates a list of all my todos (optionally with page and line info). Similar to a list of figures.

Since I am not an expert in Latex, I have troubles estimating the amount of work that I would have to be put into that. I would think I need a counter ... but what else? What other Latex building blocks are needed? :-)

lockstep
  • 250,273
nils
  • 203
  • 2
  • 5

3 Answers3

14

The documentation of todo (page 5) says:

Command \todos prints the final list that gathers the todo text of all the todos (except todoenv environments, that simply refer to the text). Each item has a box, checkmarked when \done, the todo number, and a reference (and interactive link if hyperref is on) to the page where it appears.

The documentation of todonotes (page 2) says:

The \listoftodos command inserts a list of all the todos in the current doc- ument. \listoftodos takes no arguments. For this document the list of to–do’s looks like.

Marco Daniel
  • 95,681
7

You don't mention the todo or todonotes in your question, so if you want to do this using your own command, the following might be useful. The main part comes from Gonzalo's answer to

Creating list of for \newtheoremstyle

The code starts a new toc file, \jobname.tod.

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}% just to generate text

\newcounter{todo}
\newcommand\todo[1]{\refstepcounter{todo}\marginpar{\color{red}{#1}}\addcontentsline{tod}{subsection}{#1~\thetodo}}%


\makeatletter
\newcommand\todoname{todo}
\newcommand\listtodoname{List of todos}
\newcommand\listoftodos{%
  \section*{\listtodoname}\@starttoc{tod}}
\makeatother

\begin{document}

\listoftodos

\section{Main document}
\lipsum[1]\todo{fix this}

\lipsum[2]\todo{and this}


\end{document}
cmhughes
  • 100,947
2

If you are looking for a package that already does this, I would recommend todonotes. It has a number of configuration options, and may save you some effort getting to what you want. Even if you are putting together something custom on your own, the source should be helpful in generating the lists.