LaTeX: update '\ leftmark' automatically in '\ chapter * {abc123}'

There are several chapters in my current document that need to be added using the command \chapter*because I do not want them to be real chapters (there is no entry in toc, no chapter-number, ...). It works great.

But in my headline I want to show chapter-name. I use fancyheadersand \leftmark:

\fancyhead[RO,LE]{\leftmark}

The problem is that chapters added with the command \chapter*are \leftmarknot updated, so the title still displays the chapter name of the previous chapter.

Therefore, I need to either force it to \chapter*automatically update \leftmark, or switch to the command \chapter, but do not include other material that comes (writing to toc, ...). but I dont know how! Any ideas?

+3
source share
5 answers

I just redefined the chapter and section command for what I need and explicitly set it \leftmark. The head of the team no longer be able to use the left sign, but I do not care, because I use the team \nnchapterand \nnsectionthe entire 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}
}
+3
source

* \chapter .. . , , , , \markboth, .

\chapter*{abc123\markboth{abc123}{}}
+3

All right, I did it! The solution is to override \ leftmark only in a specific block! pretty simple if you know it;)

{
    \renewcommand{\leftmark}{ABC123}
    \chapter*{ABC123}

    %... and so on ...
}
+1
source

Try the following:

 \let\oldleftmark=\leftmark
    \chapter*{My New Leftmark}
    \renewcommand{\leftmark}{My New Leftmark}
      ...
      Your text
      ...
    \pagebreak
    \chapter{Next Chapter}
    \let\leftmark=\oldleftmark

pagebreak required to ensure the use of new lefmark

+1
source

I'm not sure if this will work, because I don't have LaTeX installed on my current computer ...

But you can try installing the \ markleft command after the \ chapter * command as follows:

\chapter*{Chapter title goes here}
\markleft{Chapter title goes here}  % content should be added to the \leftmark

Hope this helps.

0
source

Source: https://habr.com/ru/post/1764129/


All Articles