作者Ninerh (小九)
看板LaTeX
标题Re: [问题] 页首页尾及章节标题版面问题求教
时间Wed Aug 3 21:32:39 2011
谢谢 uranusjr 的帮助,missing number 的问题
解决了,不过这只解决了在正文中让附件出现的要
求,但是在制作 table of contents 时就出现同样
的错误,我看了一下, 应该是
\titlecontents 的问题,因为里面我也用了
\xCJKnumber 来转换数字为国字。
因上我如法炮制更改 \titleformat 的做法,在
\titlecontents 加入了判别式, 如下
===== 更改前的 \titlecontents ========
\titlecontents{chapter}[0em]
{}{\normalfont\normalsize\bfseries\makebox[4.1em][l]
{第\xCJKnumber{\thecontentslabel}章}}{}
{\titlerule*[0.7pc]{.}\contentspage}
===== 更改後的 \titlecontents ========
\titlecontents{chapter}[0em]
{}{\normalfont\normalsize\bfseries\makebox[4.1em][l]%
{\ifthenelse{\boolean{isAppendix}}%
{附件\xCJKnumber{\thechapter}}%
{第\xCJKnumber{\thecontentslabel}章}}%
}{}%
{\titlerule*[0.7pc]{.}\contentspage}
不过问题一样会出现,在用 XeLaTeX 编辑二次後,会出现
错误讯息如下
! Missing number, treated as zero.
<to be read again>
A
l.4 ...{\numberline {A}测试 TEST}{3}{appendix.A}
我猜想是 isAppendix 在 XeLaTeX 编目录时,仍是 false
的状态,才会有上述错误。不过如果把 isAppendix=True
放在 \tableofcontents 之前,则目录上所有章节都变成
'附件零', 也就是从原本'第一章' 变成 '附件零', '第二
章' '第三章' 都一样变成 '附件零', 不过本文中的附件
标题不会有问题,出错都是在 目录 上面的名称。
这个问题有解法吗?感激不尽!!
======原始码============================
%!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}
%
\titlecontents{chapter}[0em]
{}{\normalfont\normalsize\bfseries\makebox[4.1em][l]%
{\ifthenelse{\boolean{isAppendix}}%
{附件\xCJKnumber{\thechapter}}%
{第\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 ========================
%
\clearpage\newpage
\appendix
\setboolean{isAppendix}{true}
\raggedbottom\sloppy
%
%\setcounter{chapter}{1}
\chapter{测试 TEST}
\section{test 测试}
%
\end{document}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.33.24.29