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?

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Jan 16 '15 at 11:08
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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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