2

Hello I am new to LaTeX and I am having a problem using fancyhdr package I want the header to only show the chapter number and chapter name in the center of the page and I am having issues doing that the code I am using is

\rhead{}
\chead{}
\lhead{**XXXXX**}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

where the XXXXX is suppose to be changed to a specific code i tried using \thechapter . \chaptername hoping it would show something like 'Chapter 2.Theoratical Background' but it only shows the number and nothing else I am probably making a mistake with the syntax can someone please help me out. Thank you

2
  • \chaptername is Chapter usually, but not the title of the chapter. For more on this, it requires the knowledge of the documentclass
    – user31729
    Commented Jul 22, 2015 at 22:43
  • \documentclass[12pt, a4paper, twoside]{Report} this is my document class sorry if I am a noob I am new to LaTeX Commented Jul 22, 2015 at 22:45

1 Answer 1

2

I am not sure this is really what the the OP wants to have, but the chapter title is contained in \leftmark (if I remember correctly)

\documentclass[12pt,a4paper,twoside]{report}

\usepackage{fancyhdr}
\usepackage[head=1.5cm]{geometry}


\rhead{}
\chead{}
\lhead{\leftmark}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}


\usepackage{blindtext}

\pagestyle{fancy}



\begin{document}

\chapter{My first Chapter}
\blindtext[10]

\end{document}
5
  • 1
    omg thank you so much this worked. i love you i wish i could send you a cookie through this wonderful site with this awesome community Commented Jul 22, 2015 at 22:55
  • 2
    @BakhtawarKhattak -- Upvoting is the preferred way here to say "thank you" to users who helped you. You might also accept an answer that solved your issue best (just in case you get another answer), which does not mean that you can't upvote Christian's answer if it remains the only one.
    – Ruben
    Commented Jul 23, 2015 at 1:21
  • @Ruben I think stackexchange should switch to sending cookies for showing appreciation. Commented Jul 23, 2015 at 8:26
  • @BakhtawarKhattak -- I think so, too. Yet we still have the reputation system. But please let me know if you start a poll to change it. I'll join or at least support your campaign.
    – Ruben
    Commented Jul 23, 2015 at 10:59
  • lol I am new to this website how do u upvote someone? I would like to upvote the crap out of this amazing helpful person :D Commented Jul 24, 2015 at 14:30

You must log in to answer this question.

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