方法1.来自:http://bbs.ctex.org/forum.php?mod=viewthread&tid=4560
宏包
\usepackage{color}%可以用于中文代码
\colorbox{yellow}{yellow background} \colorbox[rgb]{1,0,0}{red background} \fcolorbox{blue}{yellow}{red background with a blue frame} \fcolorbox[rgb]{0,0,1}{1,1,0}{red background with a yellow frame} \colorbox{yellow}{ \vbox{ \begin{itemize} \item aaaa \item bbbb \end{itemize} }}
宏包
\usepackage{color,soul}代码
This is some \hl{highlighted\\ text} blah blah.%可以断行,这个包不能用于 CCT 和 CJK. 所以中文... \sethlcolor{green} This is some \hl{highlighted\\ text} blah blah.
方法3.来自http://www.latex-community.org/forum/viewtopic.php?f=5&t=1441
宏包
\usepackage{color,framed}%可以中文代码
\definecolor{shadecolor}{rgb}{0.92,0.92,0.92} \begin{shaded} 我aa \end{shaded}