0

I use fancyhdr to modify the header and footer of a book written with the amsbook class. I want the left header on even pages to contain the name of the current chapter, but can't figure out how to do this. The obvious guess to use \chaptername does not work (MWE below)

\documentclass{amsbook}
\usepackage{fancyhdr,lipsum}

\fancyhead{}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[LE]{CHAPTER~\thechapter~\chaptername}

\begin{document}

\pagestyle{fancy}

\chapter{First chapter}
\section{First section}
\lipsum
\end{document}

does not work.

4
  • 1
    \chaptername (under English) just contains the word Chapter, you probably want to use \leftmark or \rightmark as that is what \chapter{title} normally writes title to.
    – daleif
    Commented Jul 26, 2021 at 13:42
  • Yes, I could use leftmark. Leftmark does almost what I want to do, but I don't want a punctuation after the chapter number. So instead of CHAPTER 1. TITLE, I would like to have CHAPTER 1 TITLE.
    – 220284
    Commented Jul 26, 2021 at 13:45
  • In that case please make sure to provide a full but minimal example such that others have something to work with without having to add stuff just to test your code.
    – daleif
    Commented Jul 26, 2021 at 13:59
  • @daleif Ok, did that.
    – 220284
    Commented Jul 26, 2021 at 14:58

1 Answer 1

1

You should redefine \chaptermark to get the desired formatting. The fancyhdr documentation has several examples of this.

For this case, the following code would probably do what you want.

\fancyhead[LE]{\leftmark}
\newcommand{\mychaptertitle}[1]{\MakeUppercase{\chaptername~\thechapter~#1}}
\renewcommand{\chaptermark}[1]{\markboth{\mychaptertitle{#1}}{\mychaptertitle{#1}}}
1
  • That's excellent Pieter, many thanks!
    – 220284
    Commented Jul 26, 2021 at 15:12

You must log in to answer this question.

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