標題行不跨越頁面寬度

標題行不跨越頁面寬度

我使用以下程式碼來創建標頭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}

相關內容