3

I'm currently using fancy for my page header everything is Ok but I just still need to also add the number of the chapter to the header.

This is my code:

\documentclass[12pt]{book} 
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{parskip}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[top=3cm,bottom=1.5cm,left=3cm,right=2cm,asymmetric]{geometry}
\usepackage{booktabs,dcolumn}
\usepackage[figureposition=bottom]{caption}
\usepackage{fancyhdr}
\numberwithin{equation}{chapter}
\fancyhf{}
\fancyhead[C]{\leftmark}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\chaptermark}[1]{
 \markboth{#1}{}}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand*{\mc}[1]{\multicolumn{1}{c}{#1}}
\newcommand*{\mcTwo}[1]{\multicolumn{2}{c}{#1}}
\linespread{1.8}
\setlength\parindent{0pt}
\begin{document} 

Thanks!

2
  • Please be a bit more specific as to where (left, right, center?) and in which format you want the chapter number to appear.
    – Mico
    Commented Jun 7, 2013 at 21:01
  • @Mico everything in my code is so far ok. The name of the chapter is in the middle and the number of the page changes from left to right. I just need the number of the chapter to appear.
    – abdu
    Commented Jun 7, 2013 at 21:20

1 Answer 1

4

Here's how you can do it. I left only what's strictly necessary for the example (of course you don't need kantlipsum).

Note the setting of \headheight and remember to issue \backmatter before the bibliography.

\documentclass[12pt]{book}
\usepackage[T1]{fontenc} % recommended for German
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}

\usepackage{fancyhdr}
\pagestyle{fancy}

\fancyhf{}
\fancyhead[C]{\ifnum\value{chapter}>0 \thechapter.\ \fi\leftmark}
\fancyhead[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\setlength{\headheight}{14.5pt} % very important!

\usepackage{kantlipsum} % just for this example

\begin{document}
\mainmatter
\chapter{Some title}
\kant[1-15]
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .