하위 섹션이 문서에 나타나기 전에 헤더에 나타나는 이유는 무엇입니까?

하위 섹션이 문서에 나타나기 전에 헤더에 나타나는 이유는 무엇입니까?

이 코드를 사용하고 있습니다

\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\leftmarkby \markboth\xdef\rightmarkby 를 바꾸면 두 줄의 and 가 다음과 같이 \markright재정의 됩니다.\sectionmark\subsectionmark

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

관련 정보