TransWikia.com

Why does the subsection appear in the header before it does in the document?

TeX - LaTeX Asked by Manj on March 28, 2021

I am using this code

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

renewcommand{sectionmark}[1]{xdefleftmark{thesectionquad#1}xdefrightmark{}}
renewcommand{subsectionmark}[1]{xdefrightmark{thesubsectionquad#1}}

to print the subsection title in the header. However, I have the issue that if the subsection is printed at the top of the page, then it shows in the header of the previous page. This is shown below.
enter image description here

This is Section 1.1, but the header shows Section 1.2. How do I fix this? My current solution is to do the following.

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_1oplus ldots oplus M_kcoloneqq { 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

So I just add a newpage command at the end of the page and that fixes the issue.

One Answer

In your code, replace xdefleftmark by markboth, and xdefrightmark by markright, so that the two lines re-defining sectionmark and subsectionmark would be like this:

renewcommand{sectionmark}[1]{markboth{thesectionquad#1}{}}
renewcommand{subsectionmark}[1]{markright{thesubsectionquad#1}}

Answered by hesham on March 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP