我使用上述示例对我的待办事项进行分类(例如图表、行政事务、实验室待办事项……),而不是不同的审阅者,效果很好(使用所有者作为标签)。但现在我在使用 missingfigure 命令时遇到了麻烦。我想只显示一个类别中的缺失图表。相反,它显示在所有 listoftodos 上。是否可以为 missingfigure 添加所有者属性或从 listoftodos 中禁用 missingfigures?
或者您有不同的想法来实现这一点?
\documentclass{scrbook}
\usepackage{hyperref}
\usepackage[
textsize=footnotesize,
colorinlistoftodos,
color=orange!10,
bordercolor=orange!90
]{todonotes}
\usepackage{etoolbox}
\usepackage{lipsum}
\presetkeys{todonotes}{inline, color=blue!15, bordercolor=blue!85, size=\scriptsize,
figwidth=0.9\linewidth, figcolor=black!10}{}
\makeatletter
\newcommand\@todonotes@owner{default}
\define@key{todonotes}%
{owner}{\def\@todonotes@owner{#1}}
\newtoggle{ownerdefault}
\newtoggle{owneradmin}
\newtoggle{ownerfig}
\newcommand\adminTodo[1]{%
\todo[%
owner=admin,
author={[Admin]},noline,caption={[Admin]: #1},color=blue!20%
]%
{#1}}
\newcommand\figTodo[1]{%
\todo[%
owner=fig,
author={[Fig]},noline,caption={[Fig]: #1},color=red!50!white%
]%
{#1}}
\renewcommand{\@todonotes@addElementToListOfTodos}{%
\if@todonotes@colorinlistoftodos%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\protect\fcolorbox{\@todonotes@currentbordercolor}%
{\@todonotes@currentbackgroundcolor}%
{\protect\textcolor{\@todonotes@currentbackgroundcolor}{o}}%
\ \@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\else%
\addtocontents{tdo}
{%
\protect\iftoggle{owner\@todonotes@owner}
{%
\protect\contentsline {todo}
{\@todonotes@caption
}{\thepage}{\@currentHref}%
}{}%
}%
\fi}%
\makeatother
\begin{document}
\todo{some uncategorized todo}
\lipsum[1]
\figTodo{This is a todo in category figure}
\lipsum[1]
\adminTodo{This is a todo in category administrative stuff}
\lipsum[1]
\missingfigure{missing figure}
\toggletrue{owneradmin}
\section*{Administrative ToDos}
\InputIfFileExists{\jobname.tdo}{}
\toggletrue{ownerfig}
\togglefalse{owneradmin}
\section*{Figure ToDos}
\InputIfFileExists{\jobname.tdo}{}
\togglefalse{ownerfig}
\toggletrue{ownerdefault}
\section*{ToDos}
\InputIfFileExists{\jobname.tdo}{}
\togglefalse{ownerdefault}
\makeatletter \@starttoc{tdo}\makeatother % to trigger the creation of the list
\end{document}
答案1
对于遇到同样问题的人,我现在通过重新定义 missingfigure 来解决这个问题,因为我没有找到干净的解决方案。
\renewcommand\missingfigure[2][width=1\textwidth, height=5cm]{
\begin{figure}
\includegraphics[#1]{example-image}
\figTodo{#2}
\end{figure}
}