![按人员分类的行动列表](https://linux22.com/image/305747/%E6%8C%89%E4%BA%BA%E5%91%98%E5%88%86%E7%B1%BB%E7%9A%84%E8%A1%8C%E5%8A%A8%E5%88%97%E8%A1%A8.png)
我正在创建一个会议记录课程,因为我有一些非常具体的要求——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}