# Display \parttitle in header\footer with titlesec package

I want the \parttitle displays in the header, however, as you see on the picture below, this command has been ignored:

I tried solutions from there questions:

The MWE is...

\documentclass[a4paper,twoside]{article}

\usepackage{titletoc}
\usepackage[pagestyles]{titlesec}

\begin{document}

\pagestyle{myfancy}
\setfoot[\thepage][][]{}{}{\thepage}

\part{Part A}
\section{Section AA}
\subsection{Section AA}
\subsubsection{Section AAA}
\subsubsection{Section AAB}
\subsection{Section AB}
\subsubsection{Section ABA}
\subsubsection{Section ABB}
\section{Section AB}

\end{document}


## After I corrected according Mr. Werner answer and returned to my source file

I discovered that hyperref package and redefining part with titlesec commands has influence, too. Look the MWE below: the part will not display if you place \usepackage{hyperref} before \usepackage{etoolbox}. It's simple to correct, however if you need to redefine the part with titlesec commands, \parttitle will dissapers again. Is anything possible to do with it? (Please don't forget to remove \iffalse from row 28 to make \parttitle disappear again)

\documentclass[twoside]{article}

\usepackage{titletoc,etoolbox}
\usepackage[pagestyles]{titlesec}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@part}% <cmd>
{\markboth{}{}}% <search>
{\gdef\parttitle{#1}}% <replace>
{}{}% <success><failure>
\makeatother
\usepackage{hyperref}

\pagestyle{myfancy}
\setfoot[\thepage][][]{}{}{\thepage}

% ---------------------
\usepackage{color,tikz}
\usetikzlibrary{arrows}

\iffalse
% -- Part format
\definecolor{ChapterColor}{rgb}{1.00,0.80,0.61}
\definecolor{ChapterColor2}{rgb}{0.5,0.10,0.23}

\titleformat{\part}[display]{\Large\sffamily\color{ChapterColor}}
{\filright\Huge\sffamily\bfseries \hspace*{2mm}%
\begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
\node[fill=ChapterColor2,rectangle,rounded corners,text=white] {第\thepart 部};
\end{tikzpicture}}
{1ex}
{\titlerule[1.5pt]\huge\sffamily}
[]

\titlespacing{\part}{0pt}{0pt}{2mm}
\titleformat{name=\part,numberless}[display]
{\normalfont\color{ChapterColor}}
{}
{1ex}
{\vspace*{5ex}\huge\sffamily}
[]
\fi

\begin{document}

\part{Part A}
\section{Section AA}
\subsection{Section AA}
\subsubsection{Section AAA}
\subsubsection{Section AAB}
\subsection{Section AB}
\subsubsection{Section ABA}
\subsubsection{Section ABB}
\section{Section AB}

\newpage

\part{Part B}
\section{Section AA}

\end{document}


\part seems somewhat exclusive in terms of titlesec. As such, here's a rudimentary patch (via etoolbox) that stores the last-used \part title in \parttitle:

\documentclass[twoside]{article}

\usepackage{titletoc,etoolbox}
\usepackage[pagestyles]{titlesec}

\pagestyle{myfancy}
\setfoot[\thepage][][]{}{}{\thepage}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@part}% <cmd>
{\markboth{}{}}% <search>
{\gdef\parttitle{#1}}% <replace>
{}{}% <success><failure>
\makeatother

\begin{document}

\part{Part A}
\section{Section AA}
\subsection{Section AA}
\subsubsection{Section AAA}
\subsubsection{Section AAB}
\subsection{Section AB}
\subsubsection{Section ABA}
\subsubsection{Section ABB}
\section{Section AB}

\end{document}


The above patch exchanges \markboth{}{} for storing the part title in \parttitle. Depending on the document composition, you may want to keep the \markboth{}{} and therefore use the patch

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@part}% <cmd>
{\markboth{}{}}% <search>
{\gdef\parttitle{#1}\markboth{}{}}% <replace>
{}{}% <success><failure>
\makeatother


to remove any header content not related to the specific part.

• Don't you need to retain the \markboth{}{}? If you add a part B followed by a few pages of lipsum before the next section, you'll still get section references from part A. At least, that is what seems to happen. – cfr Oct 14 '14 at 1:24
• @cfr: True. I've referenced this in my answer. – Werner Oct 14 '14 at 2:33
• Dear Mr. Werner, thank you for your solution. Returned to my source document, I discovered two more factors which has influence on parttile display. If you have the time and wish to join to this reseach, please check current question field which has been updated. – Gurebu Bokofu Oct 14 '14 at 9:34