我正在用 LateX 做会议笔记。在会议期间,我写下了所谓的“待办事项”(不要与软件包混淆todo
)。我使用自己的命令 TD 来简化我的布局,基本上可以归结为:
\newcommand{\TD}[2]{ToDo \textbf{#1} : #2 }
#1
人员姓名在哪里,以及#2
他或她要做什么。在文件末尾,我想生成一个完整的列表,列出在笔记中积累的所有待办事项,有点像符号列表。我该怎么做?如果可能的话,我想按人列出它们,然后使用子项列出他们的所有待办事项。
非常感谢
答案1
改进了人员和超链接的“分组”代码(如果需要)
\documentclass{book}
\usepackage{marginnote}
\usepackage{xparse}
\usepackage{totcount}
\usepackage{morewrites}
\newcounter{dummycounter}
\newcounter{personposition}
\newtotcounter{personcounter}
\makeatletter
\def\latex@starttoc#1{%
\begingroup
\makeatletter
\@input{\jobname.#1}%
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\@nobreakfalse
\endgroup
}
\DeclareRobustCommand\persontoctext[1]{%
{%
\addvspace{10pt}\nopagebreak\leftskip0em\relax
\noindent\itshape#1%
}%
}
\newcommand{\NoNamePerson}{Unknown}
\newcommand{\listoftodosname}{List of persons who should do something}
\ExplSyntaxOn
\seq_new:N \l__todotoc_personnames_seq
\NewDocumentCommand{\AddPersonName}{mm}{%
\tl_set:Nx \l_tmpa_tl {#1}
\tl_if_empty:NTF \l_tmpa_tl {%
\tl_set:Nn \l_tmpb_tl {\NoNamePerson}
}{%
\tl_set:Nx \l_tmpb_tl {#1}
}
\tl_set_eq:NN \l_tmpa_tl \l_tmpb_tl % Copy the 'real name'
\seq_if_in:NVTF \l__todotoc_personnames_seq {\l_tmpa_tl} {
\setcounter{dummycounter}{0}
\seq_map_inline:Nn \l__todotoc_personnames_seq {%
\stepcounter{dummycounter}%
\str_if_eq_x:nnT {##1} {\l_tmpa_tl} {%
\setcounter{personposition}{\number\value{dummycounter}}
\seq_map_break: % Break out, we've found the number
}
}% End of mapping
}{%
\seq_put_right:NV \l__todotoc_personnames_seq {\l_tmpa_tl}
\stepcounter{personcounter}%
\setcounter{personposition}{\number\value{personcounter}}%
\addtocontents{\arabic{personposition}todo}{\persontoctext{\l_tmpa_tl}}%
}
\seq_remove_duplicates:N \l__todotoc_personnames_seq
\addcontentsline{\arabic{personposition}todo}{section}{#2}%
}
\ExplSyntaxOff
\newcommand{\TD}[2]{%
\phantomsection%
\marginnote{ToDo \textbf{#1} : #2}%
\AddPersonName{#1}{#2}% Adding the name to the list
}
\newcommand{\listoftodos}{%
\section*{\listoftodosname}
\setcounter{dummycounter}{0}%
% Now get all the person specific toc files
\loop
\ifnum\value{dummycounter} < \numexpr\totvalue{personcounter}+1
\stepcounter{dummycounter}%
\latex@starttoc{\@arabic\c@dummycounter todo}%
\repeat%
}
\makeatother
\usepackage{blindtext} % Just to produce text
\usepackage{hyperref}
\providecommand{\phantomsection} % If hyperref is not used!
\begin{document}
\listoftodos
\clearpage
\blindtext[2]
\TD{Groucho}{Slap Harpo}
\blindtext[5]
\TD{}{Improve this document}
\blindtext[2]
\TD{Harpo}{Slap Chico}
\blindtext[5]
\TD{Chico}{Slap Gummo}
\blindtext[5]
\TD{Gummo}{Slap Zeppo}
\blindtext[5]
\TD{Zeppo}{Slap Groucho properly until he will slap Harpo properly and that one will slap Chico}
\blindtext[5]
\TD{Groucho}{Smoke a cigar}
\blindtext[5]
\TD{}{Improve this code}
\end{document}