1

I am trying to configure a book using fancyhdr. I want the book name centred on even pages, and the chapter name centred on odd pages. That is all very well, except for two simple questions:

  1. Is there a variable which stands for the book name?
  2. Is there a variable which stands for the chapter name?

I may be stupid, but I can't seem to find the names of these obvious variables.

I could of course hardwire this in the preamble and at the beginning of chapters, for my own variables, but this strikes me as a horrible kludge.

1 Answers1

1

As far as I am aware there is no variable that contains the book's title. You will have to create one yourself. I think that the MWE below gives you what I think you are after.

% titleprob.tex  SE 624386

\documentclass{book} \usepackage{lipsum} \setlength{\textheight}{0.4\textheight}

\newcommand{\booktitle}{THE BOOK} % the title of the book \usepackage{fancyhdr} % your pagestyle \pagestyle{fancy} \fancyhead[CE]{\booktitle} \fancyhead[LE,RE]{} \fancyhead[CO]{\leftmark} \fancyhead[LO,RO]{} \fancyfoot[C]{\thepage}

\begin{document} \title{\booktitle} \author{A N Other}

\maketitle

\chapter{Chapter}

Some text. the book's title is ``\booktitle''. \lipsum[1-6]

\end{document}

You might want to use different text for the actual title of the book and a another (shortened) version for the page headings.

CarLaTeX
  • 62,716
Peter Wilson
  • 28,066