
我使用 \pagestyle{fancy}。我想將當前的佈局保留在頁眉和頁腳中(某些頁面在頁眉和/或頁腳中沒有任何內容,其他頁面帶有阿拉伯數字,其他頁面再次帶有羅馬數字)。
我希望標題的左側自動具有該部分或小節的名稱(不是子小節)。
我怎樣才能做到這一點?
我的tex檔案:
\documentclass[12pt]{article}
\usepackage[utf8x]{inputenc}
%Header and footer
\usepackage{fancyhdr}
\usepackage{lastpage}
\pagestyle{fancy}
\fancypagestyle{prefacestyle}{
\fancyhf{} % clear all header and footer fields
\renewcommand{\headrulewidth}{0pt}
\lhead{}
\chead{}
\rhead{}
\cfoot{\thepage}
}
\fancypagestyle{documentstyle}{
\fancyhf{} % clear all header and footer fields
\renewcommand{\headrulewidth}{0.2pt}
\lhead{Section or Subsection}
\chead{}
\rhead{Name}
\cfoot{\thepage\ of \pageref{LastPage}}
}
\begin{document}
\thispagestyle{empty}
Frontpage
\newpage
\thispagestyle{empty}
Titlepage
\newpage\pagestyle{prefacestyle}
\pagenumbering{roman}
Preface
\newpage
Abstract
\newpage
Acknowlegdement
\newpage
Contents
\newpage\pagestyle{documentstyle}
\pagenumbering{arabic}
\setcounter{page}{1}
\section{Introduction}
\newpage
\subsection{Related work}
\newpage
\section{Theory}
\newpage
\subsection{method 1}
\newpage
\subsubsection{part 1.1}
\newpage
\subsubsection{part 1.2}
\newpage
\subsection{method 2}
\newpage
\subsubsection{part 2.1}
\end{document}
答案1
如果您想要其他內容,請編輯它。只需在這裡編輯:
\fancypagestyle{documentstyle}{ \fancyhf{} % 清除所有頁首和頁尾欄位 \renewcommand{\headrulewidth}{0.2pt} \lhead{\leftmark} \chead{\右標} \rhead{名稱} \cfoot{\pageref{LastPage}} 的\thepage\ }