5

I have chapters beginning as follows:

\chapter*{MyChapter}
\chaptermark{MyChapter}
\addcontentsline{toc}{chapter}{MyChapter}

As you can see the chapters are not numbered but added to the TOC. My problem is with the \chaptermark{} that still puts the chapter number in front of the chapter title on all page headers. What do I have to do?

Here is a working example:

\documentclass[10pt]{scrreprt}
\begin{document}
\pagestyle{headings}
\tableofcontents
\chapter*{MyChapter}
\chaptermark{MyChapter}
\addcontentsline{toc}{chapter}{MyChapter} 

Repeat this text to get a second page in this chapter!

\end{document}

Important: You need to make the text longer so a second page will be added to the chapter. The page header of this second page now reads "0 MyChapter". However, since I like it unnumbered, it should read "MyChapter".

lockstep
  • 250,273
fr3d-5
  • 163
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – alexwlchan Mar 09 '14 at 14:27
  • Classical XY-problem. Don't do workarounds, use the documented code. I vote to close as duplicate, in order to minimalize the chance that people use the answer provided. – Johannes_B Mar 25 '15 at 16:13

1 Answers1

4

The key here is using \renewcommand{\chaptermark}[1]{\markboth{}{#1}} to change how the \chaptermark command operates. Since your MWE is a single-sided document (there is no difference between even pages and odd pages), you get the same header on every page this way.

This command would also be where you can change the formatting of how the header looks, for example to make the header in a sans-serif font, you could change it to:

\renewcommand{\chaptermark}[1]{\markboth{}{\sffamily #1}}

The final code would look like:

\documentclass[10pt]{scrreprt}

\pagestyle{headings}    % Make headings on pages
\usepackage{lipsum}     % For dummy text

\begin{document}

\tableofcontents

\renewcommand{\chaptermark}[1]{\markboth{}{#1}}

\chapter*{MyChapter}
\chaptermark{MyChapter}
\addcontentsline{toc}{chapter}{MyChapter}

\lipsum[1-7]  % Add a page and a half of dummy text

\end{document}

This gives a contents without numbering:

contents example

... along with a chapter title without numbering:

chapter example

... and the header is now also without numbering: header example

egreg
  • 1,121,712
cslstr
  • 6,545
  • Worked. However, I had similar problems with KOMA-Script where this approach does not work. A solution for this case can be found here. – fr3d-5 Mar 09 '14 at 15:19
  • I changed the code to work with scrreprt. As I had mentioned previously, the solution is somewhat specific to the document class and options you might have enabled, like twopage. – cslstr Mar 09 '14 at 15:21