Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

For my dissertation I've redefined \thechapter as \thepart because I'm only using parts, sections and subsections. With the code below I get the section as the right header but nothing on the left. How do I get the part to appear on the left?

\renewcommand{\thechapter}{\thepart}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\parttitle.\ #1}{}}}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}{}}
\fancyhead{} 
\fancyhead[L]{\textit{\leftmark}} 
\fancyhead[R]{\textit{\rightmark}}
\renewcommand{\cfoot}{\thepage} 
share|improve this question
    
possible duplicate of How to get part name in LaTeX ? –  lockstep Mar 17 '12 at 21:35
    
@lockstep There are other approaches than thru \partname, as you can see in my answer. –  yo' Mar 17 '12 at 21:45

1 Answer 1

up vote 5 down vote accepted

This code does the job. It redefines LaTeX internal command \@part to call \markboth. Package lipsum is there to provide some dummy text.

As well, I cleaned the code:

  • You don't need to redefine \sectionmark nor \chaptermark.
  • There is no command \parttitle, it's \partname.
  • You should use \fancyfoot and don't redefine \cfoot.

The code:

\documentclass{book}

\renewcommand{\thechapter}{\thepart}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} 
\fancyhead[L]{\textit{\leftmark}} 
\fancyhead[R]{\textit{\rightmark}}
\fancyfoot{}
\fancyfoot[C]{\thepage}
\makeatletter
\let\old@part\@part
\def\@part[#1]#2{\old@part[#1]{#2\markboth{\MakeUppercase{\partname.\ #1}}{}}}
\makeatother

\usepackage{lipsum}

\begin{document}

\part{PP}

\section{SS}

\lipsum[1-10]

\end{document}
share|improve this answer
    
Thanks very much for your help. I redefined \sectionmark so that it was in lowercase but your changes worked perfectly. Unfortunately on the first page of each part (the page after the separating page) the \sectionmark no longer appears, even though it does on the subsequent pages. I was wondering if you know how to fix this? –  Tino Mar 17 '12 at 22:02
1  
I modifed the code. Only the longest line of the code got changed. –  yo' Mar 17 '12 at 22:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.