Hey everyone. This is the first time I've ever posted to any sort of forum, so please excuse me if I make any novice mistakes.
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!
Page Layout ⇒ Fancyhdr: Calling the part and chapter names
-
- Posts: 4
- Joined: Fri Apr 29, 2011 7:23 pm
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Fancyhdr: Calling the part and chapter names
Hi,
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
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
LaTeX.org admin
-
- Posts: 4
- Joined: Fri Apr 29, 2011 7:23 pm
Re: Fancyhdr: Calling the part and chapter names
Thanks for the reply. I actually had looked at that documentation before, but I couldn't tell if there was a simple command to literally just call the short name of a chapter/part - do you know of one? From what I understand, \chaptermark{} is used to define a very short title for the current chapter - though I could have that wrong...?
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.
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: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Fancyhdr: Calling the part and chapter names
\chaptermark and \sectionmark are defined by classes or packages. It can work like this:
Stefan
- 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
LaTeX.org admin