Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a report using the scrreprt KOMA class. Currently my header looks like this:

Current header

Introduction is the chapter name.

I would like to make two changes to it:

  1. I would like to have the chapter name on the left of the header and the section name on the right. I have already tried \lhead{\thechapter} but this only gives me the chapter number, not the title.
  2. How can I change the font used in the header to match the one in the figure? It looks like it's the default font for section titles in the KOMA classes, but I'm not 100% sure. New header font
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Redefine \chaptermark/ \sectionmark to display sectioning number plus title, and redefine \lhead/\rhead to use \leftmark/\rightmark plus the formatting instructions \sffamily\bfseries.

\documentclass{scrreprt}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand*{\chaptermark}[1]{\markboth{\thechapter.~~#1}{}}
\renewcommand*{\sectionmark}[1]{\markright{\thesection.~~#1}}

\lhead{\sffamily\bfseries \leftmark}
\rhead{\sffamily\bfseries \rightmark}

\usepackage{lipsum}

\begin{document}

\chapter{foo}

\section{foobar}

\lipsum[1-12]

\end{document}​

enter image description here

share|improve this answer
    
Thank you, this worked perfectly! However I have a couple of questions about your code: 1) what is the difference between \markboth and \markright? 2) What is the meaning of \leftmark and \rightmark? –  user1301428 Feb 2 '13 at 16:45
    
@user1301428 See section 9 of the fancyhdr manual for a good explanation. –  lockstep Feb 2 '13 at 16:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.