4

I want to set a header/footer which shows:

  1. Chapter name on odd numbered page;
  2. Author name (different authors in different chapters) in even numbered pages;
  3. Page number in central footer.

Any help would be appreciated.
Thanks.

Updated:
A MWE is given as

\documentclass{book}  
\usepackage{blindtext}  
\usepackage{fancyhdr}  
\pagestyle{fancy}  
\begin{document}

\chapter{Wombat}  
Author Aa, And Author Bb  
\blindtext[5]  
\section{tabmow}  
\blindtext[5]  

\chapter{Capybara}  
Author Cc, And Author Dd  
\blindtext[5]  
\section{arabypac}  
\blindtext[5]  

\end{document}
2
  • So you don't want the \section header to appear at all?
    – Werner
    Nov 13, 2018 at 19:36
  • Yes, for now....
    – Wings
    Nov 13, 2018 at 19:37

2 Answers 2

3

The following introduces \chapterauthor to set and store the authors associated with your \chapters. This allows you to use the stored details within the \fancyhead[LE] part.

enter image description here

\documentclass{book}

\usepackage{blindtext}
\usepackage{fancyhdr}

\makeatletter
\newcommand{\chapterauthor}[1]{%
  \def\@chapterauthor{#1}% Store chapter authors
  {\bfseries #1}% Set chapter authors
  \par
}

\fancyhf{}% Clear header/footer
\fancyhead[RO]{\leftmark}% Chapter details in book
\fancyhead[LE]{\@chapterauthor}% Stored \chapterauthor details
\fancyfoot[C]{\thepage}
%\renewcommand{\headrulewidth}{0pt}% Remove header rule
%\renewcommand{\footrulewidth}{0pt}% Remove footer rule (default)
\pagestyle{fancy}
\makeatother

\begin{document}

\chapter{Wombat}
\chapterauthor{Author Aa, And Author Bb}
\blindtext[5]
\section{tabmow}
\blindtext[5]

\chapter{Capybara}
\chapterauthor{Author Cc, And Author Dd}
\blindtext[5]
\section{arabypac}
\blindtext[5]

\chapter*{Mara}
\chapterauthor{}% No chapter author
\blindtext[5]
\section{aram}
\blindtext[5]

\end{document}
1

After reading the documentation for fancyhdr package, I got the work done as below:

\documentclass[twoside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{\thechapter.\ #1}{}}

\newcommand{\TheAuthor}{} % As given in documentation of **fancyhdr**
\newcommand{\Author}[1]{\renewcommand{\TheAuthor}{#1}}
\fancyhead{} % clear all fields
\fancyhead[CO]{\slshape \leftmark}
\fancyhead[CE]{\slshape \TheAuthor}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.6pt}

\begin{document}
\tableofcontents{}
\mainmatter % Begin numeric (1,2,3...) page numbering
\pagestyle{fancy} % Return the page headers back to the "fancy" style
\input{./Chap1/Chap1} % Include the chapters as separate files from the Chapters folder (first <Chap1> is folder and second one is file Chap1.tex)
\fancyhead{}
\end{document}

And my Chap1.tex is:

% Chapter 1  
\chapter{Introduction}  
\Author{PQR}  
\section{Introduction}  
\lipsum[1-22]  
\section{Background}  
\lipsum[1-22]  
\subsection{History}  
\lipsum[1-22]  
6
  • So how is this different than my proposed solution?
    – Werner
    Nov 15, 2018 at 1:17
  • In my solution, the command looks very easy to understand for novice users like me. It is much easier.
    – Wings
    Nov 15, 2018 at 5:11
  • What makes it easier to understand? You're using \documentclass options that aren't needed, and include text via an external file. What I'm getting at is that you should consider upvoting contributions and/or accept answers as the solution to your problem (see How do you accept an answer?) rather than adding content that replicates other answers. What you think might be easier to understand is purely subjective, don't you think?
    – Werner
    Nov 15, 2018 at 5:22
  • I guess I must thank you, first. Your solution that works,... absolutely! However, I am looking for simple solutions.
    – Wings
    Nov 15, 2018 at 5:27
  • I assume what you consider non-simple (or difficult) is the use of @ symbols in definitions and the use of \makeatletter...\makeatother.
    – Werner
    Nov 15, 2018 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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