# Create a table of todos

I'm working out notes from a meeting in LateX. During the meeting I write down so called "todo's" (not to confuse with the todo package). I use my own command TD to simplify my layout, it basicly comes down to this :

\newcommand{\TD}[2]{ToDo \textbf{#1} : #2 }


Where#1 is the persons name, and #2 what he or she has to do. At the end of my file I want to generate a complete list of all the ToDo's that accumulated along the notes, a bit like a list of symbols for instance. How can I make this ? If possible I want to list them by person, and then use subitems to list all their todos.

Thank you very much

• If my solution fits you needs consider to accept it please – user31729 Nov 28 '15 at 19:11

Improved code with 'grouping' of persons and hyperlinks (if needed)

\documentclass{book}

\usepackage{marginnote}
\usepackage{xparse}
\usepackage{totcount}
\usepackage{morewrites}

\newcounter{dummycounter}
\newcounter{personposition}
\newtotcounter{personcounter}

\makeatletter
\def\latex@starttoc#1{%
\begingroup
\makeatletter
\@input{\jobname.#1}%
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\@nobreakfalse
\endgroup
}

\DeclareRobustCommand\persontoctext[1]{%
{%
\noindent\itshape#1%
}%
}

\newcommand{\NoNamePerson}{Unknown}
\newcommand{\listoftodosname}{List of persons who should do something}

\ExplSyntaxOn
\seq_new:N \l__todotoc_personnames_seq

\tl_set:Nx \l_tmpa_tl {#1}
\tl_if_empty:NTF \l_tmpa_tl {%
\tl_set:Nn \l_tmpb_tl {\NoNamePerson}
}{%
\tl_set:Nx \l_tmpb_tl {#1}
}
\tl_set_eq:NN  \l_tmpa_tl  \l_tmpb_tl % Copy the 'real name'
\seq_if_in:NVTF \l__todotoc_personnames_seq {\l_tmpa_tl} {
\setcounter{dummycounter}{0}
\seq_map_inline:Nn \l__todotoc_personnames_seq {%
\stepcounter{dummycounter}%
\str_if_eq_x:nnT {##1} {\l_tmpa_tl} {%
\setcounter{personposition}{\number\value{dummycounter}}
\seq_map_break: % Break out, we've found the number
}
}% End of mapping
}{%
\seq_put_right:NV \l__todotoc_personnames_seq {\l_tmpa_tl}
\stepcounter{personcounter}%
\setcounter{personposition}{\number\value{personcounter}}%
}
\seq_remove_duplicates:N \l__todotoc_personnames_seq
}

\ExplSyntaxOff

\newcommand{\TD}[2]{%
\phantomsection%
\marginnote{ToDo \textbf{#1} : #2}%
}

\newcommand{\listoftodos}{%
\section*{\listoftodosname}
\setcounter{dummycounter}{0}%
% Now get all the person specific toc files
\loop
\ifnum\value{dummycounter} < \numexpr\totvalue{personcounter}+1
\stepcounter{dummycounter}%
\latex@starttoc{\@arabic\c@dummycounter todo}%
\repeat%
}
\makeatother

\usepackage{blindtext} % Just to produce text
\usepackage{hyperref}
\providecommand{\phantomsection} % If hyperref is not used!

\begin{document}
\listoftodos

\clearpage

\blindtext[2]
\TD{Groucho}{Slap Harpo}
\blindtext[5]
\TD{}{Improve this document}
\blindtext[2]
\TD{Harpo}{Slap Chico}
\blindtext[5]
\TD{Chico}{Slap Gummo}
\blindtext[5]
\TD{Gummo}{Slap Zeppo}
\blindtext[5]
\TD{Zeppo}{Slap Groucho properly until he will slap Harpo properly and that one will slap Chico}
\blindtext[5]
\TD{Groucho}{Smoke a cigar}
\blindtext[5]
\TD{}{Improve this code}

\end{document}


• Thanks for the superquick answer ! but I might have been a bit unclear in my question. I write down todos's as my notes go, at the moment they were decided in the meeting, and what I am actually looking for is a code that generates a kind of summary of all the todo's, just like this one, but I want to avoid copying them all maually in the table, there are like 30 of them and I'll have to do this every week. – Libel8 Nov 26 '15 at 20:38
• @Libel8: What manual copying? Call the \TD command and it is added automatically to the table? – user31729 Nov 26 '15 at 20:55
• Oh ok I don't fully understand the code then, my bad ! I'll try it out and play with it to see how it works, Thanks ! – Libel8 Nov 26 '15 at 21:05
• Oh, whoops, I get it now, I missed the end of the code ^^' – Libel8 Nov 26 '15 at 21:08
• @Libel8: Alright ;-) I leave the design of the list to you, especially the formatting of entries, which is done by \persontoctext and \addcontentsline. – user31729 Nov 26 '15 at 21:10