使用 titleps 修改页面布局

使用 titleps 修改页面布局

我使用 定义了 3 种不同的页面样式titleps。我还用titlesec定义了一个新的分段级别,即\subpart

现在我无法在奇数页中使用带有 titleps 的新关卡标题作为页眉。我不知道如何将其引入titleps。我附上了所使用的代码,它实现了我想要的功能(除了上述问题),但如果您能对其进行改进,我将不胜感激。

我在评论中标记了这个问题主要的页面样式定义。

注意:根据@cfr 的评论,我删除了视频页面样式定义。

\documentclass[b5paper,twoside]{book}
\usepackage{geometry}
\usepackage{titletoc}
\usepackage[rm,small,center,compact,newparttoc,clearempty]{titlesec}
\titleclass{\subpart}{page}[\part]
%
%\titleformat{\chapter}{\thechapter .,. \chaptertitlename}
\newcounter{subpart}

\renewcommand{\thesubpart}{\Alph{subpart}}
\newcommand{\subpartname}{Subpart}
%
\titleformat{\subpart}[display]{\centering\normalfont\Large\bfseries}%
{\subpartname~\thesubpart}{1pc}{\Huge\bfseries}
%
\titlespacing{\subpart}{0pt}{0pt}{0pt}

\titlecontents{subpart}[0pt]{\addvspace{1pc}\normalfont\bfseries}%
{\thecontentslabel\enspace ---\enspace\large}%
{\normalfont\large\bfseries}{\hspace{2em plus 1fill}\large\contentspage}
\setcounter{secnumdepth}{-2}

\usepackage{titleps}
\newpagestyle{main}{
    \sethead[][\chaptertitle][] % even
    {}{\subparttitle}{} % Problem: Here I want to have subpart title. 
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{main}


\newpagestyle{preface}{
    \sethead[][\chaptertitle][] % even
    {}{\chaptertitle}{} % odd
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{preface}
\assignpagestyle{\part}{empty}%it is a titlesec pkg command which suppresses page number only on the first page of the relevant sectioning command
\assignpagestyle{\subpart}{empty}
\assignpagestyle{\chapter}{empty}
\begin{document}

\frontmatter
\pagestyle{empty}
.
.
.
\chapter[Preface]{PREFACE}
\pagestyle{preface}
.
.
.
\mainmatter
\part{History}
\subpart{Primitive Historians}
\pagestyle{main}
\chapter{The Formation of the Concept of History}

\end{document}

答案1

您需要titleps使用宏来判断哪些标题标记是定义的\settitlemarks。正如 cfr 在评论中指出的那样,您还需要titlesec使用该pagestyles选项进行加载,而不是单独加载包。

因此你需要:

\usepackage[rm,small,center,compact,newparttoc,clearempty,pagestyles]{titlesec}

然后在您制作新的页面样式之后:

\settitlemarks{part,subpart,chapter}

这是完整的文档。我还没有看过你的其余代码。我还添加了lipsum包来显示一些页面。

\documentclass[b5paper,twoside]{book}
\usepackage{geometry}
\usepackage{titletoc}
\usepackage[rm,small,center,compact,newparttoc,clearempty,pagestyles]{titlesec}
\usepackage{kantlipsum}
\titleclass{\subpart}{page}[\part]
%
%\titleformat{\chapter}{\thechapter .,. \chaptertitlename}
\newcounter{subpart}

\renewcommand{\thesubpart}{\Alph{subpart}}
\newcommand{\subpartname}{Subpart}
%
\titleformat{\subpart}[display]{\centering\normalfont\Large\bfseries}%
{\subpartname~\thesubpart}{1pc}{\Huge\bfseries}
%
\titlespacing{\subpart}{0pt}{0pt}{0pt}

\titlecontents{subpart}[0pt]{\addvspace{1pc}\normalfont\bfseries}%
{\thecontentslabel\enspace ---\enspace\large}%
{\normalfont\large\bfseries}{\hspace{2em plus 1fill}\large\contentspage}
\setcounter{secnumdepth}{-2}

\newpagestyle{main}{
    \sethead[][\chaptertitle][] % even
    {}{\subparttitle}{} % Problem: Here I want to have subpart title. 
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{main}


\newpagestyle{preface}{
    \sethead[][\chaptertitle][] % even
    {}{\chaptertitle}{} % odd
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{empty}
\assignpagestyle{\part}{empty}%it is a titlesec pkg command which suppresses page number only on the first page of the relevant sectioning command
\assignpagestyle{\subpart}{empty}
\assignpagestyle{\chapter}{empty}
\settitlemarks{subpart,chapter}
\begin{document}

\frontmatter
\pagestyle{empty}
.
.
.
\chapter[Preface]{PREFACE}
\pagestyle{preface}
.
.
.
\part{History}
\subpart{Primitive Historians}
\pagestyle{main}
\chapter{The Formation of the Concept of History}
\kant[1-20]
\end{document}

正确的标题

相关内容