![사람별로 정렬된 작업 목록](https://rvso.com/image/305747/%EC%82%AC%EB%9E%8C%EB%B3%84%EB%A1%9C%20%EC%A0%95%EB%A0%AC%EB%90%9C%20%EC%9E%91%EC%97%85%20%EB%AA%A9%EB%A1%9D.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}