# Header with section title while numbering is in the footer?

How can I put the section/subsection title and number on the header while having the numbering in the footer?

\pagestyle{...} doesn't allow for this combination.

• You should take a look at the documentation of titleps, which comes with titlesec. – Bernard Aug 19 at 16:06
• What numbering do you need in the footer? Page numbering, or sectional numbering? – Werner Aug 19 at 16:13
• page numbering in the footer – J DOe Aug 19 at 16:14

Here is a way that solves some problems (like adding starred sections and subsections too in the headers -or even in TOC if modified-)

\documentclass[twoside]{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\let\oldsection\section
\let\oldsubsection\subsection
\makeatletter
\def\section{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}
\def\@StarredWith[#1]#2{%
\oldsection*{#2}%
\renewcommand\leftmark{#1}%
}
\def\@StarredWithout#1{
\oldsection*{#1}%
\renewcommand\leftmark{#1}
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldsection[#1]{#2}%
\renewcommand\leftmark{\thesection~#1}%
}
\def\@nonStarredWithout#1{%
\oldsection{#1}%
\renewcommand\leftmark{\thesection~#1}%
}

\def\subsection{%
\@ifstar{\@StarredS}{\@nonStarredS}%
}
\def\@StarredS{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to use them for the hearder}\@StarredSWith}%
{\@StarredSWithout}%
}
\def\@StarredSWith[#1]#2{%
\oldsubsection*{#2}%
\renewcommand\rightmark{#1}%
}
\def\@StarredSWithout#1{
\oldsubsection*{#1}%
\renewcommand\rightmark{#1}
}
\def\@nonStarredS{%
\@ifnextchar[%
{\@nonStarredSWith}%
{\@nonStarredSWithout}%
}
\def\@nonStarredSWith[#1]#2{%
\oldsubsection[#1]{#2}%
\renewcommand\rightmark{\thesubsection~#1}%
}
\def\@nonStarredSWithout#1{%
\oldsubsection{#1}%
\renewcommand\rightmark{\thesubsection~#1}%
}
\makeatother

\pagestyle{fancy}

\title{Test redefined sections}

\author{Kostis Leledakis}

\begin{document}
\maketitle
\tableofcontents
\clearpage

\section{A section}
\lipsum[1-8]
\subsection{A subsection}
\lipsum[1-6]
\subsection*{A starred subsection}
\lipsum[1-8]
\subsection{Another numbered  subsection}
\lipsum[1-6]
\subsection*{Another starred subsection}
\lipsum[1-8]
\subsection[Short title of subection \thesubsection]{Another numbered  subsection with short title}
\lipsum[1-6]
\section{Another section}
\lipsum[1-6]
\section*{A starred section}
\lipsum[1-8]
\subsection{A subsection}
\lipsum[1-6]
\subsection*{A starred subsection}
\lipsum[1-8]
\subsection{Another numbered  subsection}
\lipsum[1-6]
\subsection*{Another starred subsection}
\lipsum[1-8]
\subsection[Short title of subection \thesubsection]{Another numbered  subsection with short title}
\lipsum[1-6]
\section{Another numbered  section}
\lipsum[1-6]
\section*{Another starred section}
\lipsum[1-8]
\section[Short title of section \thesection]{Another numbered  section with short title}
\lipsum[1-6]
\section*[Short title of starred section]{Another starred  section with short title}
\lipsum[1-8]
\end{document}


PS: it is this answer modified.

• PS: I don't think that your question needed all these as it is right now. I mean that the normal usage of fancyhdr could define what you want to have ... But you would lose some headers of starred sections or subsections. – koleygr Aug 19 at 17:34