0

I need to get part name to insert it in some special pages (parts beginning pages), without using \titlesecpackage, but I haven't been able to get it until the moment. I tried defining a special pagestyle, but it didn't work.

This is test code I was working on:

\documentclass{report}
\usepackage{fancyhdr}
\usepackage{minitoc}

%Define pagestyle
\fancyhf{}% Clear all headers/footers
\fancyhead[L]{Left header}\fancyhead[C]{Centre header}\fancyhead[R]{Right header}
\fancyfoot[L]{Left footer}\fancyfoot[C]{Centre footer}\fancyfoot[R]{Right footer}
\pagestyle{fancy}


%Define especial pagestyle
\fancypagestyle{especial}{
\fancyhead[R]{\nouppercase{\rightmark}}
}

%Trying to include part name in headers (doesn't work)
\makeatletter
\renewcommand\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{especial}%
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@part\@spart}
\makeatother

\begin{document}
\doparttoc
\tableofcontents
\thispagestyle{especial}    
\part{part 1}
\section{section 1}
\part{part 2}
\section{section 3}

\end{document}

enter image description here Do someone get any idea how to do it?

  • \markboth{#1}{#1}? I am not sure i completely understand the question. – Johannes_B Jan 30 at 7:28
  • I just updated the post in order to do it clearer. I wouldn't know how to use this "\markboth{#1}{#1}" exactly in my code. – Daniel Jan 30 at 7:35
  • \fancyhead[R]{#1} in the definition of the part? Do you really think the reader will need this kind of information? – Johannes_B Jan 30 at 7:35
  • I tried but it didn't work me. That's in order to apply a pagestyle to initial part page. – Daniel Jan 30 at 7:40
  • AFAIK sectioning commands like part or chapter creates a new page and issue at \thisppagestyle{empty}. Hence of you really want to break this use, you would have to r patch the part command ( with \patchcmd or \appto from etoolbox, or redefine the \part command with \renewcommand) In both cases you would have to add either the standard \markboth command as suggested by @Johannes_B, or an equivalent defined with fancyhdr. – Jhor Jan 30 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.