![人別にソートされたアクションリスト](https://rvso.com/image/305747/%E4%BA%BA%E5%88%A5%E3%81%AB%E3%82%BD%E3%83%BC%E3%83%88%E3%81%95%E3%82%8C%E3%81%9F%E3%82%A2%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%AA%E3%82%B9%E3%83%88.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}