原版来自手写代码必备手册
显示注释:
\usepackage{color}
\newcommand{\Note}[1]{\textcolor{blue}{【注:#1】}} %% 笔记
\newcommand{\Hl}[1]{\textcolor{red}{#1}} %% Highlight
\newcommand{\Dl}{---------------------------------------------------------------------分割线-------------------------------------------------------------------} %% Dividingline
\usepackage{listings}
\lstnewenvironment{NoteCode}{
\lstset{ %
backgroundcolor=\color{white}, % choose the background color
basicstyle=\small, % size of fonts used for the code
columns=fullflexible,
breaklines=true, % automatic line breaking only at whitespace
captionpos=b, % sets the caption-position to bottom
tabsize=4,
commentstyle=\color{magenta}, % comment style
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
keywordstyle=\color{blue}, % keyword style
stringstyle=\color{green}\ttfamily, % string literal style
frame=single, % none
% rulesepcolor=\color{red!20!green!20!blue!20},
% identifierstyle=\color{red},
language=C++
}}{}关闭注释:
\newcommand{\Note}[1]{} %% 笔记 (注释掉)
\newcommand{\Hl}[1]{#1} %% Highlight (注释掉)
\newcommand{\Dl}[1]{} %% Dividingline (注释掉)
\usepackage{comment}
\newenvironment{NoteCode}{}{}
\excludecomment{NoteCode}