对于回忆录文档,我试图让普通章节的偶数页和奇数页标题具有如下形式
2 1 One
和
1.1 A section 3
其中“2”和“3”是页码,“1 One”是章节编号和名称,编号后没有“Chapter”字样或句号,“1.1 A Section”中章节编号后没有句号。
我以为我在做https://tex.stackexchange.com/a/512366/13492。
我还在前言和后记中使用了特殊标题,如下面的来源所示。
问题:
为什么
\pagestyle{main}
从输出第 2 页和第 3 页开始似乎被忽略了?生成的标题似乎是默认的。为什么后面标题中的“文献指南”从最后一页消失了?
样本来源:
\documentclass{memoir}
\setsecnumdepth{subsection}
\settocdepth{subsection}
\nouppercaseheads
\makepagestyle{main}
\makeheadrule{main}{\textwidth}{\normalrulethickness}
\makeevenhead{main}{\bfseries\sffamily\thepage}{}{\bfseries\sffamily\leftmark}
\makeoddhead{main}{\bfseries\sffamily\rightmark}{}{\bfseries\sffamily\thepage}
\addtopsmarks{main}{}{%
% insert "Chapter\space" & "Section\space" if desired as 4th argument:
\createmark{main}{left}{shownumber}{}{\,\space }%
\createmark{main}{right}{shownumber}{}{\,\space}%
}
\makeevenfoot{main}{}{\bfseries\sffamily\thepage}{}
\makeoddfoot{main}{}{\bfseries\sffamily\thepage}{}
\renewcommand{\contentsname}{Table of Contents}
\newcommand{\frontheads}[1]{%
\makeheadrule{headings}{\textwidth}{\normalrulethickness}
\makeevenhead{headings}{\bfseries\sffamily\thepage}{}{\bfseries\sffamily{#1}}
\makeoddhead{headings}{\bfseries\sffamily{#1}}{}{\bfseries\sffamily\thepage}
\makeevenfoot{headings}{}{\bfseries\sffamily\thepage}{}
\makeoddfoot{headings}{}{\bfseries\sffamily\thepage}{}
}
\newcommand{\backheads}[1]{%
\makeheadrule{headings}{\textwidth}{\normalrulethickness}
\makeevenhead{headings}{\bfseries\sffamily\thepage}{\bfseries\sffamily{#1}}{}
\makeoddhead{headings}{}{\bfseries\sffamily}{\bfseries\sffamily\thepage}
\makeevenfoot{headings}{}{\bfseries\sffamily\thepage}{}
\makeoddfoot{headings}{}{\bfseries\sffamily\thepage}{}
}
\chapterstyle{default}
\usepackage{lipsum}
\begin{document}
\frontmatter
\frontheads{Table of Contents}
\tableofcontents\cleardoublepage
\frontheads{Preface}
\chapter{Preface}
\lipsum[1-9]\cleardoublepage
\pagestyle{main} % <--- SEEMS TO BE IGNORED!
\mainmatter
\chapter{One}
\lipsum[1]
\section{A section}
\subsection{First}
\lipsum[1-7]
% Many (sub-)sections to force multi-page TOC
\subsection{Second}
\subsection{Third}\subsection{Four}\subsection{Five}\subsection{Six}
\subsection{Seven}\subsection{Eight}\subsection{Nine}
\subsection{Ten}\subsection{Eleven}\subsection{Twelve}
\subsection{Thirteen}\subsection{Fourteen}\subsection{Fifteen}
\subsection{Sixteen}\subsection{Seventeen}\subsection{Eighteen}
\subsection{Nineteen}\subsection{Twenty}\subsection{Twenty-one}
\subsection{Twenty-two}\subsection{Twenty-three}\subsection{Twenty-four}
\section{B section}\section{C section}\section{D section}
\section{E section}\section{F section}\section{G section}\section{H section}
\section{I section}\section{J section}\section{K section}\section{L section}
\section{M section}\section{N section}\section{O section}\section{P section}
\section{Q section}\section{R section}\section{S section}\section{T section}
\section{U section}\section{V section}\section{W section}\section{X section}
\section{Y section}\section{Z section}\section{AA section}\section{BB section}
\section{CC section}\section{DD section}\section{EE section}\section{FF section}
\section{GG section}\section{HH section}\section{II section}\section{JJ section}
\section{KK section}\section{LL section}\section{MM section}\section{NN section}
\section{OO section}\section{PP section}\section{QQ section}\section{RR section}
\section{SS section}\section{TT section}\section{UU section}\section{VV section}
\section{WW section}\section{XX section}\section{YY section}\section{ZZ section}
\chapter{Two}
\backmatter
\backheads{Guide to the Literature}
\chapter{Guide to the Literature}
\lipsum[1-10]
\end{document}
这错误的主要内容的偶数和奇数页眉打印如下:
这正确的前言(和后言)的偶数和奇数页眉打印如下:
笔记:也可以看看回忆录:简短和详细目录的标题
答案1
我会放弃\frontheads
并\backheads
定义一个适当的main
风格并在序言中激活它。
主要问题是您的 psmarks:
\makepsmarks{main}{%
\createmark{chapter}{both}{shownumber}{}{\enspace} % use both not left
\createmark{section}{right}{shownumber}{}{\enspace}
\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}
}
然后通过在序言中激活它并摆脱你的\frontheads
和\backheads
我似乎得到了与这两个宏完全相同的输出
您在 MWE 中犯的错误是这样的:
\addtopsmarks{main}{}{%
% insert "Chapter\space" & "Section\space" if desired as 4th argument:
\createmark{main}{left}{shownumber}{}{\,\space }% <-- main is wrong here
\createmark{main}{right}{shownumber}{}{\,\space}% <-- and here
}