解决latex中遇到一个常见错误:"Improper alphabetic constant."

时间:2017-02-10 15:38:41   收藏:0   阅读:8131

1.问题:

      本人是在WIN7下用texlive 2016,编辑器用的是WinEdt 10.1 ,运行如下代码:

 1 \documentclass{ctexbook}
 2 \begin{document}
 3 \title{中文 \LaTeX{} 测试}
 4 \author{姓名}
 5 \maketitle
 6 \tableofcontents
 7 \chapter{测试}
 8 中文测试.
 9 \chapter{再测试}
10 中文测试.
11 \end{document}

返回如下错误:

! Improper alphabetic constant.
<to be read again> 
                   \hspace 
l.1 ...berline {第一章\hspace {.3em}}测试}{5}

2.解决:

      在google上找答案,发现原来是在\documentclass{ctexbook}中少写了一个[UTF8] ,加上它就没有这个错误了,即改为如下代码后,就没有该错误了:

 1 \documentclass[UTF8]{ctexbook}
 2 \begin{document}
 3 \title{中文 \LaTeX{} 测试}
 4 \author{姓名}
 5 \maketitle
 6 \tableofcontents
 7 \chapter{测试}
 8 中文测试.
 9 \chapter{再测试}
10 中文测试.
11 \end{document}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!