
Estoy usando este código
\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}}
para imprimir el título de la subsección en el encabezado. Sin embargo, tengo el problema de que si la subsección se imprime en la parte superior de la página, se muestra en el encabezado de la página anterior. Esto se muestra a continuación.
Esta es la Sección 1.1, pero el encabezado muestra la Sección 1.2. ¿Cómo puedo solucionar esto? Mi solución actual es hacer lo siguiente.
\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
Así que simplemente agrego un \newpage
comando al final de la página y eso soluciona el problema.
Respuesta1
En su código, reemplace \xdef\leftmark
por \markboth
y \xdef\rightmark
por \markright
, de modo que las dos líneas redefinidas \sectionmark
y \subsectionmark
queden así:
\renewcommand{\sectionmark}[1]{\markboth{\thesection\quad#1}{}}
\renewcommand{\subsectionmark}[1]{\markright{\thesubsection\quad#1}}