# Problem with customized \part

I use titlesec package to set part style, but I also would like to put the name of the part in header. I try the way proposed in this thread (How to get part name in LaTeX ?). I get the header as I want but it causes a duplication of part name in my document (see below)...

Here is a part of the code :

\titleformat{\part}[display]%
{\Huge\sffamily\bfseries}%
{\filleft{\huge\sffamily \textbf{\partname \\}}}%
{0mm}%
{\thispagestyle{empty}\filleft}%
[]%
\titlespacing{\part}{0mm}{40pt}{40pt}[- \marginparwidth - \marginparsep]%

\let\letpart\part
\renewcommand{\partmark}{}
\renewcommand{\part}[2][]{%
\ifx\\#1\\
\letpart{#2}%
\renewcommand\partmark{\partname{} -- #2}%
\else
\letpart[#1]{#2}%
\renewcommand\partmark{\partname{} -- #1}%
\fi
}


I have the same problem if I just use :

\let\letpart\part
\renewcommand{\part}[1]{\letpart{#1}}


(so it seems the problem comes from the use of \let). Has anybody an idea to avoid it ? Thanks for your help.

Edit : Here is a compilable code. It is a part of a class I made ; I let the whole list of package in case you see a conflict.

\documentclass[twoside, openright]{report}

\usepackage[paper=a4paper, lmargin=15mm, rmargin=15mm, tmargin=15mm, bmargin=15mm,
\usepackage[francais]{babel}
\usepackage[latin1]{inputenc}

\usepackage[fleqn]{amsmath}
\usepackage{amssymb, mathrsfs, stmaryrd, gensymb}
\usepackage[upright]{fourier}
\usepackage{emerald}

\usepackage{setspace}
\usepackage{calc}
\usepackage{array, multirow, tabularx}
\usepackage{xcolor, color, colortbl}
\usepackage{graphicx, picins}
\usepackage{subfig}
\usepackage[top]{mcaption}
\usepackage{fancyhdr, lastpage}
\usepackage[fit]{truncate}
\usepackage{mdwlist}
\usepackage{titlesec, titletoc}
\usepackage{ulem}
\usepackage{float}
\usepackage[globalcitecopy]{bibunits}
\usepackage{multido}
\usepackage{ragged2e}
\usepackage{marginfix}

\usepackage[geometry]{ifsym}
\usepackage{ifthen}
\usepackage[strict]{changepage}
\usepackage{framed}

\makeatletter
\definecolor{abricot1}{rgb}{1,0.580,0.412}
\definecolor{abricot2}{rgb}{1,0.680,0.565}
\definecolor{abricot3}{rgb}{1,0.933,0.890}

\newcommand{\couleurP}[0]{abricot1}%
\newcommand{\couleurS}[0]{abricot2}%
\newcommand{\couleurT}[0]{abricot3}%

\pagestyle{fancy}

\fancyhf{}
\textcolor{\couleurP}{$\blacksquare\thinspace$}\textcolor{\couleurS}{$\blacksquare\thinspace\blacksquare$}}
\fancyhead[RO]{\textcolor{\couleurS}{$\blacksquare\thinspace\blacksquare$}\textcolor{\couleurP}{$\thinspace\blacksquare$} \quad%
\small\textsf{\thepage}}
\fancyfoot{}

\titleformat{\part}[display]%
{\Huge\sffamily\bfseries}%
{\filleft{\huge\sffamily \textbf{\partname \\}}}%
{0mm}%
{\thispagestyle{empty}\filleft}%
[]%
\titlespacing{\part}{0mm}{40pt}{40pt}[- \marginparwidth - \marginparsep]%

\let\letpart\part
\renewcommand{\partmark}{}
\renewcommand{\part}[2][]{%
\ifx\\#1\\
\letpart{#2}%
\renewcommand\partmark{\partname{} -- #2}%
\else
\letpart[#1]{#2}%
\renewcommand\partmark{\partname{} -- #1}%
\fi
}
\makeatother

\title{{\'E}tude expérimentale...}

\pagestyle{empty}

\author{Emmanuel G.}

\date{\today}

\begin{document}

\pagestyle{fancy}

\maketitle

\part{Du microscopique au mésoscopique}
tba.

\end{document}

• Can you please extend the snippet to a compilabel example to make helping easier? – Johannes_B Dec 26 '14 at 10:51
• The \partmark command should set \leftmark. Can you tell how the page headings should appear? – egreg Dec 26 '14 at 11:57
• @Johannes_B : I have just edited my message to add a compilable example. – Emmanuel G. Dec 26 '14 at 12:30
• @egreg : I would like to have the number + title of the part on the top inner corner of odd pages, and the number of the page on the top outer corner. I use \leftmark to display the chapter name on inner corner of even pages. – Emmanuel G. Dec 26 '14 at 12:34

The \...mark commands should use \markboth or \markright that set \leftmark and \rightmark, the only ones to be used in \fancyhead.

\documentclass[twoside, openright]{report}

\usepackage[paper=a4paper, lmargin=15mm, rmargin=15mm, tmargin=15mm, bmargin=15mm,

\usepackage[francais]{babel}
\usepackage[utf8]{inputenc} % just for me!

\usepackage[fleqn]{amsmath}
\usepackage{amssymb, mathrsfs, stmaryrd, gensymb}
\usepackage[upright]{fourier}
%\usepackage{emerald} % I have no emerald package

\usepackage{setspace}
\usepackage{calc}
\usepackage{array, multirow, tabularx}
\usepackage{xcolor, color, colortbl}
\usepackage{graphicx}
%\usepackage{picins} % I have no picins package
\usepackage{subfig}
\usepackage[top]{mcaption}
\usepackage{fancyhdr, lastpage}
\usepackage[fit]{truncate}
\usepackage{mdwlist}
\usepackage{titlesec, titletoc}
\usepackage{ulem}
\usepackage{float}
\usepackage[globalcitecopy]{bibunits}
\usepackage{multido}
\usepackage{ragged2e}
\usepackage{marginfix}

\usepackage[geometry]{ifsym}
\usepackage{ifthen}
\usepackage[strict]{changepage}
\usepackage{framed}

\usepackage{kantlipsum} % just to fill up pages with nonsense

\makeatletter
\definecolor{abricot1}{rgb}{1,0.580,0.412}
\definecolor{abricot2}{rgb}{1,0.680,0.565}
\definecolor{abricot3}{rgb}{1,0.933,0.890}

\newcommand{\couleurP}[0]{abricot1}%
\newcommand{\couleurS}[0]{abricot2}%
\newcommand{\couleurT}[0]{abricot3}%

\pagestyle{fancy}

\fancyhf{}
\textcolor{\couleurP}{$\blacksquare\thinspace$}%
\textcolor{\couleurS}{$\blacksquare\thinspace\blacksquare$}%
}
\textcolor{\couleurS}{$\blacksquare\thinspace\blacksquare$}%
\textcolor{\couleurP}{$\thinspace\blacksquare$}%
}
\fancyfoot{}

\titleformat{\part}[display]%
{\Huge\sffamily\bfseries}%
{\filleft{\huge\sffamily \textbf{\partname \\}}}%
{0mm}%
{\thispagestyle{empty}\filleft}%
[]%
\titlespacing{\part}{0mm}{40pt}{40pt}[- \marginparwidth - \marginparsep]%

\renewcommand{\chaptermark}[1]{\markright{\thechapter.\ \ #1}}
\renewcommand{\partmark}[1]{\markboth{\thepart.\ \ #1}{}}

\makeatother

\title{{\'E}tude expérimentale...}

\pagestyle{empty}

\author{Emmanuel G.}

\date{\today}

\begin{document}

\pagestyle{fancy}

\maketitle

\part{Du microscopique au mésoscopique}

\chapter{Je ne sais pas}

\kant[1-12]

\end{document}


## Top of even page

A solution without fancyhdr, that I replaced with titleps, since you use titlesec. You don't have to set marks, but only the \chaptertitle and \parttitle commands.

I removed packages that weren't relevant to the problem, except fonts loading. Note that loading color is pointless since you load xcolor. Also, you should load inputenc with option utf8, as it's more portable : nowadays all platforms and all modern editors understand utf8.

\documentclass[twoside, openright]{report}

\usepackage[paper=a4paper, lmargin=15mm, rmargin=15mm, tmargin=15mm, bmargin=15mm,
\usepackage[francais]{babel}
\usepackage[utf8]{inputenc}

\usepackage[fleqn]{amsmath}
\usepackage{amssymb, mathrsfs, stmaryrd, gensymb}
\usepackage[upright]{fourier}

\usepackage{calc}
\usepackage{xcolor, colortbl}%
\usepackage[clearempty, toctitles, newparttoc, pagestyles]{titlesec}

\usepackage{lipsum}

\definecolor{abricot1}{rgb}{1,0.580,0.412}
\definecolor{abricot2}{rgb}{1,0.680,0.565}
\definecolor{abricot3}{rgb}{1,0.933,0.890}

\newcommand{\couleurP}[0]{abricot1}%
\newcommand{\couleurS}[0]{abricot2}%
\newcommand{\couleurT}[0]{abricot3}%

\newpagestyle{mystyle}{%
\settitlemarks{part, chapter}
\sethead[\small\textsf{\thepage} \quad \textcolor{\couleurP}{$\blacksquare\thinspace$} \textcolor{\couleurS}{$\blacksquare\thinspace\blacksquare$}][][\thechapter. \enspace \chaptertitle]{\partname\enspace–\enspace\parttitle}{}{\textcolor{\couleurS}{$\blacksquare\thinspace \blacksquare$}\textcolor{\couleurP}{$\thinspace\blacksquare$} \quad \small\textsf{\thepage}}
}%

\titleformat{\part}[display]%
{\Huge\sffamily\bfseries}%
{\filleft{\huge\sffamily \textbf{\partname \\}}}%
{0mm}%
{\thispagestyle{empty}\filleft}%
[]%
\titlespacing{\part}{0mm}{40pt}{40pt}[- \marginparwidth - \marginparsep]%

\title{Étude expérimentale...}

\author{Emmanuel G.}

\date{\today}

\pagestyle{empty}

\begin{document}

\maketitle

\pagestyle{mystyle}

\part{Du microscopique au mésoscopique}

\chapter{Le microscopique}
\lipsum[1-20]

\end{document}