Cómo hacer que la sección* aparezca en el encabezado

Cómo hacer que la sección* aparezca en el encabezado

Estoy usando la clase de artículo y un paquete personalizado donde uso el fancyhdrpaquete. Defino mi encabezado usando:

\fancyhead[CO,CE]{}
\fancyhead[RO,RE]{\scshape\leftmark}

El problema es que tengo varias secciones y apartados*. En cada página de sección*, el encabezado muestra el nombre de la sección anterior y no el nombre de la sección *.

No tengo idea de cómo cambiar eso, agradecería cualquier ayuda.

Respuesta1

Aquí hay una manera de mi antigua respuesta.aquí:

\documentclass{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
%\fancyhead[CO,CE]{}
\fancyhead[R]{\scshape\leftmark}
\let\oldsection\section
\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{#1}%
}
\def\@nonStarredWithout#1{%
\oldsection{#1}%
\renewcommand\leftmark{#1}%
}
\makeatother

\pagestyle{fancy}

\title{Test redefined sections}

\author{Kostis Leledakis}

\begin{document}
\maketitle
\tableofcontents
\clearpage

\section{A section}
\lipsum[1-8]
\section{Another section}
\lipsum[1-6]
\section*{A starred section}
\lipsum[1-8]
\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}

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

información relacionada