Use o título da parte como cabeçalho

Use o título da parte como cabeçalho

Emessa questãoPerguntei como usar o argumento de um novo nível de seccionamento definido com o titlesecpacote como cabeçalho. Agora, repetindo o mesmo código, gostaria de perguntar como posso usar o argumento do \partcomando como cabeçalho. Parecia mais fácil, procurei na titlesecdocumentação e havia uma dica, mas não consegui entender como usá-la.

    \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}

Responder1

Eu deveria ter pesquisado mais e prestado mais atenção do que simplesmente fazer a pergunta. Misturando partes da respostaaquie esteaqui, eu poderia apresentar o \partargumento como o cabeçalho, . A primeira resposta modifica o estilo da parte com a ajuda do titlesec pkg, talvez facilitando o reconhecimento deste comando pelo titlesecpkg e a segunda resposta principalmente o último comentário sobre sua resposta possibilitou utilizá-lo como cabeçalho.

Usei o exemplo mínimo da segunda resposta. Agora o arquivo tem o título do capítulo como cabeçalho para páginas pares e o título da parte como cabeçalho para páginas ímpares.

Nota: Ao modificar a \partposição do seu argumento move-se ligeiramente para o topo em comparação com a saída do comando da peça original, uma fração 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}

insira a descrição da imagem aqui insira a descrição da imagem aqui

informação relacionada