I want to include a small logo on particular pages in a large document, in the left hand side of the footer. The way to do this seems to be with fancyhdr's alternate-able styles.
I've gotten close to what I need, but I have 2 questions:
The header style for the new logo pages is a direct copy of the IHA-fancy-style, but I have been setting the
\lheadand\rheadon a chapter by chapter basis, and changing the text style. How can I change my current set up to apply the headers to the new pagestyle too?How should I be positioning my
thispagestylecommand, when an image is set to use a full page with the[p]parameter of the figure environment? It wants to apply to the page before or after it seems.
I hope this is clear enough, I'm struggling to explain what I'm trying to do in my own head, so I've no idea if this makes sense now!
Here's a MWE of what I have so far (note there is a specific filepath for the logo if people try to re-run the code).
You should see from this output PDF, that the page with the Logo on, is lacking the headers from the rest of the chapter/document, and isn't the page with the figure on.
\documentclass[a4paper, oneside, 11pt]{report}
\usepackage[left=4cm, right=2cm, top=1.5cm, bottom=2.5cm]{geometry}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{fancyhdr}
\headsep 25pt
\headheight 20pt
\setlength{\topmargin}{0pt}
\setlength{\textheight}{670pt}
\fancypagestyle{IHA-fancy-style}{%
\fancyhf{}
\fancyhead[LE,RO]{\slshape \leftmark}
\fancyfoot[LE,RO]{\thepage\ } % Custom footer
\renewcommand{\headrulewidth}{0.4pt}% Line at the header visible
\renewcommand{\footrulewidth}{0.4pt}% Line at the footer visible
}
\fancypagestyle{augment}{%
\fancyhf{}
\fancyhead[LE,RO]{\slshape \leftmark}
\fancyfoot[R]{\thepage\ } % Custom footer
\fancyfoot[L]{\raisebox{-0.1cm}{\includegraphics[height=0.5cm, clip, trim={100 100 100 100}]{/path/to/mylogo.png}}
}
\renewcommand{\headrulewidth}{0.4pt}% Line at the header visible
\renewcommand{\footrulewidth}{0.4pt}% Line at the footer visible
}
\begin{document}
\pagestyle{IHA-fancy-style}
\lhead{\textsf{Chapter 1}}
\rhead{\textsf{My First Chapter}}
\lipsum[1]
\newpage
\lipsum[2]
\thispagestyle{augment}
\begin{figure}[p]
\includegraphics[width=\textwidth, height=\textwidth, clip, trim={0 0 0 0}, draft]{/path/to/dummy/image.png}
\end{figure}
\newpage
\lipsum[3]
\end{document}
EDIT
The answer below does solve the problem for the minimal case I posted, but raised other issues when I brought it in to the full document.
2 issues mainly:
Firstly, I can typeset the document correctly once, but when it comes to a second time in order to populate the ToC, I'm now getting this error:
Undefined control sequence. # Pointing to my document.toc file
\f@ncycolh ->\sffamily \myleftmark # I added sffamily to the header in the answer below, but its a valid command
\strut
which points to this line in the ToC file, though I can't see that there's anything wrong with it specifically
\contentsline {subsection}{\numberline {3.3.2}Harvesting}{78}{subsection.3.3.2}
Secondly, when I include my Appendix Chapters (even with a \pagetyle{plain}) I get this error:
Use of \reserved@a doesn't match its definition.
\new@ifnextchar ...eseverd@d = #1\def \reserved@a {
#2}\def\reserved@vb {#3}\f...
l.685 ...{Chapter \ref{appendix1}}
\ref{}in the chapter title, which presumably confused the numbering that it was trying to put in to the header, so I've just done away with it for the time being. – Joe Healey Jun 26 '18 at 14:39