
Enesta preguntaPregunté cómo utilizar el argumento de un nuevo nivel de sección definido con el titlesec
paquete como encabezado. Ahora, repitiendo el mismo código, me gustaría preguntar cómo puedo usar el argumento del \part
comando como encabezado. Parecía más fácil, busqué en titlesec
la documentación y había una pista, pero no podía entender cómo usarla.
\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}
Respuesta1
Debería haber buscado más y haber prestado más atención que simplemente hacer la pregunta. Mezclando partes de la respuestaaquíy ésteaquí, Podría hacer el \part
argumento como encabezado. La primera respuesta modifica el estilo de la parte con la ayuda de titlesec pkg, tal vez facilitando el reconocimiento de este comando por titlesec
pkg y la segunda respuesta, particularmente su último comentario sobre su respuesta, hizo posible usarlo como encabezado.
Utilicé el ejemplo mínimo de la segunda respuesta. Ahora el archivo tiene el título del capítulo como encabezado para las páginas pares y el título de la parte como encabezado para las páginas impares.
Nota: Al modificar la \part
posición de su argumento, se mueve ligeramente hacia la parte superior en comparación con la salida del comando de pieza original, una fracción de milímetro.
\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}