TransWikia.com

What is the difference between leftmark and rightmark in fancyhdr?

TeX - LaTeX Asked by zyy on October 31, 2020

I am having a hard time trying to figure out the difference between leftmark and rightmark in fancyhdr. At page 8 of the documentation, it says

The leftmark contains the Left argument of the Last markboth on the page, the rightmark contains the Right argument of the fiRst markboth or the only argument of the fiRst markright on the page.

However, I could not find the definition of markboth. Could anyone please teach me of the difference or definition of leftmark and rightmark?

My though is, based on my use of fancyhdr, leftmark writes chapter number and name if chapters exist, if not, it will write section number and name instead. As for rightmark, it will always write the title one level lower than that of leftmark.

Thank you in advance!

One Answer

The primitive mark stores one piece of data. The latex commands markright and markboth splits the argument of mark to be able to store two things. So

markboth{left 1}{right 1} does more or less mark{{left 1}{right 1}}

markright{right 2} retrieves the left part of the previous mark and then stores it together with the new right content. So it does (again more or less) mark{{left 1}{right 2}}.

The stored contents can be retrieved (only in the header and footer, at other places the result is not reliable!) with leftmark and rightmark.

As the names indicates the commands retrieve the left and right part respectivly: leftmark gets the left part of the last mark on the page, rightmark the right part of the first mark on the page (or the last on the previous page).

With normal setups you get these marks

 ==== page break, new chapter:
 chapter:     {{chapter}    {   }}
 section1:    {{chapter}    {section1}}
 section2:    {{chapter}    {section2}}
 ==== page break: leftmark: chapter, rightmark: empty

 section3:    {{chapter}    {section3}}
 section4:    {{chapter}    {section4}}
 ==== page break: leftmark: chapter, rightmark: section3

Answered by Ulrike Fischer on October 31, 2020

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