2

I defined 3 different page styles with titleps. I also used titlesec to define a new sectioning level namely \subpart.

Now I can't use this new level's title with titleps as header in odd pages. I don't know how to introduce it to titleps. I include the code I used, it delivers what I intend(apart from the above mentioned problem), but I'd really appreciate if you could refine it.

I marked the problem in the comment to the main page-style definition.

Note: Upon @cfr's remark I removed vide page-style definition.

\documentclass[b5paper,twoside]{book}
\usepackage{geometry}
\usepackage{titletoc}
\usepackage[rm,small,center,compact,newparttoc,clearempty]{titlesec}
\titleclass{\subpart}{page}[\part]
%
%\titleformat{\chapter}{\thechapter .,. \chaptertitlename}
\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}

\usepackage{titleps}
\newpagestyle{main}{
    \sethead[][\chaptertitle][] % even
    {}{\subparttitle}{} % Problem: Here I want to have subpart title. 
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{main}


\newpagestyle{preface}{
    \sethead[][\chaptertitle][] % even
    {}{\chaptertitle}{} % odd
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{preface}
\assignpagestyle{\part}{empty}%it is a titlesec pkg command which suppresses page number only on the first page of the relevant sectioning command
\assignpagestyle{\subpart}{empty}
\assignpagestyle{\chapter}{empty}
\begin{document}

\frontmatter
\pagestyle{empty}
.
.
.
\chapter[Preface]{PREFACE}
\pagestyle{preface}
.
.
.
\mainmatter
\part{History}
\subpart{Primitive Historians}
\pagestyle{main}
\chapter{The Formation of the Concept of History}

\end{document}
nima
  • 393
  • Your page style doesn't seem to use the new division information at all, so it isn't clear what doesn't work. vide seems to be equivalent to empty, so a bit pointless, as far as I can see. main uses chapter, part and page information. preface uses chapter and page information. None of them try to use sub-part information. – cfr Jun 04 '16 at 22:31
  • I defined preface for the preface chapter only, because there is no higher level section above this chapter and using the main style would kept the odd pages of the preface without header. It was the solution which came to my mind in this simple manner and I searched for it and titleps provided this way of defining. – nima Jun 04 '16 at 23:32
  • You need to not load titleps separately but as an option for titlesec, if you want them to work nicely together. – cfr Jun 04 '16 at 23:52

1 Answers1

2

You need to tell titleps which titlemarks are defined using the \settitlemarks macro. As cfr noted in the comments, you also need to load titlesec with the pagestyles option rather than loading the package separately.

So you need:

\usepackage[rm,small,center,compact,newparttoc,clearempty,pagestyles]{titlesec}

and then after you've made your new pagestyles:

\settitlemarks{part,subpart,chapter}

Here's a complete document. I haven't looked at the rest of your code. I've also added the lipsum package to show some pages.

\documentclass[b5paper,twoside]{book}
\usepackage{geometry}
\usepackage{titletoc}
\usepackage[rm,small,center,compact,newparttoc,clearempty,pagestyles]{titlesec}
\usepackage{kantlipsum}
\titleclass{\subpart}{page}[\part]
%
%\titleformat{\chapter}{\thechapter .,. \chaptertitlename}
\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][] % even
    {}{\subparttitle}{} % Problem: Here I want to have subpart title. 
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{main}


\newpagestyle{preface}{
    \sethead[][\chaptertitle][] % even
    {}{\chaptertitle}{} % odd
    \setfoot[][\thepage][]
    {}{\thepage}{}}
\pagestyle{empty}
\assignpagestyle{\part}{empty}%it is a titlesec pkg command which suppresses page number only on the first page of the relevant sectioning command
\assignpagestyle{\subpart}{empty}
\assignpagestyle{\chapter}{empty}
\settitlemarks{subpart,chapter}
\begin{document}

\frontmatter
\pagestyle{empty}
.
.
.
\chapter[Preface]{PREFACE}
\pagestyle{preface}
.
.
.
\part{History}
\subpart{Primitive Historians}
\pagestyle{main}
\chapter{The Formation of the Concept of History}
\kant[1-20]
\end{document}

correct headers

Alan Munn
  • 218,180
  • Do you know why it is necessary to add part to the \settitlemarks and not just subpart? I just figured this out by trial-and-error but I'm clueless as to why it is needed when the default with only chapter,section obviously works fine. – cfr Jun 05 '16 at 00:48
  • I hope you don't mind Kant, but my answer used kantlipsum and I thought a screenshot might be helpful. – cfr Jun 05 '16 at 00:50
  • @cfr Thanks for adding the screenshot. As for the inclusion of part that was an oversight [on my part :) ] For me, it does work with just subpart, chapter. Do you get an error or an incorrect output? – Alan Munn Jun 05 '16 at 01:07
  • I got an error. It complained \subparttitle was not defined in that case. I thought it very strange that adding part resolved it. – cfr Jun 05 '16 at 01:27
  • @cfr Maybe you had an old .aux file? I just reran the posted code without the part in \settitlemarks and it compiles without error. I've also removed it from the answer. – Alan Munn Jun 05 '16 at 01:32
  • I can't reproduce it now. I don't think I had an old .aux. I used glanhau-tex which definitely removes the .aux. (I realise this is not a ... er... commonly used command, but it does work.) I don't know what I did. Maybe I'm just confused. titlesec and friends tend to confuse me almost immediately, so this is a very likely hypothesis ;). – cfr Jun 05 '16 at 01:34
  • thank you both, I added the line you wrote and passing the pagestyles option to titlesec but it returned error and I have to go take an exam. I'll respond after my exam. – nima Jun 05 '16 at 06:34
  • After an hour I finally recognized the source of the problem.In the front-matter I have a preface chapter and a acknowledgment as soon as I uncomment the latter it returns a bunch of error. – nima Jun 05 '16 at 16:16
  • @AlanMunn Even in your file the problem persists. \chapter{PREFACE} \pagestyle{preface} \kant[1-20] \chapter{Acknowledgments} \kant[1-20] – nima Jun 05 '16 at 16:20
  • @nima I can reproduce the problem but at the moment I'm not sure what's going on. – Alan Munn Jun 05 '16 at 16:44
  • @AlanMunn I shall mention another problem here, the part page is numbered though I have the \assignpagestyle{\part}{empty}. By the way sorry I forgot to thank you for your answer. – nima Jun 05 '16 at 20:31
  • 1
    @nima Yes, I've noticed that problem too. For the original problem, if you put the \settitlemarks{subpart,chapter} inside the definition of the {main} pagestyle, the document will compile properly. I haven't updated the answer because I was hoping to solve the numbering problem too. – Alan Munn Jun 05 '16 at 21:03
  • @AlanMunn In this question (http://tex.stackexchange.com/questions/117354) the numbering problem is solved. – nima Jun 06 '16 at 11:43