Pretext: I am aware of packages such as todonotes, todo, and fixme, but this is more of a task for learning LaTeX programming. Therefore, the use of additional packages downloaded from CTAN is discouraged. Would also like to avoid using additional *.sty files.

How does one create a command in the main *.tex for a counted item to be later displayed in a listing? For example:

Text before\todo[optional caption]{my text here}. 
Some other text in the document\todo{another todo but without caption}.

The todo note will be coloured, prefixed, or otherwise marked in the inline text. Calling \listoftodos will then create a list of the \todos in the document and generate a (hyperlinked) list similar but separate to \tableofcontents, where the content in {} will be replaced by that in [] if and only if it is present, with the page number on the right. This list will only need a single level of depth.

Was looking through the source code for the todonotes package, but could not make much sense of it. From what I can tell, this task will require defining two new commands, storing the texts in a list of todos, handling optional arguments, and finally making a referenced list of todos using hyperref in a(nother) table of contents. The list will be written to the *.aux file.


  • Safety to be used within an equation or section header, safety to have formatting or an equation within the note

  • How can options be added? A simple show or hide option for the inline text (while still being displayed in the \listoftodos) would be nice.

  • Can this method be extended for other items? \myitem, \listofmyitems, \otheritems, \listofotheritems?

Addendum: is there any advanced guide online for programming (La)TeX? This will be helpful for any future ventures.

  • Welcome to TeX.SX! Would etoolbox and xparse be allowed, as a helper package?
    – user31729
    Feb 22, 2015 at 8:51
  • @ChristianHupfer Unless absolutely necessary (or lack thereof produces bunch of overhead), please avoid. Getting into the heart of LaTeX seems like an interesting challenge.
    – dbwa
    Feb 22, 2015 at 9:07
  • The request for [] as optional list-of-todos entry and for options is tricky. I suggest either a second [] (easy to get with xparse or an option for the toc entry)
    – user31729
    Feb 22, 2015 at 9:37

1 Answer 1


A preliminary version, without option keys

\usepackage{blindtext}% Just as text filler



  % \addcontentsline{todo}{section}{\thetodolistcounter~#1} % No contents line
   %      \colorbox{green}{\thetodolistcounter~#1}

   %      \colorbox{green}{\thetodolistcounter~#2}

  \section{List of Todos}

% inline display (as a enumerate) list 
  \item ##1%


\ToDo{first} \ToDo{We}

\blindtext[5] \ToDo[should not]{should} \blindtext[10]\ToDo{start from scratch}
    E = mc^2%


\section{The ToDos}

\section{A heading with a ToDo \protect\ToDo{Something}}


  • Storing whole math equation environments and handle them in to another command is not easy. I'll try to get a workaround
    – user31729
    Feb 22, 2015 at 11:14
  • Haven't seen any other input, so this will do. Thanks for the starter on lists, counters, and conditions!
    – dbwa
    Mar 2, 2015 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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