Inserting a section title into a header with titlesec and fancyhdr

fancyhdrtitlesec

I would like to place specially formatted section titles into page headers. I had been accomplishing this with titlesec and fancyhdr. However, after updating my tex distribution my solution no longer works. The code compiles but the section titles do not appear in the header or anywhere.

I've posted a minimal example below. Switching between the 2 titleformat commands demonstrates the issue. If I place the format code inside an lhead the section titles disappear.

If you have any insight into why this occurring or have an alternative solution I would greatly appreciate it.

\documentclass[11pt]{article}

\usepackage{lipsum}

% Support for header customization
\usepackage{fancyhdr}

% Customize title and sections headers
\usepackage[explicit]{titlesec}

% Clear page headers and footers. 
\pagestyle{fancy}
\fancyhead{}

% Section Header customization
% Comment/Uncomment to see issue.
\titleformat{\section}{}{}{0em}{\lhead{ \Large\sffamily #1 }} 
% \titleformat{\section}{}{}{0em}{\Large\sffamily #1}

\begin{document}
    \section{Section Label}

    \lipsum[1]
\end{document}

Best Answer

Is it something like this you want? I used the companion package titleps:

    \documentclass[11pt]{article}

    \usepackage{lipsum}
    \usepackage[explicit]{titlesec}
    \usepackage{titleps}

    \titleformat{\section}{}{}{0em}{\lhead{ \Large\sffamily #1 }}
     \titleformat{\section}{}{}{0em}{\Large\sffamily #1}

    \usepackage{titleps}
    \newpagestyle{mine}{\headrule
    \sethead[][\sffamily\sectiontitle][]{}{\sffamily\sectiontitle}{}%

    \setfoot[][\thepage][]{}{\thepage}{}}

    \pagestyle{mine}
    \begin{document}

        \section{Section Label}

        \lipsum[1-6]

    \end{document} 

enter image description here