1

i would like to change my headings, instead of showing each time the current chapter title, i want to see the current Part title without "Part:"

Here is the MWE:

\documentclass[a4paper,french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel} %langue francaise
\usepackage{titlesec}
\usepackage{lipsum} %paragraphes prédéfinis
\usepackage{verbatim}
\aliaspagestyle{part}{empty}
\renewcommand{\printpartname}{}
\renewcommand{\partnamenum}{}
\renewcommand{\printpartnum}{}
\usepackage{booktabs}
\chapterstyle{tandh}
\renewcommand\partnumberlinebox[2]{#2\hspace{1em}}
\usepackage{hyperref}
\begin{document}
\part{Hello}
\pagestyle{headings}
\chapter{yes}
\lipsum
\newpage
\lipsum
\chapter{no}
\lipsum
\chapter{maybe}
\end{document}

Thank you


enter image description here

1

You can copy the pagestyle headings and then change the marks of the new page style:

\copypagestyle{partheadings}{headings}
\makepsmarks{partheadings}{%
  \createmark{part}{both}{nonumber}{}{}%
  \clearmark{chapter}%
  \clearmark{section}%
}

Now you can use

\cleardoublepage
\pagestyle{partheadings}

to set the page style inside the document.

enter image description here

Code:

\documentclass[a4paper,french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel} %langue francaise
\usepackage{titlesec}
%\usepackage{lipsum} %paragraphes prédéfinis
\usepackage{verbatim}
\aliaspagestyle{part}{empty}
\renewcommand{\printpartname}{}
\renewcommand{\partnamenum}{}
\renewcommand{\printpartnum}{}
\usepackage{booktabs}
\chapterstyle{tandh}
\renewcommand\partnumberlinebox[2]{#2\hspace{1em}}
\usepackage{hyperref}

\copypagestyle{partheadings}{headings}
\makepsmarks{partheadings}{%
  \createmark{part}{both}{nonumber}{}{}%
  \clearmark{chapter}%
  \clearmark{section}%
}

\usepackage{blindtext}% dummy text
\begin{document}
\pagestyle{empty}
\tableofcontents

\cleardoublepage
\pagestyle{partheadings}
\part{Hello}
\blinddocument

\cleardoublepage
\pagestyle{headings}% switch to normal headings
\part{Next}
\blinddocument
\end{document}
  • Without a single @, nice :-) – Johannes_B Jun 19 '15 at 14:56
1

Modeling \partmark on \chaptermark and redefining the latter:

\documentclass[a4paper,french,12pt,oneside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel} %langue francaise
\usepackage{titlesec}
\usepackage{lipsum} %paragraphes prédéfinis
\usepackage{verbatim}
\usepackage{booktabs}
\usepackage{hyperref}

\aliaspagestyle{part}{empty}
\renewcommand{\printpartname}{}
\renewcommand{\partnamenum}{}
\renewcommand{\printpartnum}{}
\chapterstyle{tandh}
\renewcommand\partnumberlinebox[2]{#2\hspace{1em}}
\newcommand{\partmarksn}[1]{#1}

\makeatletter
\renewcommand{\partmark}[1]{%
  \@setclcnt{part}{@memmarkcntra}%
  \advance\c@@memmarkcntra\m@ne
  \markright{%
    \memUChead{%
      \ifnum\c@secnumdepth>\c@@memmarkcntra
        \if@mainmatter\@nameuse{partmarksn}{\partname. \ }\fi
      \fi
      #1%
    }%
  }%
}
\renewcommand{\chaptermark}[1]{}
\setlength{\headheight}{15.5pt}
\makeatother

\begin{document}
\part{Hello}
\chapter{yes}
\lipsum
\newpage
\lipsum
\chapter{no}
\lipsum
\chapter{maybe}
\end{document}

enter image description here

If you don't want “Première partie.”, then comment out three lines in the definition of \partmark:

\renewcommand{\partmark}[1]{%
  \@setclcnt{part}{@memmarkcntra}%
  \advance\c@@memmarkcntra\m@ne
  \markright{%
    \memUChead{%
%      \ifnum\c@secnumdepth>\c@@memmarkcntra
%        \if@mainmatter\@nameuse{partmarksn}{\partname. \ }\fi
%      \fi
      #1%
    }%
  }%
}

enter image description here

  • 1
    @Hamza.w Remove everything from \ifnum (included) to #1 (excluded). – egreg Jun 18 '15 at 17:28
  • @Hamza.w I added how to do it – egreg Jun 18 '15 at 17:40
  • 1
    @Hamza.w You should remove \pagestyle{headings} as in my code. – egreg Jun 18 '15 at 18:07
  • i see, but i can't i mean i have chapters in the middle of my document, before i have TOC and Introduction so i have to omit their headings ... Can i use put \pagestye to the first pages and then change it to empty? – Hamza.w Jun 18 '15 at 18:14
  • How to cancel the previous pagestyle @egreg ? – Hamza.w Jun 18 '15 at 19:55

Your Answer

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

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