书中有两个标题页,无需重新开始页码

书中有两个标题页,无需重新开始页码
\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}

这是我的 preambleBrill 代码:

% 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在于,它是一个在使用调用后会自行禁用的命令(对于等也是\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

titlepage该补丁只是通过重新启动编号方案来停止使用\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尽管如果误解它,显然会产生不良影响,而且命名可能不太恰当。无论如何,由于它易于使用,并能使我的代码保持简单,因此我认为没有理由对礼物吹毛求疵,即使我对礼物在其他情况下的价值存在普遍怀疑。]

因为您已经在使用\frontmatter\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}

相关内容