[Tex/LaTex] Getting chapter and section in \fancyhead

chaptersfancyhdrsectioning

I am having a bit of a heard time getting \fancyhead to give me the out put I want. I'd like to have a header that includes Chapter X: THIS IS THE SECTION (italicized like the default). I can get it to do chapter centred and section in the right but It'd be cool if they could be on the right together. I ahve a feeling I can do this with a \renewcommand but I can't find the combination that works. Alternatively if anyone knows how to combine \thechapter and \rightmark within \fancyhead that would help too.

Currently I'm using:

\fancyhead[R]{\textit{ \nouppercase{\thechapter}} }

in a multi-chapter report document with \pagestyle{fancy} in the preamble.

This gives me "Chapter 2" in the header but I would like "Chapter 2: Experimental Methods"

Thanks in advance and I'm still pretty new at this so let me know if you need more info.

Best Answer

Usually only information about either the current chapter or section goes in a header, as they need space. The most common way is to have chapter information on left pages (even) and section information on right pages (odd). If your thesis is one-sided, then choose chapters

A possible way out is to use two lines in the header, but be careful because it might get too heavy.

\documentclass{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[R]{\footnotesize
  \begin{tabular}[b]{@{}r@{}}
    \nouppercase{\leftmark}\\[3pt]
    \nouppercase{\rightmark}
  \end{tabular}%
}
\setlength{\headheight}{22pt} % check the log to be sure what this length should be

\usepackage{lipsum} % just for the example

\begin{document}
\chapter{This is my first chapter}
\section{With my section}
\lipsum

\end{document}

The value for \headheight can be determined by fancyhdr itself: first leave the line commented out; then check in the .log file, where the required value is shown.

enter image description here