
目次 (および要約、謝辞など) にはローマ数字を使用し、本文は 1 ページ目からアラビア数字で始めようと考えています。記事ドキュメント クラスを使用しており、タイトル ページにページ番号は不要です。同時に、フッターにページ x/y を表示したいと考えています。
つまり私は
表紙: 番号なし
目次の最初のページ: ページ i / ii
目次の 2 番目のページ: ページ ii / ii [この例では ii が選択されています]
文書の最初のページ: ページ 1 / x
文書の 2 番目のページ: ページ 2 / x
このコードは目次に対しては正常に機能し、ページ i / ii、ページ ii / ii などが表示されます。ただし、ドキュメントの残りの部分では、ページ 1 / ii、ページ 2 / ii が表示されます。実際に、間違いの原因 ( の使用\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
ファイルに何も書き込まれません。たとえば、パッケージは、で使用できる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}