[問題] \addtocontents 編譯問題

看板LaTeX (論文排版)作者 (小九)時間14年前 (2011/08/10 20:08), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
各位高手大家好,小弟又來請教了, 這次問題是有關 \addtocontents 這個命令 我想在 toc 的最後加上 附件一 的字樣,但 不要編號及頁碼,因此參考版上 po 文,加了 這一行 \addtocontents{toc}{\contentsline{chapter}{\numberline{}附件一}{}}% 可是在 XeLeTeX 下編譯,會出現以下錯誤 ! Argument of \contentsline has an extra }. <inserted text> \par l.174 ...sline{chapter}{\numberline{}附件一}{}} % 指出 \contentsline 多了個 } ,可是我怎麼看 都找不出是多那一個,曾試著從最右邊拿掉一個 } 但會編譯失敗,請各位高手幫小弟看看,到底原因 是出在那裏呢?附上原始碼,請參考。 謝謝,感激不盡。 =====原始碼 ========== %!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}{\centering\Huge\bfseries}{第\,\xCJKnumber{\thechapter}\,章}{1em}{} %設定章標題 (\chapter) 格式 % \titleformat{\chapter}% %設定章標題 (\chapter) 格式 {\centering\Huge\bfseries}{% \ifthenelse{\boolean{isAppendix}}% {附件\thechapter}% {第\,\xCJKnumber{\thechapter} \,章}% }{1em}{} % \titlespacing{\chapter}{0pt}{0em}{2em} %設定章標題 (\chapter)上下間距 % \titlecontents{chapter}[0em] {}{\normalfont\normalsize\bfseries\makebox[4.1em][l] {第\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} % \def\bibpreamble{\protect\addcontentsline{toc}{chapter}{參考文獻}} %納入參考文獻 % %========================================================== \pagestyle{fancy} % 設定頁首頁尾 \renewcommand{\chaptermark}[1]{\markboth{}{}} % %== 設定標題頁出現頁首頁尾 \fancypagestyle{plain}{% \fancyhf[]{} \fancyhead[LE,RO]{系統擴增開發\\工作計畫書} \fancyhead[LO,RE]{} \fancyfoot[C]{\small\thepage} } % % == 設定本文頁首頁尾 \fancyhf[]{} \fancyhead[LE,RO]{系統擴增開發\\工作計畫書} \fancyhead[LO,RE]{} \fancyfoot[C]{\small\thepage} %\renewcommand{\headrule}{\hrule width\headwidth height\1pt} \renewcommand{\headrulewidth}{0.4pt} \renewcommand{\footrulewidth}{0.4pt} % % % %====================================================== %====== 開始本文 ======================================== \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 ======================== % \addtocontents{toc}{\contentsline{chapter}{\numberline{}附件一}{}}% % \end{document} -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.33.24.122

08/10 20:18, , 1F
\protect\contentsline{...
08/10 20:18, 1F
文章代碼(AID): #1EGdIeTh (LaTeX)
文章代碼(AID): #1EGdIeTh (LaTeX)