![Listas de ações classificadas por pessoa](https://rvso.com/image/305747/Listas%20de%20a%C3%A7%C3%B5es%20classificadas%20por%20pessoa.png)
Estou criando uma aula para atas de reuniões porque tenho algumas demandas bastante específicas - minutes.sty
não parece atender a todas as minhas necessidades.
Houve um bom progresso, mas estou completamente preso no seguinte: quero ser capaz de definir itens de ação à medida que os encontro nas reuniões e classificá-los automaticamente por pessoa.
Seria ótimo se eu pudesse escrever algo assim:
\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}
E faça com que tudo apareça em um description
ambiente como este:
\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}
As tarefas também não precisam ser classificadas por data de vencimento por pessoa, embora eu também adorasse dicas para isso. Agrupá-los por pessoa é mais crítico.
Obviamente preciso de uma estrutura de dados, mas não tenho ideia por onde começar ou como funcionaria. Existe algo como um array, lista, mapa hash ou qualquer coisa que permita a classificação com bastante facilidade?
Também não estou vinculado a nenhum compilador específico. Se houver recursos, digamos luatex
que facilitarão esse caminho, então isso não seria um problema.
Alguém pode me apontar na direção certa? É mesmo possível?
Responder1
Aqui está um ponto de partida:
\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}