In my current document there are some chapters that have to be added with the \chapter*-command because I don't want them to be real chapters (no entry in toc, no chapter-number, ...). This works fine.
But in my header I want the chapter-name to be displayed. I'm using fancyheaders and \leftmark:
\fancyhead[RO,LE]{\leftmark}
The problem is, that for chapters added with the \chapter*-command, \leftmark is not updated and so the header still displays the chapter-name of the previous chapter.
Therefore I either need to force \chapter* to automatically update \leftmark, or I switch to the \chapter-command but prevent the other stuff that comes along (entry in toc, ...). but I don't know how! Any ideas?
The * forms of the \chapter etc. commands do not call the mark commands. So if you want your preface to set the header info but not be numbered nor be put in the table of contents, you must issue the \markboth command yourself, e.g.
\chapter*{abc123\markboth{abc123}{}}
I just had redefined chapter and section command to what I need and had set the \leftmark explicitly. Chapter commands will not able to use leftmark anymore, but I don't care as I'm using my \nnchapter and \nnsection commands in the whole document
\newcommand{\nnchapter}[1]{
\phantomsection
\addcontentsline{toc}{chapter}{#1}\renewcommand{\leftmark}{#1}\chapter*{#1}
}
\newcommand{\nnsection}[1]{
\phantomsection
\addcontentsline{toc}{section}{#1}\renewcommand{\leftmark}{#1}\section*{#1}
}
Try this:
\let\oldleftmark=\leftmark
\chapter*{My New Leftmark}
\renewcommand{\leftmark}{My New Leftmark}
...
Your text
...
\pagebreak
\chapter{Next Chapter}
\let\leftmark=\oldleftmark
pagebreak is required to ensure the new lefmark is used
allright, i did it! the solution is to redefine \leftmark only within a specific block! pretty simple if you know it ;)
{
\renewcommand{\leftmark}{ABC123}
\chapter*{ABC123}
%... and so on ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With