显示章节编号而不是书名(回忆录 + titlesec)

显示章节编号而不是书名(回忆录 + titlesec)

我正在使用该memoir软件包编写一本非小说类书籍。我发现创建一个部分会使右侧页面的标题显示章节编号而不是书名

我想要的是:背面的页眉应该有章节名称,正面的页眉应该有书名。

我提到这个问题,仅包含章节标题的页眉,但似乎无法解决我的问题。以下是 MWE:

% universal settings
\documentclass[a5paper,11pt,twoside,onecolumn,openright,extrafontsizes]{memoir}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[osf]{Alegreya,AlegreyaSans}
\usepackage[tracking=true,letterspace=50]{microtype}
\usepackage{setspace}
\usepackage{titlesec}

\usepackage{lipsum} % to generate Lorem Ipsum

\setlength{\parskip}{0em}
\linespread{1.15}
\SetTracking{encoding=*,shape=sc}{100}

% tracking adjustments for small caps
\DeclareMicrotypeSet*[tracking]{alegreyasc}
{font = */AlegreyaSC-TLF/*/*/*}

% defining the title and the author
\title{My Title}

% chapter title manipulation
% padding with zero
\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}

\setcounter{secnumdepth}{0}
\titleformat{\section}[block]{\large\bfseries}{}{1em}{}

% HEADER AND FOOTER MANIPULATION
 % for normal pages
 \nouppercaseheads
 \makeatletter
\newcommand*\headerfont[1]{%
  \renewcommand*\mystyle@headerfont{#1}%
}
\newcommand*\mystyle@headerfont{\scshape}
\makepagestyle{mystyle}
\setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
\makerunningwidth{mystyle}{\headwidth}
\makeevenhead{mystyle}{}{\mystyle@headerfont\thetitle}{}
\makeoddhead{mystyle}{}{\mystyle@headerfont\leftmark}{}
\makeevenfoot{mystyle}{}{\mystyle@headerfont\thepage}{}
\makeoddfoot{mystyle}{}{\mystyle@headerfont\thepage}{}
\clearmark{section}
\makepsmarks{mystyle}{%
  \createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother
 % for pages where chapters begin
 \makepagestyle{plain}
 \makerunningwidth{plain}{\headwidth}
 \makeevenfoot{plain}{}{}{}
 \makeoddfoot{plain}{}{}{}
 \pagestyle{mystyle}

% layout check and fix
\checkandfixthelayout
\fixpdflayout

% BEGIN THE DOCUMENT
\begin{document}
\pagestyle{mystyle}
% preface
\chapter{Chapter One}
\lipsum[1]

\section*{Section One}
\lipsum[2-10]

\end{document}

输出如下(注意标题): 页眉中的章节编号,而不是书名

答案1

编辑:这是对修改问题。原始版本请参见下文。

Memoir 提供的功能与 (p. 339) 提供的功能类似titlesec。如果同时使用,则需要控制两个部分:分区格式、标记内容和页眉格式。如果要使用titlesec,请使用titleps配置页眉、页脚和标记。如果要使用 Memoir,请不要加载titlesec。而是使用 Memoir 提供的功能。

您的\titleformatfor\section基本上相当于

\setsecheadstyle{\large\bfseries}

因为如果您不编号部分或打印标签,标签和标题之间的缩进是无关紧要的,并且这block几乎是默认外观。所以该\titleformat命令唯一真正做的事情就是替代\large\Large这很公平,但是您可以使用 Memoir 的轻松做到这一点\setsecheadstyle,如第 95 页所述。本节还介绍如何配置其他部分划分,包括调整标题前后的垂直间距、缩进等。如果您使用这些命令,那么您使用 Memoir 对标记和页眉的自定义将在您的文档中生效。否则,您需要重做该代码以考虑所做的更改titlesec

章节格式和标题 *sans* <code>titlesec</code>

\documentclass[a5paper,11pt,twoside,onecolumn,openright,extrafontsizes]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[osf]{Alegreya,AlegreyaSans}
\usepackage[tracking=true,letterspace=50]{microtype}
% setspace is emulated - see p. 339 - so loading the package is blocked, but the emulation is not complete
\makeatletter
\newcommand{\setstretch}[1]{% from setspace.sty
  \def\baselinestretch{#1}%
  \@currsize
}
\makeatother
% see p. 339 of Memoir's docs re. titlesec - you can use it, but you'll lose Memoir's equivalent functionality which cooperates with headers, marks etc.
\usepackage{lipsum} % to generate Lorem Ipsum

% \parskip is 0 by default
\setstretch{1.15}% see setspace.sty for details
\SetTracking{encoding=*,shape=sc}{100}

% tracking adjustments for small caps
\DeclareMicrotypeSet*[tracking]{alegreyasc}
{font = */AlegreyaSC-TLF/*/*/*}

% defining the title and the author
\title{My Title}

% chapter title manipulation
% padding with zero
\renewcommand*\thechapter{\ifnum\value{chapter}<10 0\fi\arabic{chapter}}

\setcounter{secnumdepth}{0}
\setsecheadstyle{\large\bfseries}% p. 95
% HEADER AND FOOTER MANIPULATION
% for normal pages
\nouppercaseheads
\makeatletter
\newcommand*\headerfont[1]{%
  \renewcommand*\mystyle@headerfont{#1}%
}
\newcommand*\mystyle@headerfont{\scshape}
\makepagestyle{mystyle}
\setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
\makerunningwidth{mystyle}{\headwidth}
\makeevenhead{mystyle}{}{\mystyle@headerfont\thetitle}{}
\makeoddhead{mystyle}{}{\mystyle@headerfont\leftmark}{}
\makeevenfoot{mystyle}{}{\mystyle@headerfont\thepage}{}
\makeoddfoot{mystyle}{}{\mystyle@headerfont\thepage}{}
\clearmark{section}
\makepsmarks{mystyle}{%
  \createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother
 % for pages where chapters begin
 \makepagestyle{plain}
 \makerunningwidth{plain}{\headwidth}
 \makeevenfoot{plain}{}{}{}
 \makeoddfoot{plain}{}{}{}
 \pagestyle{mystyle}

% layout check and fix
\checkandfixthelayout
\fixpdflayout

% BEGIN THE DOCUMENT
\begin{document}
\pagestyle{mystyle}
% preface
\chapter{Chapter One}
\lipsum[1]

\section*{Section One}
\lipsum[2-10]

\end{document}

笔记:这是对原来的问题更新后,这个问题或多或少变得毫无意义。特别是,我的回答假设 Memoir 的功能用于格式化页面布局,包括页眉、标记等。但更新后的问题titlesec显然破坏了这些关键假设。(也许我应该出于这个原因删除这个答案……?)

目前,您永远无法应用您定义的样式。添加\pagestyle{mystyle}将解决此问题。当然,您还需要添加标题,以便它在标题中可用。

我修改了页眉和页脚的字体设置,因为\textls您的示例中没有定义。为此,我创建了一个\headerfont{}可以在一个地方配置的命令。现在,页眉和页脚使用\scshape。要使用小型大写字母,请添加

\headerfont{\small\scshape}

结果如下

输出

完整代码:

\documentclass[a5paper,11pt,twoside,onecolumn,openright]{memoir}
\usepackage{lipsum}
\makeatletter
\newcommand*\headerfont[1]{%
  \renewcommand*\mystyle@headerfont{#1}%
}
\newcommand*\mystyle@headerfont{\scshape}
\makepagestyle{mystyle}
\setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
\makerunningwidth{mystyle}{\headwidth}
\makeevenhead{mystyle}{}{\mystyle@headerfont\thetitle}{}
\makeoddhead{mystyle}{}{\mystyle@headerfont\leftmark}{}
\makeevenfoot{mystyle}{}{\mystyle@headerfont\thepage}{}
\makeoddfoot{mystyle}{}{\mystyle@headerfont\thepage}{}
\clearmark{section}
\makepsmarks{mystyle}{%
  \createmark{chapter}{left}{nonumber}{\@chapapp\ }{.\ }}
\makeatother
\pagestyle{mystyle}
\begin{document}
\title{My Book}
\author{Me}
\date{Now}
\maketitle
\chapter{Chapter title}
\lipsum[1]
\section*{section}
\lipsum[2-10]
\end{document}

相关内容