![禁用 todonotes 中的特定颜色](https://linux22.com/image/441646/%E7%A6%81%E7%94%A8%20todonotes%20%E4%B8%AD%E7%9A%84%E7%89%B9%E5%AE%9A%E9%A2%9C%E8%89%B2.png)
我正在使用 todonotes 包进行一个大型写作项目。我有一个系统,其中有不同颜色的笔记用于不同的目的,例如橙色是我自己写的笔记,而黄色是我的合作者应该查看的更大的想法。
有没有办法禁用一种或多种颜色,以便在编译时隐藏它们?这样我就可以向合作者发送一个版本,其中“我自己的待办事项”已经消失,但大问题仍然存在。类似这样的:
\usepackage[disable=orange]{todonotes}
答案1
定义两个命令,一个用于自己做笔记(\NoteToMe
在此示例中),另一个用于记录好点子。每个命令都有自己的选项。
disable
当您想将文档发送给您的合作者时,请激活定义中的选项\NoteToMe
工作文件:显示所有注释
分享文件:唯有伟大的想法
使用
\newcommand{\NoteToMe}[1]{\todo[linecolor=linecolor,
backgroundcolor=bkgcolor,
bordercolor=bordercolor,
textcolor=textcolor,
disable % activate to disable <<<<<<<<<<<<<<<<<<<
]{#1}}
完整代码
\documentclass[11pt,a4paper]{report}
\usepackage[left=3.00cm, right=5.00cm, top=4.00cm, bottom=3.00cm, marginparwidth=4cm]{geometry}
\usepackage{todonotes}
\usepackage{xcolor}
% colors to myself
\definecolor{textcolor}{RGB}{255,69,0}
\definecolor{bordercolor}{RGB}{0,0,0}
\definecolor{linecolor}{RGB}{150,0,0}
\definecolor{bkgcolor}{RGB}{254,254, 254}
% great colors for others to see
\definecolor{greattextcolor}{RGB}{10,215, 50}
\definecolor{greatbordercolor}{RGB}{100,100,100}
\definecolor{greatlinecolor}{RGB}{150,0,0}
\definecolor{greatbkgcolor}{RGB}{254,254, 254}
\newcommand{\NoteToMe}[1]{\todo[linecolor=linecolor,
backgroundcolor=bkgcolor,
bordercolor=bordercolor,
textcolor=textcolor,
%disable % activate to disable <<<<<<<<<<<<<<<<<<<
]{#1}}
\newcommand{\GreatIdea}[1]{\todo[linecolor=greattextcolor,
backgroundcolor=greatbkgcolor,
bordercolor=greatbordercolor,
textcolor=greattextcolor
]{#1}}
\usepackage{kantlipsum} % only to dummy text
\begin{document}
\kant[1]\NoteToMe{Let us suppose that the noumena have nothing to do
with necessity, since knowledge of the Categories is a
posteriori.}
\kant[2]\GreatIdea{\textbf{GREAT!} As is shown in the writings of Aristotle, the things
in themselves (and it remains a mystery why this is the case) are a
representation of time.}
\end{document}
答案2
您可以添加对颜色参数处理的检查,如下所示:
\documentclass[11pt,a4paper]{report}
\usepackage[left=3.00cm, right=5.00cm, top=4.00cm, bottom=3.00cm, marginparwidth=4cm]{geometry}
\usepackage{todonotes}
\def\discolor{green}
\makeatletter
\define@key{todonotes}{color}{%
\renewcommand{\@todonotes@currentlinecolor}{#1}%
\renewcommand{\@todonotes@currentbackgroundcolor}{#1}%
\ifthenelse{\equal{#1}{\discolor}}{\@todonotes@localdisabletrue}{}%
}
\makeatother
\usepackage{kantlipsum} % only for dummy text
\begin{document}
\kant[1]\todo[color=green]{Let us suppose that the noumena have nothing to do
with necessity, since knowledge of the Categories is a
posteriori.}
\kant[2]\todo{\textbf{GREAT!} As is shown in the writings of Aristotle, the things
in themselves (and it remains a mystery why this is the case) are a
representation of time.}
\end{document}
现在,通过定义\discolor
命令,您可以选择禁用哪种颜色。