I sense this error coming from the code! Missing number, treated as zero.
<to be read again>
{
l.119 ...ine{chapter}{\numberline{}附件一}{}{}}
%
Code: Select all
\addtocontents{toc}{\contentsline{chapter}{\numberline{}附件一}{}{}}%
Does anyone have the solution? Any comment is appreciated. Thank you.
Original code below.
Code: Select all
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
%
\documentclass[12pt,a4paper,twoside]{report}
\setcounter{secnumdepth}{3} %設定章節層級至 1.1.1.1
\setcounter{tocdepth}{3}
%
\usepackage{amsmath, amsthm, amssymb, txfonts, upgreek, amsbsy, mathrsfs}
\usepackage{fontspec}
\usepackage[a4paper,top=3.0cm,bottom=2.54cm,left=2cm,right=2cm,bindingoffset=1cm]{geometry} % 邊界設定,bindingoffset表示裝訂邊
\usepackage[unicode]{hyperref} % 為 pdf 設定頁籤,開啟 pdf 檔案檢視時左側會有 bookmark 可用
\usepackage{type1cm} % 使 Type1 字型可以無段放大縮小
\usepackage{graphicx} % 可直接插入圖片
\usepackage{float}
\usepackage{caption}
\usepackage{indentfirst} % 首段縮排
\usepackage{url} % 文稿中出現的 \url{網址} 能夠隨文斷行
\usepackage{natbib} % 增加更多文獻引用細節功能
\bibpunct{(}{)}{;}{a}{,}{,}
\usepackage{fancyhdr} % 設定頁首頁尾用的套件
\usepackage{titlesec, titletoc}
\usepackage{appendix}
\usepackage{ifthen}
%
%======================================================================
%% use xeCJK
\usepackage[BoldFont,SlantFont,CJKnumber,CJKchecksingle]{xeCJK}
\usepackage{xCJKnumb}
\setCJKmainfont{BiauKai}%{標楷體}
\setromanfont{Times New Roman}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
%
%
\newboolean{isAppendix}
\setboolean{isAppendix}{false}
%
%
%
\titleformat{\chapter}% %設定章標題 (\chapter) 格式
{\centering\Huge\bfseries}{%
\ifthenelse{\boolean{isAppendix}}%
{附件}%
{第\,\xCJKnumber{\thechapter} \,章}%
}{1em}{}
%
\titlespacing{\chapter}{0pt}{0em}{2em} %設定章標題 (\chapter)上下間距
%
\titlecontents{chapter}[0em]
{}{\normalfont\normalsize\bfseries\makebox[4.1em][l]%
{\ifthenelse{\boolean{isAppendix}}%
{附件}%
{第\xCJKnumber{\thecontentslabel}章}}%
}{}%
{\titlerule*[0.7pc]{.}\contentspage}
%
%========================================================================
%
\renewcommand{\contentsname}{目\,\,\,錄}
\renewcommand{\figurename}{圖}
\renewcommand{\tablename}{表}
\renewcommand{\listfigurename}{圖目錄}
\renewcommand{\listtablename}{表目錄}
\renewcommand{\bibname}{參考文獻}
%
% Redefine the second level of Enumerate
\renewcommand{\theenumii}{(\arabic{enumii})} % (1) (2) (3) ...
\renewcommand{\labelenumii}{\theenumii}
% third level
\renewcommand{\theenumiii}{\Alph{enumiii}、} % A, B, C...
\renewcommand{\labelenumiii}{\theenumiii}
%
%
%======================================================
%====== 開始本文 ========================================
\begin{document}
%
\pagenumbering{roman}
\tableofcontents
\listoffigures
\listoftables
\clearpage
%
% 正文開始的環境設定
% ================================================================================
\pagenumbering{arabic} % 頁碼改以阿拉伯數字表示
\captionsetup{labelsep=quad} %修改圖表號,拿掉冒號, eg. 圖1.1
\fontsize{12pt}{18pt}\selectfont % 行高 1.5
%
%
%===========================================================================
% for testing
\chapter{第一名}
測試測試 test test
test test 測試測試 test test測試測試 test test測試測試 test test測試測試 test test
\section{Test 測試}
test test 測試測試 test test測試測試 test test測試測試 test test測試測試 test test
\clearpage
\section{測試 Test}
test test 測試測試 test test測試測試 test test測試測試 test test測試測試 test test
123456
ABCDFG $\alpha \beta$ 測試!測試!測試!
%
%%
%======= Appendix ========================
%
\setboolean{isAppendix}{true}
%\addcontentsline{toc}{chapter}{附件一}
\addtocontents{toc}{\contentsline{chapter}{\numberline{}附件一}{}{}}%
%
\end{document}