# Action lists sorted by person

I am creating a class for meeting minutes as I have some quite specific demands —minutes.sty doesn't seem to meet all of my requirements.

There's some good progress, but I'm completely stuck on the following: I want to be able to define action items as I encounter them in the meetings and have them automatically sorted per person.

It'd be great if I could write something like this:

\action{Peter}{next week}{Take out the garbage}

\action{Mike}{tomorrow}{Prepare a presentation for the thing}

\action{Peter}{2015-02-28}{Clean the kitchen}

\action{Peter}{tomorrow}{Water the plants}

\action{Mike}{yesterday}{Cleanse the bathroom}


And have it all show up in a description environment like this:

\begin{description}
\item[Peter] \hfill \\
Water the plants     \hfill \textbf{tomorrow} \\
Take out the garbage \hfill \textbf{next week} \\
Clean the kitchen    \hfill \textbf{2015-02-28} \\
\item[Mike] \hfill \\
Prepare a presentation for the thing \hfill \textbf{tomorrow} \\
Cleanse the bathroom                 \hfill \textbf{yesterday} \\
\end{description}


The tasks needn't be also sorted by due date per person, although I'd love pointers for that as well. Grouping them by person is more critical.

I obviously need a datastructure, but I have no idea where to start or how these would work. Is there something like an array, list, hash map or anything that allows sorting quite easily?

I am also not tied to any particular compiler. If there are features in, say luatex that will make this way easier, then that wouldn't be a problem.

Can anyone point me in the right direction? Is it even possible?

• – Werner Feb 17 '15 at 0:28

Here is a starting point:

\documentclass{article}

\usepackage{multido}
\newcounter{personcntr}% Keep track of number of persons
\makeatletter
\newcommand{\action}[3]{% \action{<name>}{<time>}{<duty>}
\@ifundefined{person@#1}{% If person doesn't exist
\stepcounter{personcntr}% Next person
\expandafter\xdef\csname person@#1\endcsname{1}% One time/duty
\expandafter\xdef\csname person@bynumber@\thepersoncntr\endcsname{#1}% Number person

\expandafter\xdef\csname person@#1\endcsname{%
\number\numexpr\csname person@#1\endcsname+1}% Step number of time/duty
}%
\expandafter\xdef\csname person@#1@\csname person@#1\endcsname @time\endcsname{#2}% Store time
\expandafter\xdef\csname person@#1@\csname person@#1\endcsname @duty\endcsname{#3}% Store duty
\ignorespaces
}
\gdef\newpar{\par}% \multido doesn't enjoy \par

\newcommand\printactions{% Print actions
\def\descriptionBODY{}% Empty descriptionBODY
{\let\item\relax% Prevent expansion of \item
\let\newpar\relax% Prevent expansion of \newpar
\multido{\iPerson=1+1}{\value{personcntr}}{% Step through all persons
% Extract person name
\expandafter\xdef\expandafter\thisperson\expandafter{\csname person@bynumber@\iPerson\endcsname}%
\protected@xdef\descriptionBODY{%
\descriptionBODY%
\item[\thisperson] \leavevmode\newpar}% Add person name to descriptionBODY
% Extract person number
\expandafter\xdef\expandafter\thispersonnum\expandafter{\csname person@\thisperson\endcsname}%
\multido{\iDuty=1+1}{\thispersonnum}{%
\protected@xdef\descriptionBODY{%
\descriptionBODY%
\csname person@\thisperson @\iDuty @duty\endcsname% Add person duty to descriptionBODY
\hfill
{\bfseries\csname person@\thisperson @\iDuty @time\endcsname}% Add person time to descriptionBODY
\newpar
}%
}%
}%
}%
% Print person time/duty
\begin{description}
\descriptionBODY
\end{description}
}
\makeatother

\begin{document}

\action{Peter}{next week}{Take out the garbage}

\action{Mike}{tomorrow}{Prepare a presentation for the thing}

\action{Peter}{2015-02-28}{Clean the kitchen}

\action{Peter}{tomorrow}{Water the plants}

\action{Mike}{yesterday}{Cleanse the bathroom}

\printactions

\end{document}

• Thank you very much! If anyone reading this is interested in the package, it can be found on GitHub. – Duijf Feb 17 '15 at 11:13