# fail to add Chinese punctuation after CJKnumber in chatper title in xeLaTeX

I'm writing my thesis in Chinese with xeLaTeX and I've to format the chapter name and section name.

The following command works ok:

 \usepackage[CJKnumber][xeCJK]
\renewcommand{\chaptername}{\CJKnumber{\thechapter}}


except that I still need to add Chinese punctuation after the number. e.g

  一、第一章
（一） 第一节


the compiler would complain ! Missing number, treated as zero. if I did so:

 \usepackage[CJKnumber][xeCJK]
\renewcommand{\chaptername}{\CJKnumber、{\thechapter}}


Any ideas to work around this ?

example:

  \documentclass{report}
\usepackage[CJKnumber]{xeCJK}
\usepackage{titlesec}

\renewcommand{\chaptername}{\CJKnumber{\thechapter}、}
\titleformat{\chapter}{\xiaosihao\hei}{\chaptername}{0.1em}{}
\newcommand{\sectionname}{（\CJKnumber{\thesection}）}
\titleformat{\section}{\xiaosihao\hei}{\sectionname}{0.1em}{}

\begin{document}
\chapter{第一章}
\section{第一节}
\end{document}


I'm able to get chapter name to work now but section number turns out to be （.1 一） instead of （一）

• I guess that \CJKnumber{\thechapter}、 should do. – egreg Apr 23 '13 at 8:02
• @egreg yes it works. would you please elaborate your answer below? How about the section name? – manuzhang Apr 23 '13 at 10:01

The command \CJKnumber has an argument that should expand to a number, so that it can be converted to the Chinese system.

Thus \CJKnumber{1} is legal, as it is \CJKnumber{\thechapter}: the whole lot is "the number".

Since you want the punctuation mark after the number, the construction

\CJKnumber{\thechapter}、


is what you're looking for.

You probably want something like this:

\documentclass{report}
\usepackage[CJKnumber]{xeCJK}
\setCJKmainfont{Kai}

\renewcommand{\chaptername}{章}
\renewcommand{\thechapter}{\CJKnumber{\arabic{chapter}}、}
\renewcommand{\thesection}{%
（\CJKnumber{\arabic{chapter}}、 %
\CJKnumber{\arabic{section}}）}

\begin{document}
\chapter{第一章}
\section{第一节}
\end{document}


• another issue is to replace section number like 1.1 with （一），what I get with （\CJKnumber{\thesection}） is （.1 一） – manuzhang Apr 23 '13 at 12:11
• @manuzhang Please, add a minimal example to your question starting with \documentclass and ending with \end{document} so it's possible to play with it. – egreg Apr 23 '13 at 12:21
• Updated my question – manuzhang Apr 23 '13 at 12:57
• what does \arabic do here? – manuzhang Apr 26 '13 at 14:15
• @manuzhang \arabic{section} produces the decimal representation of the counter's value. You can also use \value{section} if you prefer, so \CJKnumber will use the "abstract" value. – egreg Apr 26 '13 at 14:19

You SHOULD read the document of ctex package and follow it. Don't use the low level macros. titlesec is useful for more complex chapter title formats, but it is overkill here.

And further more, CJKnumber option is now somewhat obsolete for new documents, since zhnumber works better than old CJKNumb package. New version of ctex uses zhnumber internally as well.

\documentclass{ctexrep}
\CTEXsetup[name={,、},number=\chinese{chapter},aftername={}]{chapter}
\CTEXsetup[name={（,）},number=\chinese{section},aftername={}]{section}

\begin{document}
\chapter{第一章}
\section{第一节}
\end{document}