修改评论环境

修改评论环境

我正在使用评论包在我的序言中

\specialcomment{notes}{\begingroup \color{Blue}}{\endgroup}

所以当我想评论我的文字时我会写

\begin{notes}...\end{notes}

得到蓝色输出。因为我需要黑白打印,所以让注释在文本中更清晰会很有用。所以我想让它产生一个换行符、粗体文本“注释:”和注释末尾的另一个换行符。我还希望仍然能够输入

\excludecomment{notes}

删除我的所有评论,但不影响文本的间距(因为没有任何注释)。

由于我对 latex 编程一无所知,我希望有人能帮助我,因为这个网站上的专家过去曾为我提供过很大帮助。不使用我目前拥有的软件包的解决方案也可以。非常感谢 :)

答案1

只需定义notes环境来做你想做的事情:

\documentclass{article}
\usepackage{xcolor,comment}

\newenvironment{notes}
 {\par\textcolor{blue}{\bfseries Note:} \color{blue}\ignorespaces}
 {\par}

%\excludecomment{notes}

\begin{document}

Some text for saying some nonsense.
\begin{notes}
Here we want to add a note.
\end{notes}
Start again with nonsense.

\bigskip

\excludecomment{notes}

Some text for saying some nonsense.
\begin{notes}
Here we want to add a note.
\end{notes}
Start again with nonsense.

\end{document}

取消注释该\excludecomment行将隐藏notes环境,就像示例第二部分中的模拟一样。

在此处输入图片描述

流程中断,但这是comment软件包的限制。完成并移除notes环境后,您可以重新建立正确的流程。

注意:我发出了两次颜色指令,因为如果可以避免的话最好不要发出\color。然而,\par

\newenvironment{notes}
 {\par\leavevmode\color{blue}{\bfseries Note:} \ignorespaces}
 {\par}

是一样的。

相关内容