Sie sind hier

Redefine \headmark to get a centre chaptername

Hello guys,
I am writing a book using koma script and am trying to set the page header. I want the the chaper number to be on the left and chapter name in the centre. Something like this

Chapter 1 \centre Introduction

However if i do this

\usepackage[automark]{scrpage2}
\clearscrheadings
\chead{\headmark}
\cfoot{\pagemark}
\pagestyle{scrheadings}

it centres the whole thing. How can i refer to the Chapter name and number separately?

Thanks,
Rajil

Bild von Markus Kohm

LaTeX uses the mark mechanism of TeX to set the running head. LaTeX only has a left and a right mark. One of these is used for the chapters, one for the sections. So there's no room for splitting the chapters in number an title.

But you may redefine \chaptermarkformat to add a distance, something like (untestet):

\renewcommand*{\chaptermarkformat}{\chapapp~\thechapter\autodot\hfill}
\chead{\headmark\hfill}

For chapters (and only for these not for section or lower levels!) you may also try (untested):

\renewcommand*{\chaptermarkformat}{}
\lehead{\chapapp~\thechapter\autodot}
\chead{\headmark}

If this doesn't work please show a complete but minimal example of what you are doing.

Thanks a lot. This is exactly what i wanted and has worked very well.
There is another issue I have, it would be great if you can suggest something.

I know, there is a option to print a title page before the start of the chapter. However, is it possible to have the Chapter name on a blank page before the start of the chapter. This is how it show look

------------------------------------------------------------------------------
\center Chapter 1
\center Literature review

\newpage{}

This chapter deals with the literature review blah blah blah....
----------------------------------------------------------------------------

Thus i want to move the chapter name and number to a page before the start of the actual text. Is it possible?

Bild von Markus Kohm

\part works in the kind you are describing, so maybe you are sarching for parts. But if you realy wanted chapter to behave like this, you may use:

\documentclass[chapterprefix]{scrbook}

\addtokomafont{chapter}{% X
  \renewcommand*{\raggedsection}{\centering}%
}% Y

\renewcommand*{\chapterheadendvskip}{\newpage}

\begin{document}
\chapter{Chapter}
\section{Section}
\clearpage\null\clearpage\null
\end{document}

If not only chapters but also sections, subsections etc. should be centered, you may comment out the two lines that are marked with X and Y.

BTW: center is an environment (using trivlist, a kind of list environment) that should be ended. The corresponding switch would be \centering as shown in the complete example above.

Thanks for your help. Well, you guessed it right it is indeed that I need a Part type functionality but instead of parts I need to replace it with chapters.

The code you gave me works well, but it does not centre the Chapter description in the middle of the page. Is it possible to place the chapter description in the same place as \part. Or maybe it is easier to modify the \part functionality to print chapter numbers?

I forgot to mention that the chapter page i need is of the form

Chapter 1
Description

rather than
Chapter 1 Description
as your code makes. Is that possible?

Thanks.

Bild von Markus Kohm

My example gives two centered lines like you wanted. Please try exactly my code and do not omit any class option I've used.

You may change \chapterheadstartvskip to move the chapter head down. E.g. try:

\documentclass[chapterprefix]{scrbook}

\addtokomafont{chapter}{% X
  \renewcommand*{\raggedsection}{\centering}%
}% Y

\renewcommand*{\chapterpagestyle}{empty}
\renewcommand*{\chapterheadstartvskip}{\vfill}
\renewcommand*{\chapterheadendvskip}{\vfill\null\newpage}

\begin{document}
\chapter{Chaptertitle}
\section{Sectiontitle}
\clearpage\null\clearpage\null
\end{document}

BTW: If you'll get a warning:

LaTeX Warning: Unused global option(s):
    [chapterprefix].

You have very, very old KOMA-Script that should be updated.

oops! I forgot to add chapterprefix in the preamble. Now it is looking great. Thanks a lot for your help!!!

Comments for "Redefine \headmark to get a centre chaptername" abonnieren