页眉中页面第一个字的节号

页眉中页面第一个字的节号

我正在使用 fancyhead,我想在标题中包含该页面上第一个单词所属的部分编号:

\documentclass[leqno]{book}
\usepackage[utf8]{inputenc}
\usepackage{polski}
\usepackage{fancyhdr}
\usepackage{lipsum}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1}{} }

\pagestyle{fancy}
\fancyhead[LE]{\thepage} 
\fancyhead[CE]{\thepart. \parttitle}
\fancyhead[RE]{[\thesubsection}
\fancyhead[LO]{\thesubsection]} 
\fancyhead[CO]{\nouppercase{\rightmark}}
\fancyhead[RO]{\thepage}
\begin{document}


\setcounter{page}{5}
\setcounter{part}{1}
\setcounter{chapter}{3}
\setcounter{section}{4}

\section{first section}

\subsection{first subsection}
\lipsum[1]
\lipsum[1]
\lipsum[1]
\lipsum[1]\\
\\
that text comes from section 1 and should make header to [3.5.1
\subsection{second subsection}
that text comes from subsection 2 and changes header in the top right to [3.5.2 (supposed to be [3.5.1)
\end{document}

二十

相关内容