我面臨著調整論文前面的頁碼編號的挑戰。我下載了給出的模板論文這裡,它使用 book 類別作為新定義的類別的基礎Thesis.cls
。為了編譯下面的 MWE,您還需要我提供的連結中的vector.sty
和lstpatch.sty
文件(除非我認為有必要將它們複製並貼上到我的問題的主體中)。不保留細節,我的課堂文檔看起來像這樣:
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{Thesis}
[2007/22/02 v1.0
LaTeX document class]
\def\baseclass{book}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\baseclass}}
\def\@checkoptions#1#2{
\edef\@curroptions{\@ptionlist{\@currname.\@currext}}
\@tempswafalse
\@tfor\@this:=#2\do{
\@expandtwoargs\in@{,\@this,}{,\@curroptions,}
\ifin@ \@tempswatrue \@break@tfor \fi}
\let\@this\@empty
\if@tempswa \else \PassOptionsToClass{#1}{\baseclass}\fi
}
\@checkoptions{11pt}{{10pt}{11pt}{12pt}}
\PassOptionsToClass{a4paper}{\baseclass}
\ProcessOptions\relax
\LoadClass{\baseclass}
\newcommand\bhrule{\typeout{------------------------------------------------------------------------------}}
\newcommand\Declaration[1]{
\btypeout{Approval of the Dissertation Committee}
\addtotoc{Approval of the Dissertation Committee}
\thispagestyle{plain}
\null\vfil
%\vskip 60\p@
\begin{center}{\huge\bf Approval of the Dissertation Committee\par}\end{center}
%\vskip 60\p@
{\normalsize #1}
\vfil\vfil\null
%\cleardoublepage
}
\newcommand\btypeout[1]{\bhrule\typeout{\space #1}\bhrule}
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space \number\year}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\usepackage{vmargin}
\setmarginsrb { 1.5in} % left margin
{ 0.6in} % top margin
{ 1.0in} % right margin
{ 0.8in} % bottom margin
{ 20pt} % head height
{0.25in} % head sep
{ 9pt} % foot height
{ 0.3in} % foot sep
\raggedbottom
\setlength{\topskip}{1\topskip \@plus 5\p@}
\doublehyphendemerits=10000 % No consecutive line hyphens.
\brokenpenalty=10000 % No broken words across columns/pages.
\widowpenalty=9999 % Almost no widows at bottom of page.
\clubpenalty=9999 % Almost no orphans at top of page.
\interfootnotelinepenalty=9999 % Almost never break footnotes.
\usepackage{fancyhdr}
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\ \thechapter\ #1}{\@chapapp\ \thechapter\ #1}}
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\usepackage{amsmath,amsfonts,amssymb,amscd,amsthm,xspace}
\theoremstyle{plain}
\newtheorem{example}{Example}[chapter]
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{axiom}[theorem]{Axiom}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\usepackage[centerlast,small,sc]{caption}
\setlength{\captionmargin}{20pt}
\newcommand{\fref}[1]{Figure~\ref{#1}}
\newcommand{\tref}[1]{Table~\ref{#1}}
\newcommand{\eref}[1]{Equation~\ref{#1}}
\newcommand{\cref}[1]{Chapter~\ref{#1}}
\newcommand{\sref}[1]{Section~\ref{#1}}
\newcommand{\aref}[1]{Appendix~\ref{#1}}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\dbltopfraction}{.85}
\renewcommand{\floatpagefraction}{0.75}
\renewcommand{\dblfloatpagefraction}{.75}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[scriptsize]{subfigure}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{listings}
\usepackage{lstpatch}
\lstset{captionpos=b,
frame=tb,
basicstyle=\scriptsize\ttfamily,
showstringspaces=false,
keepspaces=true}
\lstdefinestyle{matlab} {
language=Matlab,
keywordstyle=\color{blue},
commentstyle=\color[rgb]{0.13,0.55,0.13}\em,
stringstyle=\color[rgb]{0.7,0,0} }
\usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,
bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=false,
colorlinks,linkcolor={blue},citecolor={blue},urlcolor={red},
pdfstartview={FitV},unicode,breaklinks=true]{hyperref}
\pdfstringdefDisableCommands{
\let\\\space
}
\newcommand*{\supervisor}[1]{\def\supname{#1}}
\newcommand*{\examiner}[1]{\def\examname{#1}}
\newcommand*{\degree}[1]{\def\degreename{#1}}
\newcommand*{\authors}[1]{\def\authornames{#1}}
\newcommand*{\addresses}[1]{\def\addressnames{#1}}
\newcommand*{\university}[1]{\def\univname{#1}}
\newcommand*{\UNIVERSITY}[1]{\def\UNIVNAME{#1}}
\newcommand*{\department}[1]{\def\deptname{#1}}
\newcommand*{\DEPARTMENT}[1]{\def\DEPTNAME{#1}}
\newcommand*{\group}[1]{\def\groupname{#1}}
\newcommand*{\GROUP}[1]{\def\GROUPNAME{#1}}
\newcommand*{\faculty}[1]{\def\facname{#1}}
\newcommand*{\FACULTY}[1]{\def\FACNAME{#1}}
\newcommand*{\subject}[1]{\def\subjectname{#1}}
\newcommand*{\keywords}[1]{\def\keywordnames{#1}}
\supervisor {Dr. Such and Such}
\examiner {}
\degree {}
\authors {MEEE!!}
\university {\texorpdfstring{\href{}
{Real Good University}}
{Real Good University}}
\UNIVERSITY {\texorpdfstring{\href{}
{REAL GOOD UNIVERSITY}}
{REAL GOOD UNIVERSITY}}
\department {\texorpdfstring{\href{}
{Department of Fizzx}}
{Department of Fizzx}}
\DEPARTMENT {\texorpdfstring{\href{}
{DEPARTMENT OF FIZZX}}
{DEPARTMENT OF FIZZX}}
\group {\texorpdfstring{\href{Research Group Web Site URL Here (include http://)}
{Research Group Name}}
{Research Group Name}}
\GROUP {\texorpdfstring{\href{Research Group Web Site URL Here (include http://)}
{RESEARCH GROUP NAME (IN BLOCK CAPITALS)}}
{RESEARCH GROUP NAME (IN BLOCK CAPITALS)}}
\faculty {\texorpdfstring{\href{Faculty Web Site URL Here (include http://)}
{Faculty Name}}
{Faculty Name}}
\FACULTY {\texorpdfstring{\href{Faculty Web Site URL Here (include http://)}
{FACULTY NAME (IN BLOCK CAPITALS)}}
{FACULTY NAME (IN BLOCK CAPITALS)}}
\addresses {}
\subject {}
\keywords {}
\renewcommand\maketitle{
\btypeout{Title Page}
\hypersetup{pdftitle={\@title}}
\hypersetup{pdfsubject=\subjectname}
\hypersetup{pdfauthor=\authornames}
\hypersetup{pdfkeywords=\keywordnames}
\thispagestyle{empty}
\begin{titlepage}
\let\footnotesize\small
\let\footnoterule\relax
\let \footnote \thanks
\setcounter{footnote}{1}
\null\vfil
\vskip 60\p@
\begin{center}
\setlength{\parskip}{0pt}
%{\large\textbf{Claremont Graduate University}\par}
\vfill
{\huge \bf \@title \par}
\vfill
{\LARGE by \par}
\smallskip
{\LARGE \authornames \par}
\vfill
{\large A thesis submitted in partial fulfillment for the \par}
{\large degree of Doctor of Philosophy in Mathematics \par}
\bigskip
\bigskip
{\large in the \par}
%{\large \facname \par}
{\large \deptname \par}
{\large \univname \par}
\bigskip
\bigskip
\bigskip
{\Large \@date \par}
\bigskip
\end{center}
\par
\@thanks
\vfil\null
\end{titlepage}
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
\cleardoublepage
}
\newenvironment{abstract}
{
\btypeout{Abstract Page}
\thispagestyle{empty}
\null\vfil
\begin{center}
\setlength{\parskip}{0pt}
{\huge{\textit{Abstract}} \par}
\bigskip
{\normalsize\bf A Pretty Decent(?) Thesis \par}
\medskip
{\normalsize by \par}
{\normalsize \authornames \par}
\bigskip
{\normalsize \UNIVNAME : 2019 \par}
\bigskip
% {\normalsize \facname \par}
% {\normalsize \deptname \par}
% \bigskip
% {\normalsize Doctor of Philosophy\par}
%\bigskip
\end{center}
}
{
\vfil\vfil\vfil\null
\cleardoublepage
}
\addtocounter{secnumdepth}{1}
\setcounter{tocdepth}{6}
\newcounter{dummy}
\newcommand\addtotoc[1]{
\refstepcounter{dummy}
\addcontentsline{toc}{chapter}{#1}}
\renewcommand\tableofcontents{
\btypeout{Table of Contents}
\begin{spacing}{1}{
\setlength{\parskip}{1pt}
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname
\@mkboth{
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}
\@starttoc{toc}
\if@restonecol\twocolumn\fi
\cleardoublepage
}\end{spacing}
}
\renewcommand\listoffigures{
\btypeout{List of Figures}
\addtotoc{List of Figures}
\begin{spacing}{1}{
\setlength{\parskip}{1pt}
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename
\@mkboth{\MakeUppercase\listfigurename}
{\MakeUppercase\listfigurename}}
\@starttoc{lof}
\if@restonecol\twocolumn\fi
\cleardoublepage
}\end{spacing}
}
\renewcommand\listoftables{
\btypeout{List of Tables}
\addtotoc{List of Tables}
\begin{spacing}{1}{
\setlength{\parskip}{1pt}
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listtablename
\@mkboth{
\MakeUppercase\listtablename}{\MakeUppercase\listtablename}}
\@starttoc{lot}
\if@restonecol\twocolumn\fi
\cleardoublepage
}\end{spacing}
}
\newcommand\listsymbolname{Abbreviations}
\usepackage{longtable}
\newcommand\listofsymbols[2]{
\btypeout{\listsymbolname}
\addtotoc{\listsymbolname}
\chapter*{\listsymbolname
\@mkboth{
\MakeUppercase\listsymbolname}{\MakeUppercase\listsymbolname}}
\begin{longtable}[c]{#1}#2\end{longtable}\par
\cleardoublepage
}
\newcommand\listconstants{Physical Constants}
\usepackage{longtable}
\newcommand\listofconstants[2]{
\btypeout{\listconstants}
\addtotoc{\listconstants}
\chapter*{\listconstants
\@mkboth{
\MakeUppercase\listconstants}{\MakeUppercase\listconstants}}
\begin{longtable}[c]{#1}#2\end{longtable}\par
\cleardoublepage
}
\newcommand\listnomenclature{Symbols}
\usepackage{longtable}
\newcommand\listofnomenclature[2]{
\btypeout{\listnomenclature}
\addtotoc{\listnomenclature}
\chapter*{\listnomenclature
\@mkboth{
\MakeUppercase\listnomenclature}{\MakeUppercase\listnomenclature}}
\begin{longtable}[c]{#1}#2\end{longtable}\par
\cleardoublepage
}
\newcommand\acknowledgements[1]{
\btypeout{Acknowledgements}
\addtotoc{Acknowledgements}
\thispagestyle{plain}
\begin{center}{\huge{\textit{Acknowledgements}} \par}\end{center}
{\normalsize #1}
\vfil\vfil\null
}
\newcommand\dedicatory[1]{
\btypeout{Dedicatory}
\thispagestyle{plain}
\null\vfil
\vskip 60\p@
\begin{center}{\Large \sl #1}\end{center}
\vfil\null
\cleardoublepage
}
\renewcommand\backmatter{
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\addtotoc{\bibname}
\btypeout{\bibname}
\@mainmatterfalse}
\endinput
我還包含了一個用於編譯的 MWE:
\documentclass[a4paper, 11pt, oneside]{Thesis}
\begin{document}
\setstretch{1.3}
\fancyhead{}
\rhead{} %\thepage}
\lhead{}
\pagestyle{empty}
\frontmatter
\title {A Pretty Decent(?) Thesis}
\authors {Me}
\maketitle
%% ----------------------------------------------------------------
% The "Funny Quote Page"
\pagestyle{empty} % No headers or footers for the following pages
\null\vfill
\begin{flushright}
Ha! A limerick\\
The bane of my existence\\
Thank goodness I'm done
\end{flushright}
\vfill\vfill\vfill\vfill\vfill\vfill\null
\clearpage % Funny Quote page ended, start a new page
\addtotoc{Abstract} % Add the "Abstract" page entry to the Contents
\abstract{
\addtocontents{toc}{\vspace{1em}}
It's a pretty good thesis, I promise.
}
\clearpage
\setstretch{1.3}
\pagestyle{fancy}
\acknowledgements{
\addtocontents{toc}{\vspace{1em}}
Thank you, I love you, Babye.
}
\pagestyle{fancy}
\lhead{\emph{Contents}}
\tableofcontents
\lhead{\emph{List of Figures}}
\listoffigures
\end{document}
我看到的主要問題可以從第四個編譯頁面(致謝)中說明,我們可以看到這是文件中的第四頁,但它被列為第三頁:
我想要兩件事:
- 我希望羅馬數字編號從標題頁開始(即 pdf 的第一頁應該是第 i 頁)。
- 我不希望在致謝部分之前看到前面的編號。
我的 MWE 並不完美,因為 MWE 中顯示的第一頁碼位於致謝頁上,而在我的實際論文中,摘要的頁碼i
印在底部。我不知道如何讓我的 MWE 更全面,但希望我能夠一次解決一個問題(如果不是同時解決的話)。
答案1
好的,讓我們從可編譯的程式碼開始來解釋您的問題fancyhdr
。
使用以下程式碼模擬您的論文結構
\documentclass[a4paper, 11pt, oneside]{book}
\usepackage{fancyhdr}
\usepackage{blindtext}
\title{A Pretty Decent Thesis}
\author{username}
\begin{document}
\frontmatter
%\pagestyle{empty} % <===================================================
\maketitle
\section*{Abstract}
\Blindtext
\tableofcontents
\listoffigures
\pagestyle{fancy} % <===================================================
\mainmatter
\chapter{Introduction}
\Blinddocument
\end{document}
你可以看到 的兩行\pagestyle
很重要。如果你編譯上面的程式碼你會得到
在那裡您可以看到兩件事:顯示頁碼(因為第一個\pagestyle{empty}
已註釋!)並且它使用羅馬數字,如底部的紅色圓圈所示。根據您的 pdf 檢視器,pdf 檢視器會以阿拉伯數字完全對頁面進行編號(這在您和我的情況下都會發生)。這意味著第一頁(在列印中用羅馬數字編號,直到iv
)用阿拉伯數字計數。編譯我的程式碼後,您可以在最後一頁看到這一點。最後一頁的列印頁碼為 20,但在檢視器中計為第 25 頁。例如,據我記得,Acrobat 顯示羅馬數字和阿拉伯數字。
現在請取消註解第一個\pagestyle{empty}
。現在fancyhdr
知道它不必在所有後續頁面上顯示頁眉和頁腳(直到\pagestyle{fancy}
其他命令(例如\tableofcontents
使用樣式)激活我在本範例程式碼中使用的plain
標準頁首和頁尾)。fancyhdr
編譯後,您將獲得一些沒有頁碼的頁面,但目錄仍然顯示羅馬頁碼。要擺脫它,您必須調用\thispagestyle{empty}
,因為命令是為了使用我們不想要的\tableofcontents
樣式而建立的。plain
同樣的情況也可能發生listoffigures
!
所以下面的程式碼
\documentclass[a4paper, 11pt, oneside]{book}
\usepackage{fancyhdr}
\usepackage{blindtext}
\title{A Pretty Decent Thesis}
\author{username}
\pagestyle{plain}{%
\fancyhead{}
\fancyfoot[c]{}
}
\begin{document}
\frontmatter
\pagestyle{empty} % <===================================================
\maketitle
\pagestyle{empty}
\section*{Abstract}
\Blindtext
\tableofcontents
\thispagestyle{empty} % <==============================================
\listoffigures
\thispagestyle{empty} % <==============================================
\pagestyle{fancy} % <===================================================
\mainmatter
\chapter{Introduction}
\Blinddocument
\end{document}
frontmatter 中不提供頁碼,但顯示從第 1 章開始的頁碼:
現在您可以使用此處解釋的命令並在論文中使用它們來刪除不需要的頁碼。
如果您載入hyperref
程式碼這取決於所使用的 pdf 檢視器顯示的頁面如何編號。就我而言 - 我正在使用 SumatraPDF - 我會看到以下畫面:
現在,SumatraPDF 可以顯示我們所在的頁面iii
(或阿拉伯數字中的 4)。原因是hyperref
書籤被啟動時攜帶了該訊息。
更新:
您使用的類別有一些錯誤,其中一個錯誤導致標題頁後面的頁面(您添加打油詩的頁面)編號錯誤。
若要消除此錯誤,請在序言中(之前\begin{document}
)新增以下程式碼來定義新環境,其中我將頁碼明確設為 2 作為解決方法(請參閱標記行<==========
):
\newenvironment{funyquote}
{
\btypeout{Funyquote Page}
\thispagestyle{empty}
\setcounter{page}{2}% <===============================================
\null\vspace{3cm}
}
{
% \vfill\vfill\vfill\vfill\vfill\vfill\null
\cleardoublepage
}
您可以在\maketitle
以下程式碼後面加上打油詩來新增您的頁面(當然刪除舊的打油詩程式碼!):
\clearpage
\funyquote{% <==========================================================
\begin{flushright}
Ha! A limerick\\
The bane of my existence\\
Thank goodness I'm done
\end{flushright}
} % <===================================================================
\clearpage % Funny Quote page ended, start a new page
然後你得到結果:
如果不進行更正,您會得到錯誤的頁碼,從而導致您觀察到的問題:
我沒有調查這個問題來自哪裡(隱藏在該類別的程式碼中的某個地方),但我建議使用標準類別。誰知道還會出現哪些其他錯誤...