書中的兩個標題頁,無需重新開始頁碼編號

書中的兩個標題頁,無需重新開始頁碼編號
\documentclass[11pt,twoside]{book}
\input{Brillpreamble}
\begin{document}
\frontmatter
\include{titleBrill}
\include{abbrevBrill}
\include{prefaceandintroBrill}
\mainmatter
\input{./title1.tex}
\include{text1}
\input{./title2.tex}
\include{text2}
\backmatter
\printindex[nominum]
\printindex[rerum]
\pagestyle{myheadings}
\include{Biblio}
\end{document}

這是我的序言Brill 代碼:

% XeLaTeX can use any Mac OS X font. See the setromanfont command below.
% Input to XeLaTeX is full Unicode, so Unicode characters can be typed directly into the source.

% The next lines tell TeXShop to typeset with xelatex, and to open and save the source with Unicode encoding.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\usepackage{booktabs}
\usepackage{ledmac}
\linenummargin{inner}
\sidenotemargin{outer}
\usepackage{fancyhdr}
\usepackage{adforn}
\usepackage{amsmath}
\usepackage{lmodern}
\pagestyle{myheadings}
\usepackage{hanging}
\usepackage{pdfpages}
\textheight = 180.5 mm
\textwidth = 108.5 mm
\pagenumbering{arabic}
\usepackage[hang]{footmisc}
\setlength{\footnotemargin}{12pt}
\makeatletter
\renewcommand\@makefntext[1]{%
  \noindent\makebox[1em][r]{\@makefnmark}#1}
\makeatother
\usepackage{imakeidx} 
\makeindex[name=nominum, title=Index nominum, columns=2]
\makeindex[name=rerum, title=Index rerum, columns=2]
\pretolerance=100
\usepackage{microtype}
\makeatletter
% And in the paragraphed footnotes, I'd like no colon too:
\def\parafootfmt#1#2#3{%
  \normal@pars
  \parindent=0pt \parfillskip=0pt plus 1fil
  {\bf\printlines#1|}%
  {\select@lemmafont#1|#2}~%
  #3\penalty-10 }
\makeatother
\let\Afootfmt\parafootfmt

%\newcommand{\rhet}[2]{\edtext{#1}{\Afootnote{#2}}}
\newcommand{\rhet}[2]{\edtext{ #1}{\Afootnote{] #2}}}
\newcommand{\oed}[2]{\edtext{ #1}{\Bfootnote{] #2}}}
\footparagraph{A}
\footparagraph{B}

%%%%%%%%%%%%%%%%
\raggedbottom


\newcommand*{\LeftWidth}{3.0cm}%
\newcommand*{\RightWidth}{\dimexpr\linewidth-\LeftWidth-2em\relax}%
\newcommand{\AlignedBrace}[2]{%
    \medskip\par\noindent%
    \parbox{\LeftWidth}{\raggedleft\textbf{#1}\strut~}%
    $\left\{~\parbox{\RightWidth}{\strut\textit{#2}\strut}\right.$%
}%


%\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
%\geometry{a4paper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page geometry
%\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}

\usepackage{amssymb}
%\renewcommand %These two commands are for double-spacing
%\baselinestretch{2}

% Will Robertson's fontspec.sty can be used to simplify font choices.
% To experiment, open /Applications/Font Book to examine the fonts provided on Mac OS X,
% and change "Hoefler Text" to any of these choices.

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Brill}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}
\frenchspacing

\newfontfamily{\H}[Scale=0.9]{Lucida Grande}
\usepackage{caption}
\captionsetup{aboveskip=5pt}

\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
\let\endchangemargin=\endlist

答案1

問題\maketitle是,它是一個在使用 using 呼叫後會禁用自身的命令(對於等也是\global\let\maketitle\relax如此\title\author

可以透過重新定義\maketitle或使用\xpatch和刪除相關程式碼來停用此功能。

無論如何,這將阻止重新啟動頁碼編號。

下一個罪魁禍首是隱式book使用titlepage。如果使用此選項,maketitle\begin{titlepage}...\end{titlepage}將自動重設頁碼。

notitlepage我暫時在這裡提供版本,titlepage稍後嘗試獲取該野獸。

\documentclass[notitlepage]{book}



\usepackage{xpatch}

\newcounter{titlescntr}

\makeatletter

\xpatchcmd{\maketitle}{\par
}{%
  \par%
  \stepcounter{titlescntr}
  \ifnum\value{titlescntr} > 0 
  \cleardoublepage
  \fi
}{}{}

\xpatchcmd{\maketitle}{%
  \global\let\thanks\relax
  \global\let\maketitle\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
}{%
  \clearpage
}{\typeout{Patched!}}{\typeout{Patching failed!}}

\makeatother

\title{Two treatises} 
\author{Guillaume Coatalen} 
\date{} 

\usepackage{blindtext}

\begin{document}

\maketitle 

\title{Theory of Brontosaurs}
\author{Ann Elk}
\maketitle

\blindtext


\end{document}

更新:刪除頁碼的重置(如果titlepage使用)

\documentclass[titlepage]{book}
\usepackage{xpatch}
\newcounter{titlescntr}

\makeatletter

\if@titlepage
\xpatchcmd{\maketitle}{%
  \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
}{%
}{\typeout{patched maketitle for titlepage}}{}

\xpatchcmd{\titlepage}{%
  \setcounter{page}\@ne
}{%
}{\typeout{patched titlepage}}{}

\xpatchcmd{\endtitlepage}{%
  \setcounter{page}\@ne
}{%
}{\typeout{patched endtitlepage}}{}

\else

\xpatchcmd{\maketitle}{\par
}{%
  \par% 
  \stepcounter{titlescntr}
  \ifnum\value{titlescntr} > 0 % Make a new page for the next title
  \cleardoublepage
  \fi
}{}{}

\xpatchcmd{\maketitle}{%
  \global\let\thanks\relax
  \global\let\maketitle\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
}{%
  \clearpage
}{\typeout{Patched!}}{\typeout{Patching failed!}}
\fi

\makeatother

\title{Two treatises} 
\author{Guillaume Coatalen} 
\date{} 

\usepackage{blindtext}

\begin{document}

\maketitle 

\title{Theory of Brontosaurs}
\author{Ann Elk}
\maketitle

\blindtext


\end{document}

答案2

我很懶。如果其他人已經完成了這項工作並且我可以使用他們的工作,我認為我沒有必要花時間研究他們稱之為“輪子”的新發明的不同設計。


我會用電子工具箱修補預設用於標題的titlepage環境,並讓book標題做剩下的。

\usepackage{etoolbox,titling}
\makeatletter
\patchcmd{\titlepage}{\setcounter{page}\@ne}{}{\message {Successfully patched titlepage.}}{\message {Failed to patch titlepage.}}
\makeatother

該補丁只是停止使用titlepageby\maketitle重新啟動編號方案。然而,當我們第一次在主要內容中切換到阿拉伯數字時,我們仍然會從 1 開始編號,因為\mainmatter它會自動處理。

載入中標題允許我們在文件中任意多次使用常規\title, \author, \date,命令。\maketitle

\title{Title 1}
\author{Author 1}
\date{Date 1}
\maketitle

\title{Title 2}
\author{Author 2}
\date{Date 2}
\maketitle

[我並不反對使用 ,\maketitle儘管它顯然在被誤解時會產生不良影響,並且可能不幸被命名。無論如何,由於它很容易使用並且讓我的代碼保持簡單,所以我認為沒有理由對一匹禮物馬放在心上,即使我對這匹馬在其他情況下的價值有普遍懷疑。 ]

因為您已經在使用\frontmatterand \mainmatter,所以無需擔心設定頁碼類型,因為該類book預設使用小寫羅馬數字作為前題,並使用阿拉伯數字作為主要內容。

\frontmatter

切換為小寫羅馬數字,從 1 開始。

\mainmatter

然後切換到阿拉伯數字,從 1 重新開始計數。

兩個扉頁,小寫羅馬數字和連續阿拉伯數字

完整程式碼:

\documentclass[11pt]{book}
\usepackage{etoolbox,titling}
\makeatletter
\patchcmd{\titlepage}{\setcounter{page}\@ne}{}{\message {Successfully patched titlepage.}}{\message {Failed to patch titlepage.}}
\makeatother
\pagestyle{myheadings}
\usepackage{kantlipsum}
\begin{document}
\frontmatter
\kant[1-5]
\mainmatter
\title{Title 1}
\author{Author 1}
\date{Date 1}
\maketitle
\kant[6-10]
\title{Title 2}
\author{Author 2}
\date{Date 2}
\maketitle
\kant[11-15]
\backmatter
\kant[16-20]
\end{document}

相關內容