
我使用以下程式碼來創建標頭fancyhdr
:
\documentclass{report}
\usepackage[margin=3.0cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhf{} % clear the headers
\fancyhead[R]{%
% We want italics
\itshape
% The chapter number only if it's greater than 0
\ifnum\value{chapter}>0 \chaptername\ \thechapter. \fi
% The chapter title
\leftmark}
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyfoot[C]{\thepage}
}
\setlength{\headheight}{14.5pt}
\begin{document}
test
\end{document}
問題如下:
標題行沒有跨越頁面的整個寬度。我懷疑這是因為我已經
\usepackage[margin=3.0cm]{geometry}
載入了調整邊距的內容。如何確保標題行仍然跨越整個頁面,同時保留這些邊距?
答案1
加載geometry
之前fancyhdr
將修復它
\usepackage[margin=3.0cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}