Re: [問題] 頁首頁尾及章節標題版面問題求教
非常謝謝 andrew43 的解答,依照你的方法,
我解決了之前提到的問題,不過我又遇到新的
問題,稍微説明如下.
1. 我用 \usepackage{fancyhdr}
然後自訂了 plain 的 pagestyle, 使 plain 下的
頁首及頁尾跟 \pagestyle{fancy} 一樣,這樣子
在標題頁 (例如第一章那頁) 也會出現頁首頁尾。
第一個問題解決!
2. 我用 \usepackage{titlesec}
我加了一行指令
\titlespacing{\chapter}{0pt}{0em}{2em} %設定章標題 (\chapter)上下間距
就能將章標題 (\chapter{}) 移到頁面上邊界,不會
像之前標題上面會有一大塊空白。
注意:\titlespacing 要跟 \titleformat 配合使用
第二個問題解決!
新問題: 我加入 \appendix 然後試用一個 \chapter{app 1}
卻出現編譯錯誤的訊息如下
Appendix A.
! Missing number, treated as zero.
<to be read again>
A
l.146 \chapter{app 1}
我看了很久,想不出來那裏有問題,可以請各位
高手指點一下嗎?感激不盡!
再次感謝 andrew43 的幫助,謝謝!!
======分隔線 ====================================
我把我用的 XeLaTeX code 貼在下面供大家參考
=================================================
%!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}
%
%======================================================================
%% use xeCJK
\usepackage[BoldFont,SlantFont,CJKnumber,CJKchecksingle]{xeCJK}
\usepackage{xCJKnumb}
\setCJKmainfont{標楷體}
\setromanfont{Times New Roman}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
\titleformat{\chapter}{\centering\Huge\bfseries}{第\,\xCJKnumber{\thechapter}\,章}{1em}{} %設定章標題 (\chapter) 格式
\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{\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
\raggedbottom\sloppy
%
\chapter{app 1}
%
\end{document}
========分隔線================
※ 引述《andrew43 (Myrmarachne)》之銘言:
: ※ 引述《Ninerh (小九)》之銘言:
: : 各位 LaTeX 的高手,小弟使用 XeLaTeX 來編
: : 排中文報告,遇到幾個問題,上網 Google 沒找
: : 到解決的方法,因此想向各位高手求教。
: : 我的問題很簡單,是有關頁首頁尾,以及章節頁的章標
: : 題距上邊界距離的問題。
: : 1. 為什麼各章開始的第1頁(例如出現'第一章'字樣的那一
: : 頁),設定的頁首不會出現,只會出現頁碼? 可以強迫
: : 章節開始的第1頁出現設好的頁首跟頁尾嗎?
: Chapter page 會有不同的 header/footer 設定是因為 latex
: 在 \chapter{} 的同時會使用 \thispagestyle{plain}, 也就
: 是在 chapter page 會採用 plain 這個 pagestyle. 所以只要
: 把 plain 這個 pagestyle 修正成其你所希望的一致即可.
: 試試這個:
: \documentclass{report}
: \usepackage{fancyhdr}
: \pagestyle{fancy}
: \fancypagestyle{plain}{%
: \fancyhf[]{}
: \fancyhead[LE,RO]{\slshape \rightmark}
: \fancyhead[LO,RE]{\slshape \leftmark}
: \fancyfoot[C]{\thepage}
: }
: \fancyhead[LE,RO]{\slshape \rightmark}
: \fancyhead[LO,RE]{\slshape \leftmark}
: \fancyfoot[C]{\thepage}
: 在上段原始碼中, 我採用了 fancy 這個 pagestyle, 且另外設
: 定了 plain pagestyle, 使二者一致. 要再變化請見 fancyhdr
: 使用手冊.
: : 2. 為什麼各章的章標題\chapter{} (例如'第一章 背景説明')
: : 其位置會位在大約從頁上邊界算下來約 1/3 整頁高
: : 的地方,可以調整其與上邊界的距離嗎?我想要讓章標
: : 題儘量靠上邊界,而不是上面空白一大塊。
: : 第2個問題同樣出現在'目錄' '圖目錄' '表目錄' 等
: : 標題,我想要調整標題與上邊界的距離。
: 這只要靠 titlesec package 中的 \titleformat{} 或 \titlespacing{}.
: 換句話說, 就是重新定義 title 的樣式和距離. 使用方法請自己
: 查閱吧.
: : 我有使用
: : \usepackage{fancyhdr}
: : 試了很多次,也找了些時日,一直不得其解,希望
: : 各位高手能夠解惑,謝謝。
: : 感激不盡!
: : -----分隔線-------------------
: : 我用的tex設定(report.tex)
: : http://ppt.cc/zjpF
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.33.24.29
→
08/03 14:09, , 1F
08/03 14:09, 1F
討論串 (同標題文章)
LaTeX 近期熱門文章
PTT數位生活區 即時熱門文章