サブセクションがドキュメントよりも先にヘッダーに表示されるのはなぜですか?

サブセクションがドキュメントよりも先にヘッダーに表示されるのはなぜですか?

私はこのコードを使用しています

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
\lhead{\textit{\leftmark}}
\rhead{\textit{\rightmark}}
\rfoot{\textit{Page \thepage}}

\renewcommand{\sectionmark}[1]{\xdef\leftmark{\thesection\quad#1}\xdef\rightmark{}}
\renewcommand{\subsectionmark}[1]{\xdef\rightmark{\thesubsection\quad#1}}

ヘッダーにサブセクションのタイトルを印刷します。ただし、サブセクションがページの上部に印刷されると、前のページのヘッダーに表示されるという問題があります。これは以下に示します。 ここに画像の説明を入力してください

これはセクション 1.1 ですが、ヘッダーにはセクション 1.2 と表示されています。これを修正するにはどうすればよいでしょうか? 現在の解決策は、次のとおりです。

\begin{Def}
Let $\{M_i:i \in \{1,\ldots ,k\} \}$ be a family of submodules of an $R$-module $M$. Then $M$ is the \textit{direct sum} of $M_1,\ldots ,M_k$ if\\
\indent  i) $M=M_1\oplus \ldots \oplus M_k\coloneqq \{ m_1+\ldots +m_k: m_i \in M_i\}$; \\
\indent  ii) $M_i \cap M_j = \emptyset $ for all $i \neq j$.
\end{Def} 

\newpage

したがって、\newpageページの最後にコマンドを追加するだけで問題は解決します。

答え1

コード内で、\xdef\leftmarkを に\markboth\xdef\rightmarkを に置き換えて\markright、 と を再定義する 2 行は\sectionmark\subsectionmarkのようになります。

\renewcommand{\sectionmark}[1]{\markboth{\thesection\quad#1}{}}
\renewcommand{\subsectionmark}[1]{\markright{\thesubsection\quad#1}}

関連情報