
나는 기사 클래스와 패키지를 사용하는 사용자 정의 패키지를 사용하고 있습니다 fancyhdr
. 다음을 사용하여 헤더를 정의합니다.
\fancyhead[CO,CE]{}
\fancyhead[RO,RE]{\scshape\leftmark}
문제는 여러 섹션과 섹션*이 있다는 것입니다. 각 섹션* 페이지에서 헤더에는 섹션 이름이 아닌 이전 섹션의 이름이 표시됩니다*.
나는 그것을 변경하는 방법에 대한 단서가 없습니다. 도움을 주시면 감사하겠습니다.
답변1
내 이전 답변의 방법은 다음과 같습니다.여기:
\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}