Page Layout ⇒ Fancyhdr: Calling the part and chapter names
-
- Posts: 4
- Joined: Fri Apr 29, 2011 7:23 pm
Fancyhdr: Calling the part and chapter names
I'm using fancyhdr and would like to make the following appear in italics at the top left of each page:
"Part <part #>, Ch. <ch #>: <part short name> / <chapter short name>" - e.g.:
"Part I, Ch. 1: Introduction / Literature Review"
Right now I'm doing this via, e.g.:
"\fancyhead[L]{\textit{Part \thepart, Ch. \thechapter: <manually entering in part name> / <manually entering in chapter name>}"
and just re-entering this with the new info every time there's a chapter or part change.
I was wondering if there's a way to call the part (short) name and chapter (short) name so that I don't have to manually re-enter at each change (similar to the way "\thepart" and "\thechapter" call the part and chapter numbers respectively automatically)?
My guess was that preamble etc. info wasn't necessary for this sort of question but if you need that, please let me know.
Any direction would be much appreciated - thanks!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10328
- Joined: Mon Mar 10, 2008 9:44 pm
Fancyhdr: Calling the part and chapter names
welcome to the board!
You could use \leftmark and \rightmark. These are used by LaTeX to store such short titles. They can be modified using commands such as \chaptermark and \partmark. You can read about this in the fancyhdr manual: 9 The scoop on LaTeX’s marks.
Stefan
-
- Posts: 4
- Joined: Fri Apr 29, 2011 7:23 pm
Re: Fancyhdr: Calling the part and chapter names
Basically I've used \chapter[xxx]{yyy} to define each given chapter, and I'm hoping to pull the <xxx> for the header but didn't know if there's a command (like "\thechapter" for the chapter number) that would just spit out the <xxx>.
Thanks again.
- Stefan Kottwitz
- Site Admin
- Posts: 10328
- Joined: Mon Mar 10, 2008 9:44 pm
Fancyhdr: Calling the part and chapter names
- You write \chapter[xxx]{yyy}
- \chapter automatically calls \chaptermark with xxx and uses yyy for the heading in the body text
- \chaptermark applies some formatting to xxx and puts it into \leftmark
- fancyhdr puts \leftmark into the header as you specified it
Stefan