羅馬數字表示目錄,阿拉伯數字表示頁腳正文

羅馬數字表示目錄,阿拉伯數字表示頁腳正文

我嘗試使用羅馬數字作為目錄(以及摘要、致謝詞等),然後從第 1 頁開始使用阿拉伯數字正文。我正在使用文章文檔類,並且不希望標題頁上有頁碼。同時在頁腳我想顯示第 x 頁(共 y 頁)。

即我想要

扉頁:無編號
目錄第一頁:第 i 頁,共 ii
頁 目錄第二頁:第 ii 頁,共 ii [為本範例選擇 ii]
文件首頁:第 1 頁,共 x 頁
文件第二頁:第2 頁的 x

程式碼對於目錄工作正常,我確實得到了ii 的第i 頁、ii 的第ii 頁等。看到原因錯誤(使用 a \label{lastromanpage}),但我不知道如何解決這個問題。

\documentclass{article}

\newcommand{\Title}{Title}
\newcommand{\DueDate}{\today}
\newcommand{\Class}{}
\newcommand{\ClassTime}{}
\newcommand{\ClassInstructor}{}
\newcommand{\AuthorName}{Authorname}

\title{\vspace{2in}\textmd{\textbf{ \Title}}\\\normalsize\vspace{0.1in}\small{Due\ on\ \DueDate}\\\vspace{0.1in}\large{\textit{\ClassInstructor\ \ClassTime}}\vspace{3in}}
\date{}
\author{\textbf{\AuthorName}}

\pagestyle{fancy}
\lhead{\AuthorName}
\chead{\Class}
\rhead{\Title}

\lfoot{\lastxmark}
\cfoot{}
\rfoot{Page\ \thepage\ of\ \pageref{lastromanpage}}

\begin{document}\begin{spacing}{1.1}

\maketitle\thispagestyle{empty}\newpage
\pagenumbering{roman}\tableofcontents \label{lastromanpage}
\newpage\pagenumbering{arabic}\clearpage

答案1

您也可以使用 變更文件內的頁尾\rfoot。最後頁碼的標籤更複雜,因為\label 最後一頁不會在.aux文件中寫入任何內容。例如,package提供了一個可以與 一起使用的lastpage標籤。LastPage\pageref

完整範例:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{lastpage}

\newcommand*{\Title}{Title}
\newcommand*{\AuthorName}{John Doe}
\title{\Title}
\date{}
\author{\AuthorName}

\pagestyle{fancy}
\lhead{\AuthorName}
\chead{Class}
\rhead{\Title}

\lfoot{}
\cfoot{}
\rfoot{Page\ \thepage\ of\ \pageref{lastromanpage}}

\begin{document}

\maketitle\thispagestyle{empty}
\newpage

\pagenumbering{roman}
\tableofcontents
\label{lastromanpage}
\clearpage

\pagenumbering{arabic}
\rfoot{Page\ \thepage\ of \pageref{LastPage}}
\section{First section}
\newpage
\section{Last section}

\end{document}

相關內容