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}
Wings
  • 131

2 Answers2

5

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}
Werner
  • 603,163
2

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]  
Wings
  • 131
  • So how is this different than my proposed solution? – Werner Nov 15 '18 at 01:17
  • In my solution, the command looks very easy to understand for novice users like me. It is much easier. – Wings Nov 15 '18 at 05: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 '18 at 05:22
  • I guess I must thank you, first. Your solution that works,... absolutely! However, I am looking for simple solutions. – Wings Nov 15 '18 at 05: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 '18 at 05:34
  • Yes, and I have updated my MWE... as you pointed out. Thanks again. – Wings Nov 15 '18 at 05:43