0

I am currently trying to set up a document for a project report. I am having difficulties with the headers and footers.

I would like to have the footer on every page and the footer should look like the picture shown below.

Footer using the fancyhdr package

To achieve this footer, I am currently using the fancyhdr package with the fancy pagestyle as shown in the code snippet below.

\pagestyle{fancy}
%%  FOOTER
\fancyfoot[C]{\small \thepage} % PAGE NUMBER
\fancyfoot[L]{\small ENEL895 \\ Version 1.0} % PAPER CODE AND VERSION
\fancyfoot[R]{\small \today} % TODAY'S DATE
\renewcommand{\footrulewidth}{1pt} % FOOTER RULE LINE

The problem I am encountering for the footer is for the TOC (I have put \thispagestyle{fancy} next to the TOC and all chapters to try and get the headers and footers). The TOC is spread across 2 pages, the first page only has the page number for the footer, whereas the second page has the correct header and footer.

The TOC header and footer for both pages should look like the picture shown below. TOC Header and Footer

The header is where it gets complicated. For the header, I require all the front matter (everything before Chapter 1) to have the section title on the right side of the header and the lettercase should be exactly the same as the title case (i.e. not capitalised and not italicised). The TOC Header (shown above) is an example of what I mean. As for the chapters, I would like the first chapter page to have no header and only the footer specified above. For the remaining pages of the chapter, I would like the chapter on the left (Format: Chapter # - Chapter Name) and the section on the right (Format: # Section Name) of the header.

The header and footer for the first page of the chapter should look like the image shown below. Header and Footer for the First Page of the Chapter

The header and footer for the remaining pages of the chapter should look like the picture shown below (Ignore the fact that I have shown the first page of the chapter).

Ignore the Chapter 1 Introduction (this is the remaining pages of the chapter)

Another difficulty I have encountered with the header is that the appendix header has Chapter A instead of Appendix A. I would like this to be on the left hand side of the header and the first page of the appendix should have no header (just like the chapters).

Appendix Header Difficulty:

Chapter instead of Appendix

Here is a MWE of my document so far (sorry it has a lot of comments and the output is not the same as the images shown in this thread).

\documentclass[12pt,a4paper]{report}

%----------------------------------------------------------------------------------------
%   PACKAGES
%----------------------------------------------------------------------------------------
%%  PAGE MARGINS
\usepackage[margin=1in]{geometry}

%%  RANDOM LOREM IPSUM TEXT TO FILL
\usepackage{blindtext}

%%  TOC BABEL
\usepackage[english]{babel}

%%  HYPERLINKING
\usepackage[colorlinks=true]{hyperref}
\hypersetup{%
    colorlinks,
    linkcolor={red!50!black},
    citecolor={blue!50!black},
    urlcolor={blue!80!black}
}

%%  HEADERS AND FOOTERS
\usepackage{fancyhdr}

%%  HEADING TITLES (TITLE SECTIONS)
\usepackage{titlesec}

%%  MAKES THE TOC WORK BETTER IMO (NOT SURE HOW)
\usepackage{tocloft}

%%  INCLUDE PDF PAGES
\usepackage{pdfpages}

%----------------------------------------------------------------------------------------
%   PAGE STYLE - HEADERS AND FOOTERS SETUP
%----------------------------------------------------------------------------------------
\pagestyle{fancy}

%%  HEADER
\fancyhead[L]{\leftmark} % SECTION NAME-FIRST SECTION/PREVIOUS SECTION

\fancyhead[R]{\nouppercase{\rightmark}} % CHAPTER NAME

%--------------------------------------------------------------------------

%%  FOOTER
\fancyfoot[C]{\small \thepage} % PAGE NUMBER

\fancyfoot[L]{\small ENEL895 \\ Version 1.0} % PAPER CODE AND VERSION

\fancyfoot[R]{\small \today} % TODAY'S DATE

\renewcommand{\footrulewidth}{1pt} % FOOTER RULE LINE

%--------------------------------------------------------------------------

%----------------------------------------------------------------------------------------
%   REDEFINING CHAPTER AND SECTION (LEFT AND RIGHT MARKS) TO BE THE     %   CHAPTER & SECTION NAMES AND NOT CAPITALISED.
%----------------------------------------------------------------------------------------

%%  CHAPTER DEFINED AS RIGHT MARK (Chapter # - Chapter Name)
\renewcommand{\chaptermark}[1]{%
\markboth{}{\chaptername
\ \thechapter ~- #1}}

%%  SECTION DEFINED AS LEFT MARK (# Section Name)
\renewcommand{\sectionmark}[1]{\markboth{\thesection\ #1}{}}

%----------------------------------------------------------------------------------------
%   REDEFINE THE CHAPTER HEADING FORMAT AND VERTICAL SPACING
%----------------------------------------------------------------------------------------

%%  SIZE AND FORMAT OF CHAPTER HEADING TITLE
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

% ALTERS "BEFORE" SPACING (SECOND ARGUMENT) TO 0
\titlespacing*{\chapter}{0pt}{0pt}{20pt}

%----------------------------------------------------------------------------------------
%   EDITING THE TOC TITLE AND DOTTED LINE SEGMENTS FOR CHAPTERS
%----------------------------------------------------------------------------------------

%%  CHANGE TITLE TO "Table of Contents"
\addto\captionsenglish{% Replace "english" with the language you use
  \renewcommand{\contentsname}%
    {Table of Contents}%
}

%%  ADD DOTTED LINES FOR CHAPTERS IN TOC
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters, if you really want! 

%----------------------------------------------------------------------------------------
%   CHANGE LINE SPACING TO 1.5
%----------------------------------------------------------------------------------------

\renewcommand{\baselinestretch}{1.5}

%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
%   END OF PREAMBLE AND START OF DOCUMENT
%----------------------------------------------------------------------------------------
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------

\begin{document}

%----------------------------------------------------------------------------------------
%   PDF TITLE PAGE (NOT INCLUDED FOR MWE)
%----------------------------------------------------------------------------------------

%-----------------------------PDF PAGE---------------------------------

\pagenumbering{roman}

%----------------------------------------------------------------------------------------
%   STATEMENT OF ORIGINALITY
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Statement of Originality\markboth{}{Statement of Originality}}}
\addcontentsline{toc}{chapter}{{Statement of Originality}}
\thispagestyle{fancy}

\newpage
%----------------------------------------------------------------------------------------
%   ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Acknowledgements (optional)\markboth{}{Acknowledgements}}}
\addcontentsline{toc}{chapter}{{Acknowledgements}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   ABSTRACT
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Abstract\markboth{}{Abstract}}}
\addcontentsline{toc}{chapter}{{Abstract}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   ACRONYMS (OPTIONAL)
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Acronyms (optional)\markboth{}{Acronyms}}}
\addcontentsline{toc}{chapter}{{Acronyms}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   SYMBOLS (OPTIONAL)
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Symbols (optional)\markboth{}{Symbols}}}
\addcontentsline{toc}{chapter}{{Symbols}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\begin{center}
\hypersetup{linkcolor=black} % Make Links Black
\vspace*{-40pt}
\tableofcontents\thispagestyle{fancy}\markboth{}{Table of Contents}
\addcontentsline{toc}{chapter}{Table of Contents}
\newpage
\vspace*{-40pt}
\listoffigures\thispagestyle{fancy}\markboth{}{}
\addcontentsline{toc}{chapter}{List of Figures}
\newpage
\vspace*{-40pt}
\listoftables\thispagestyle{fancy}\markboth{}{}
\addcontentsline{toc}{chapter}{List of Tables}
\end{center}

\newpage
\pagenumbering{arabic}

%----------------------------------------------------------------------------------------
%   MAIN TEXT (CHAPTERS)
%----------------------------------------------------------------------------------------

\chapter{Introduction}
\section{Introduction}\thispagestyle{fancy}
\Blindtext
\blindtext

\chapter{Literature Review}\thispagestyle{fancy}
\section{Background/Problem}
\blindtext 
\section{Analysis..}
\Blindtext 

\Blindtext

\chapter{Methodology}\thispagestyle{fancy}
\section{Procedure}
\blindtext\\

\blindtext \\

\blindtext\\

\blindtext
\section{Simulation?}
\blindtext\\

\blindtext \\
\blindtext

\chapter{Results and Discussion}\thispagestyle{fancy}
\section{Results Verification?}
\Blindtext

\chapter{Future Developments}\thispagestyle{fancy}
\section{Recommendations for Future Work}
\blindtext\\

\blindtext

\chapter{Conclusion}\thispagestyle{fancy}
\section{Conclusion}
\blindtext

%----------------------------------------------------------------------------------------
%   APPENDIX
%----------------------------------------------------------------------------------------
\begin{appendix}

\chapter{Example 1}\thispagestyle{fancy}
\section{Testing}
\Blindtext

\chapter{Example 2}\thispagestyle{fancy}
\section{Extra}
\blindtext

\end{appendix}

%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY/REFERENCES
%----------------------------------------------------------------------------------------

%-------------------------------REFS-----------------------------------

\end{document}

Sorry this thread is so long, I just thought I should try and thoroughly explain my issues and my desired outcome. I am currently using the fancyhdr package but if you believe I should be using the KOMA Script equivalent, feel free to leave a comment on how I should use it (I have not used KOMA Script before).

Thanks.

0

If you are willing to use the memoir class (a superset of the book and report classes) then you can get the headers/footers that you want. I know it looks complicated but memoir lets you define many pagestyles and where they are to be used.

It seems to me that you want several different pagestyles; for the ToC (and presumably the LoT and LoF as well), perhaps for the title page, for chapter title pages, for general document pages, perhaps for an index or bibliography.

The following MWE provides for your pagestyles for the ToC and LoT, chapter title pages (including appendices) and general run-of-the-mill pages.

% headersprob.tex  SE 562212
\documentclass{memoir}
\usepackage{lipsum}
\usepackage{comment}

% macro for details of the footer style
\newcommand{\enelf}[1]{%
\makeevenfoot{#1}{\small \parbox[t]{1in}{ENEL895 \\ Version 1.0}}{\small \thepage}{\small \today}
\makeoddfoot{#1}{\small \parbox[t]{1in}{ENEL895 \\ Version 1.0}}{\small \thepage}{\small \today}
\makefootrule{#1}{\textwidth}{1pt}{5pt}
}

\makepagestyle{ENELfoot}
\enelf{ENELfoot}


% pagestle for the ToC
\makepagestyle{ENELtoc}
\makeevenhead{ENELtoc}{}{}{Table of Contents}
\makeoddhead{ENELtoc}{}{}{Table of Contents}
\makeheadrule{ENELtoc}{\textwidth}{1pt}
\enelf{ENELtoc}

% pagestyle of the LoT
\makepagestyle{ENELlot}
\makeevenhead{ENELlot}{}{}{List of Tables}
\makeoddhead{ENELlot}{}{}{List of Tables}
\makeheadrule{ENELlot}{\textwidth}{1pt}
\enelf{ENELlot}

% pagestyle for chapter pages
\makepagestyle{chapter}
\enelf{chapter}

% don't uppercase chapter and section titles in headers
% (regular definition uses \MakeUppercase for titles)
\makeatletter
\renewcommand*{\chaptermark}[1]{%
  \markboth{\ifnum\c@secnumdepth > \m@ne
               \if@mainmatter
                 \@chapapp\ 
                  \thechapter \ %
               \fi
             \fi
              #1}{}}

\renewcommand*{\sectionmark}[1]{%
  \markright{\ifnum\c@secnumdepth > \z@
               \thesection \ %
              \fi
              #1}}
\makeatother

% The page style for the bulk of the document
\makepagestyle{ENELmain}
\makeevenhead{ENELmain}{\leftmark}{}{\rightmark}
\makeoddhead{ENELmain}{\leftmark}{}{\rightmark}
\enelf{ENELmain}

\begin{document}
\pagestyle{ENELfoot}

\frontmatter

\pagestyle{ENELtoc}
\copypagestyle{chapter}{ENELtoc} % the first page of the ToC uses the chapter pagestyle
\tableofcontents
\clearpage

\pagestyle{ENELlot}
\copypagestyle{chapter}{ENELlot} % the first page of the LoT uses the chapter page style
\listoftables

\mainmatter

% set the general page style
\pagestyle{ENELmain}
% first page of a chapter uses the chapter page style, so set it to be just the footer
\copypagestyle{chapter}{ENELfoot}
\chapter{One}

\lipsum

\section{A section}

\begin{table}
\centering
TABULATION
\caption{A table}
\end{table}

\lipsum

\addtocontents{toc}{\newpage} % make sure the ToC is more that one page
\section{Another section}
\lipsum

\appendix

\chapter{App}

\lipsum

\section{In appendix}

\lipsum
\end{document}

Read the documentation (> texdoc memoir Chapter 7) for more information.

| improve this answer | |

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.