3

I changed my fancyhdr settings, but it doesn't look as I want to. Just look at my example below and use pdflatex. On the second side of the pdf, the headers text should be: "Chapter 1: MyChaptername"

\documentclass[a4paper,oneside,10pt]{report}
\usepackage{fancyhdr}

\fancypagestyle{myheader}{ 
    \fancyhead{} %clear all headers
    \fancyfoot{} %clear all footers
    \fancyhead[L]{\chaptername \ \thechapter: } %How to insert the Chapter names like "MyChapter"?
    \fancyhead[R]{\thepage}
    \renewcommand{\headrulewidth}{0.4pt} 
    \renewcommand{\footrulewidth}{0.0pt}    
}

\begin{document}
\pagestyle{myheader}

\chapter{MyChaptername}
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is  

\subsection{MySubsection}
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... This is some Text... 
\end{document}

Can anybody help me please?

1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Commented Jan 16, 2015 at 11:08

1 Answer 1

3

You can simply use

\fancyhead[L]{\leftmark}

and redefine \chaptermark

\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter:\ #1}{}}

MWE

\documentclass[a4paper,oneside,10pt]{report}
\usepackage{fancyhdr}

\fancypagestyle{myheader}{
    \fancyhead{} %clear all headers
    \fancyfoot{} %clear all footers
    \fancyhead[L]{\leftmark} %How to insert the Chapter names like "MyChapter"?
    \fancyhead[R]{\thepage}
    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0.0pt}
}
\pagestyle{myheader}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter:\ #1}{}}

\usepackage{lipsum} %for dummy text

\begin{document}   
\chapter{MyChaptername}
\lipsum[1-30]
\end{document} 

Output

enter image description here

3
  • Wow, that works pretty fine! Thank you! Well I didn't understand what \leftmark does and how it works.
    – Lukas
    Commented Jan 16, 2015 at 11:36
  • @Lukas You're welcome. The command \chaptermark issues a \markboth command which defines a \leftmark command with that contents. Commented Jan 16, 2015 at 11:48
  • Ok, thanks. This evening I'm gonna sign up. Then I will vote you answer up!
    – Lukas
    Commented Jan 16, 2015 at 11:58

You must log in to answer this question.

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