我想在偶数页上设置页眉,其中包含页码和章节号,在奇数页上设置章节标题和页码。 即,如下图所示:
这是我所能得到的。它给了我在正确位置上的章节标题,但没有给出章节编号。
\documentclass[10pt]{memoir}
\usepackage{lipsum}
\makepagestyle{myheadings}
\makepsmarks {myheadings}{
\nouppercaseheads
\createmark {chapter} {left} {nonumber}{\@chapapp\ }{. \ }
%\createmark {chapter} {right} {notitle}{\@chapapp\ }{ }
\createplainmark {toc} {both} {\contentsname}
\createplainmark {lof} {both} {\listfigurename}
\createplainmark {lot} {both} {\listtablename}
\createplainmark {bib} {both} {\bibname}
\createplainmark {index} {both} {\indexname}
\createplainmark {glossary} {both} {\glossaryname}
}
\makeoddhead{myheadings}{\footnotesize\sffamily\leftmark}{}{\footnotesize\sffamily\thepage}
\makeevenhead{myheadings}{\footnotesize\sffamily\thepage}{}{\footnotesize\sffamily\rightmark}
\pagestyle{myheadings}
\begin{document}
\chapter{Chapter title}
\section{Introduction}
\lipsum[1-5]
\section{Section title}
\lipsum[6-10]
\end{document}
我一直尝试包含类似这样的内容:\createmark {chapter} {right} {notitle}{\@chapapp\ }{ }
,但没有效果。
我也尝试过\makeevenhead{myheadings}{\footnotesize\sffamily\thepage}{}{\footnotesize\sffamily{Chapter~\thechapter}}
。这适用于本书的大部分内容,但不适用于目录、前言和附录(在标题中变为第 0 章、第 A 章和第 B 章)。
答案1
以下是我的解决方法
\documentclass[10pt]{memoir}
\usepackage{lipsum}
\makeatletter
\makepagestyle{myheadings}
\makepsmarks{myheadings}{
\nouppercaseheads
% remove any marks for sections (might be left over from default pagestyle)
\clearmark{section}
\clearmark{subsection}
\clearmark{subsubsection}
% hand code \chaptermark, the code is taken from the definition of
% \createmark for the 'both' version, and cleaned a little
\renewcommand\chaptermark[1]{
\@setclcnt{chapter}{@memmarkcntra}%
\advance\c@@memmarkcntra\m@ne
\markboth{%
\memUChead{%
\ifnum\c@secnumdepth > \c@@memmarkcntra
\if@mainmatter
\@chapapp\ \thechapter
\fi
\fi
}%
}{%
\memUChead{%
##1%
}%
}%
}%
\createplainmark{toc} {both}{\contentsname}
\createplainmark{lof} {both}{\listfigurename}
\createplainmark{lot} {both}{\listtablename}
\createplainmark{bib} {both}{\bibname}
\createplainmark{index} {both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}
}
\makeatother
\makeoddhead{myheadings}{\footnotesize\sffamily\rightmark}{}{\footnotesize\sffamily\thepage}
\makeevenhead{myheadings}{\footnotesize\sffamily\thepage}{}{\footnotesize\sffamily\leftmark}
\pagestyle{myheadings}
\begin{document}
\chapter{Chapter title}
\section{Introduction}
\lipsum[1-5]
\section{Section title}
\lipsum[6-10]
\end{document}