Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to display the chapter name with the \chapter* command to the left side of the header. This is one example of what I tried:

    \documentclass[12pt,a4paper,oneside]{book}
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \lhead{}
    \chead{}
    \rhead{\fancyplain{}{\textit{\leftmark}}}

    \begin{document}
    \chapter*{\centerline{Chapter Name}}

    \end{document}

How can I do this?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

Try

\chapter*{chapter name}
\markboth{chapter name}{}

And consider using titlesec package rather using \centerline as a visual formatting approach.

share|improve this answer
1  
Ok, using this command in the header appears "Chapter0. Chapter Name". I would like having only the chapter name, without "Chapter0". –  Ford Prefect Jan 8 '13 at 20:31
2  
@FordPrefect sorry. comes from not thinking ... nice to get 3 votes for a wrong solution. People give too much credit :-) –  Frank Mittelbach Jan 8 '13 at 20:55

Setting the headers with fancyhdr usually requires changing the \chaptermark and \sectionmark commands; you don't need the latter, as you want only the chapter title in the header.

Here's an example in which I show two methods. A simple \chapter command in the \frontmatter will not give a numbering and correctly set the header. If you want the unnumbered chapter in the \mainmatter, then you can use an explicit \chaptermark command.

\documentclass[12pt,a4paper,oneside]{book}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\fancyhf{} % clear the headers
\fancyhead[R]{%
   % We want italics
   \itshape
   % The chapter number only if it's greater than 0
   \ifnum\value{chapter}>0 \chaptername\ \thechapter. \fi
   % The chapter title
   \leftmark}
\fancyfoot[C]{\thepage}

\fancypagestyle{plain}{
  \renewcommand{\headrulewidth}{0pt}
  \fancyhf{}
  \fancyfoot[C]{\thepage}
}

\setlength{\headheight}{14.5pt}

\usepackage{kantlipsum} % for the mock text

\begin{document}

\frontmatter

\chapter{Introduction}

\kant

\mainmatter

\chapter*{Another introduction}
\chaptermark{Another introduction}

\kant

\chapter{Title}

\kant

\end{document}

Note that if you plan to use appendices, one of the commands should be modified:

\makeatletter
\fancyhead[R]{%
   % We want italics
   \itshape
   % The chapter number only if it's greater than 0
   \ifnum\value{chapter}>0 \@chapapp\ \thechapter. \fi
   % The chapter title
   \leftmark}
\makeatother

(Unfortunately, the command that holds either \chaptername or \appendixname is an internal one, so one has to do some tricks to access it.)

Note also the \setlength{\headheight}{14.5pt} to give the header the room it needs.

For centering the chapter title it's better to use the methods of the titlesec or sectsty packages than doing explicit formatting.

Note This assumes that the unnumbered chapter is in the \frontmatter (any number of them, actually) or there is only one at the beginning of the \mainmatter. For other cases a more complex approach should be taken.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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