
在這個問題我詢問如何使用以 pkg 作為標頭定義的新分段層級的參數titlesec
。現在重複相同的程式碼,我想問如何使用\part
命令的參數作為標題。這看起來更容易,我查看了titlesec
文檔,有一個提示,但我不明白如何使用它。
\documentclass[b5paper,twoside]{book}
\usepackage{geometry}
\usepackage{titletoc}
\usepackage[rm,small,center,compact,newparttoc,clearempty,pagestyles]{titlesec}
\usepackage{kantlipsum}
\titleclass{\subpart}{page}[\part]
\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][]
{}{\parttitle}{} % Problem: Here I want to have part title.
\setfoot[][\thepage][]
{}{\thepage}{}}
\pagestyle{main}
\newpagestyle{preface}{
\sethead[][\chaptertitle][]
{}{\parttitle}{}
\setfoot[][\thepage][]
{}{\thepage}{}}
\pagestyle{empty}
\assignpagestyle{\part}{empty}
\assignpagestyle{\subpart}{empty}
\assignpagestyle{\chapter}{empty}
\settitlemarks{part,chapter}
\begin{document}\frontmatter
\pagestyle{empty}
\chapter[Preface]{PREFACE}
\pagestyle{preface}
\kant[1-20]
\part{History}
\subpart{Primitive Historians}
\pagestyle{main}
\chapter{The Formation of the Concept of History}
\kant[1-20]
\end{document}
答案1
我應該多搜尋、多關注,而不是簡單地問這個問題。透過混合部分答案這裡和這個這裡,我可以將\part
參數作為標題,。第一個答案在 titlesec pkg 的幫助下修改了部分樣式,也許有助於 pkg 識別該命令titlesec
,第二個答案特別是他對答案的最後評論使得可以將其用作標題。
我使用了第二個答案的最小範例。現在,該文件將章節標題作為偶數頁的標題,並將部分標題作為奇數頁的標題。
注意:透過修改\part
其參數的位置,與原始零件命令輸出相比,稍微向頂部移動了幾分之一毫米。
\documentclass{book}
\usepackage[a6paper]{geometry}% just for the example
\usepackage[pagestyles]{titlesec}
\assignpagestyle{\part}{empty} % Works[removes the page number from the part page]
\assignpagestyle{\chapter}{empty} % Works[removes the page number from the starting page of the chapter]
\titleformat{\part}[display]
{\normalfont\huge\bfseries\filcenter}{\partname\ \ \thepart}{22pt}{\Huge}
\newpagestyle{main}{
\sethead[][\chaptertitle][] % even header
{}{\parttitle}{} % odd header
\setfoot[][\thepage][] % even footer: making the page number on th bottom of the page and center
{}{\thepage}{} % odd footer
\settitlemarks{part,chapter}}
\pagestyle{main}
\usepackage{kantlipsum}
\begin{document}
\part{Bar}
\chapter{Foo}
\kant[1-20]
\end{document}