4

I move code from Miktex into Texlive. But I get errors:

Run in Xelatex

! Undefined control sequence.
\chaptername ->第\CJKnumber 
                             {\thechapter }章
l.33 \chapter{绪论}

? 

My minimal work is:

% !Mode:: "TeX:UTF-8"
\documentclass[12pt,a4paper,oneside,openany]{book}

\usepackage{fontspec,xunicode,xltxtra}
\usepackage[slantfont,boldfont,CJKnumber]{xeCJK}
\usepackage[bookmarksnumbered]{hyperref}

\usepackage{subfig}
\usepackage{titlesec} 
\usepackage[titles,subfigure]{tocloft} 
\usepackage[numbers,square,super,sort&compress]{natbib} 
\defaultfontfeatures{Mapping=tex-text} 
\setromanfont{Times New Roman}
\setCJKmainfont[BoldFont=SimHei,ItalicFont=KaiTi]{SimSun}
\setCJKmonofont[BoldFont=SimHei]{SimSun}   
\setCJKsansfont{KaiTi}
\settowidth{\parindent}{空格} 
\setCJKfamilyfont{youyuan}{幼圆} 

\renewcommand{\contentsname}{目\hspace{1.5em}录}
\renewcommand{\chaptername}{第\CJKnumber{\thechapter}章}
\titleformat{\chapter}[block]{\bfseries\huge\filcenter}{\chaptertitlename}{1em}{}
\renewcommand{\bibname}{参考文献}
\renewcommand{\cftchappresnum}{第\CJKnumber}
\renewcommand{\cftchapaftersnum}{章}
\renewcommand{\cftchapnumwidth}{4em}
\renewcommand{\figurename}{图}
\renewcommand{\tablename}{表}

\begin{document}

\tableofcontents
\chapter{绪论}

\section{引言}

\end{document}
4

As far as I understand from the package code, the option CJKnumber has been deprecated and indeed you find

*************************************************
* xeCJK warning: "option-deprecated"
* 
* The `CJKnumber' option is deprecated.
* You may load the package `CJKnumb' after xeCJK to use its function.
* 
*************************************************

in the log file. Solution:

\usepackage{fontspec}
\usepackage[slantfont,boldfont]{xeCJK}
\usepackage{CJKnumb}

Avoid loading xunicode and xltxtra. Instructions that say to do so are outdated.

  • Thanks, it works. :-D BTW, how can you know it is outdated?(xunicode and xltxtra) I'm very curious. I can learn a lot from you, I think. – ytyyutianyun Nov 4 '14 at 10:10
  • 1
    @ytyyutianyun Well, loading xunicode has been deprecated for some years (three, IIRC). The xltxtra package used to be a convenient way for not remembering to load both fontspec and xunicode in the right order, but it's not needed any more as fontspec does load xunicode at the proper time. – egreg Nov 4 '14 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.