
Вэтот вопросЯ спросил, как использовать аргумент нового уровня секционирования, определенного с titlesec
pkg в качестве заголовка. Теперь, повторяя тот же код, я хотел бы спросить, как использовать аргумент \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, а второй ответ, особенно его последний комментарий к его ответу, сделал возможным использование его в качестве заголовка.
Я использовал минимальный пример второго ответа. Теперь файл имеет заголовок главы для четных страниц и заголовок части для нечетных страниц.
Примечание: при изменении \part
позиции аргумент немного смещается вверх по сравнению с исходным выводом команды 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}