Списки действий, отсортированные по человеку

Списки действий, отсортированные по человеку

Я создаю класс для протоколов собраний, поскольку у меня есть некоторые весьма специфические требования — minutes.styпохоже, он не отвечает всем моим требованиям.

Есть определенный прогресс, но я полностью застрял на следующем: я хочу иметь возможность определять пункты действий по мере их возникновения на встречах и автоматически сортировать их по каждому человеку.

Было бы здорово, если бы я мог написать что-то вроде этого:

\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}

И все это должно проявиться в descriptionтакой обстановке:

\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}

Задачи не обязательно сортировать по дате выполнения для каждого человека, хотя я бы тоже хотел иметь указатели для этого. Группировка по человеку более критична.

Мне, очевидно, нужна структура данных, но я понятия не имею, с чего начать или как это будет работать. Есть ли что-то вроде массива, списка, хэш-карты или чего-то еще, что позволяет сортировать довольно легко?

Я также не привязан к какому-то конкретному компилятору. Если в нем есть функции, luatexкоторые, скажем, облегчат этот путь, то это не будет проблемой.

Может ли кто-нибудь указать мне правильное направление? Возможно ли это вообще?

решение1

Вот отправная точка:

введите описание изображения здесь

\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

  }{% Person already exists
    \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}

Связанный контент