
でこの質問パッケージで定義された新しいセクション レベルの引数を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の助けを借りてパートスタイルを変更し、おそらくtitlesec
pkgによるこのコマンドの認識を容易にし、2番目の回答、特に彼の回答に対する最後のコメントにより、それをヘッダーとして使用できるようになりました。
2 番目の回答の最小限の例を使用しました。これで、ファイルには偶数ページのヘッダーとして章のタイトルが含まれ、奇数ページのヘッダーとしてパートのタイトルが含まれるようになりました。
注: を変更すると、\part
その引数の位置が、元のパーツ コマンド出力と比較して、わずか 1 ミリメートルだけ上方向に移動します。
\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}