禁用 todonotes 中的特定颜色

禁用 todonotes 中的特定颜色

我正在使用 todonotes 包进行一个大型写作项目。我有一个系统,其中有不同颜色的笔记用于不同的目的,例如橙色是我自己写的笔记,而黄色是我的合作者应该查看的更大的想法。

有没有办法禁用一种或多种颜色,以便在编译时隐藏它们?这样我就可以向合作者发送一个版本,其中“我自己的待办事项”已经消失,但大问题仍然存在。类似这样的:

\usepackage[disable=orange]{todonotes}

答案1

定义两个命令,一个用于自己做笔记(\NoteToMe在此示例中),另一个用于记录好点子。每个命令都有自己的选项。

disable当您想将文档发送给您的合作者时,请激活定义中的选项\NoteToMe

工作文件:显示所有注释

A

分享文件:唯有伟大的想法

b

使用

\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命令,您可以选择禁用哪种颜色。

相关内容