原因有两种:
1、由不能生成章节编号引起的。
这是由hyperref包引起的错误。那么在Begin{document}后加上:\hypersetup{CJKbookmarks=true}
\documentclass{ctexart}
\usepackage[colorlinks,
linkcolor=red,
anchorcolor=blue,
citecolor=green]{hyperref}
\begin{document}
\hypersetup{CJKbookmarks=true}
\tableofcontents
参考网址:http://www.cnblogs.com/EverYoung/archive/2011/09/28/2194892.html
2、若在lstlistings中报错
则需仔细检查是否某些字符是在中文输入法下输入的,而不是在英文输入法输入的,譬如空格、减号,那样的话,就会报错。