2

In this question I asked how to use the argument of a new sectioning level defined with the titlesec pkg as header. Now repeating the same code I'd like to ask how can I use the argument of \part command as header. It seemed easier, and I looked into titlesec documentation and there was a hint but I couldn't understand how to use it.

    \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 Answer 1

2

I should've searched more and paid more attention than simply asking the question. By mixing parts of answer here and this one here, I could make the \part argument as the header, . First answer modifies the part style with the help of titlesec pkg,maybe facilitating the recognition of this command by titlesec pkg and the second answer particularly his last comment on his answer made it possible to use it as header.

I used the minimal example of the second answer. Now the file has chapter title as header for even pages and part title as header for odd pages.

Note: By modifying the \part the position of its argument slightly moves toward the top in comparison to the original part command output, a fraction of a millimeter.

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

enter image description here enter image description here

2
  • I just couldn't understand what are these two seperated backslashes in this line between \partname and \thepart? {\normalfont\huge\bfseries\filcenter}{\partname\ \ \thepart}{22pt}{\Huge}
    – nima
    Commented Jun 6, 2016 at 13:26
  • 1
    \ \ \thepart just introduce two space characters before the part number. \ stands for space character
    – user31729
    Commented Jun 6, 2016 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .