# How to place a same image on the very top of every page of a section

I would like to place a same image on the very top of every page belonging to the same section of the document. Is that possible?

See the example below, where the figure is a PNG one:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{babel}
\begin{document}

\section*{Section A}

\includegraphics{fig1}

A lot of contents spanning several pages.

I would like to have the figure above repeated at the top of each page
of Section A.

\section*{Section B}

\includegraphics{fig2}

A lot of contents spanning several pages.

I would like to have the figure above repeated at the top of each page
of Section B.

\end{document}

SUPPLEMENT

I have tried a different approach, by using fancyhdr package. (Please, see code below.) However, I am getting the problems that I show below. Any ideas?

PROBLEM 1

On the first page of the document.

PROBLEM 2

When returning to the plain style:

USED PICTURE

CODE I AM USING

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{graphicx}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{lipsum}

\fancypagestyle{logo}{
\fancyhf{}
}

\makeatother

\usepackage{babel}
\begin{document}
\pagestyle{logo}

\lipsum[1-8]

\includegraphics[scale=0.5]{/tmp/x}

\pagestyle{plain}

\lipsum[1-7]
\end{document}
• @KJO Thanks! Just added a minimal example. – Paul Smith May 31 at 21:43
• @KJO Thanks! So let me ask the following: (1) Can your solution be adapted to emulate my second example, but without the problems I mentioned?; (2) Can one turn off inserting anything on the top of the page for certain and specified sections? – Paul Smith Jun 1 at 12:23

Ok have been playing with this and its just about a very minimal / basic solution. Version 1 (see later edits for V2 and V3 :-)

I had to borrow bits and pieces from several answers to get stable enough results however in Version 1 (based on section numbers) I broke one of your supplied requirements (the no numbers star in chapter/section definition)

I am working with each section having a number (which may not always be the case) and is contrary to your suppression to zero.

I am not allowing for right or left as such (I am assuming only right top corner) and if you want a section to be blank then you need a clear/blank image for the section. (However these points are addressed in version 2 later)

\documentclass[english,draft]{article}% use draft to observe numbering then remove for print run
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{babel}

\usepackage{calc}
\usepackage{everypage}
\renewcommand{\thesection}{\number\value{section}}%
\newlength\Hoffset \Hoffset 0.0cm
\newlength\Voffset \Voffset 0.5cm
\smash{\hspace{\oddsidemargin}\hspace{\textwidth}\hspace{\Hoffset}%
{%
\includegraphics[height=3cm,width=4cm]{example\thesection}
}         }             }

\usepackage{lipsum} %remove after demo

\begin{document}

\section{Section A}% NOTe the star version will zero chapter counter thus blocking an image number

\includegraphics[width=12cm,height=9cm]{example\thesection}

A lot of contents spanning several pages.
\newline
I would like to have the figure above repeated at the top of each page
of Section A.
\lipsum[1-7]

\newpage % newpage is needed to split count from old section to new section
\section{Section B}
\includegraphics[width=12cm,height=9cm]{example\thesection}

A lot of contents spanning several pages.

I would like to have the figure above repeated at the top of each page
of Section B.
\lipsum[1-6]
\end{document}

## Version 2

The question was expanded to include some on/off control of headers and I was not happy with initial tying into section numbers (that might be suppressed). For version 2, I used fancy header based on the amended Question. However do note there are still some weaknesses in this method.

I have forced the normal fancy and plain header to be identical but the system will still treat chapter pages (and some others) as different so with this approach I can not assign logos to the first page of the chapter (not a problem if that has the full image and later pages just echo it.) There are many more ways we could expand our use of fancyhdr however since we are distorting the normal usage, the next level of customisation would best be achieved by say switching to a more dedicated overlay per page using dedicated on off markers.

\documentclass[english]{book} % I suspect LyX may be adding to and shuffling this preamble I set to book to show dual sided  abilities
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}

%--- just for the examples
\usepackage{mwe}
\usepackage{lipsum}
%---

\usepackage{fancyhdr,floatpag}
% globally remove fancy style rules since \pagestyle{plain} for chapters etc. = no header, and footer only contains page number centered
% set fancy to be similar default just have the page number
\fancyhf{}
\fancyfoot[C]{\textbf{\thepage}} % common method to use simple Bottom centre page numbers
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\textbf{\thepage}} % except the center
\renewcommand{\footrulewidth}{0pt}}

\floatpagestyle{plain}% Page style for float-pages
%\usepackage[style=plain]{clrdblpg} this option will ensure verso pages are also plain

\fancypagestyle{logo}{%change LO,RE v RO,LE for opposite side or just C for centre
\fancyhf{}
\fancyfoot[C]{\textbf{\thepage}} % except the center
\renewcommand{\footrulewidth}{0pt}}

%the following is a lyx construct so although not used I am leaving in place
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\makeatother

\begin{document}
\pagenumbering{arabic} % reset page number counter
\thispagestyle{logo}
\chapter{One}
\pagestyle{logo} %  If you want a fancy layout on a page containing \maketitle you must issue a \thispagestyle{fancy} after the \maketitle.
%\pagestyle{plain} % uncoment to reset
%
\lipsum[1-9]
\section{first still with logo}
\noindent\includegraphics[width=1.0\textwidth]{x.jpg}\newline\par\lipsum[10-12]
%
\newpage \pagestyle {plain} % if header style change is required it can usually be combined with \newpage at the same time
%\pagestyle{plain}
\noindent\begin{figure}[t]
\centering
\includegraphics[width=1.0\textwidth]{x.jpg}%
\caption{Caption}
\end{figure}
Page style Plain'' default usually has only page number at bottom centre but no header.\newline\par
\lipsum[1-7]

\end{document}

## Version 3 - not related to sections (uses current page for start stop)

This is one of many ways a watermark can be applied based on a very basic Bg NoBg (More complex methods of selecting pages are possible) so for more specific control choices read the background manual.
In this example I exclude "logo" on first and last page and use 50% opacity on all others.

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\usepackage{graphicx}

placement=top,
opacity=0.5]{background}
\backgroundsetup{contents={\includegraphics[scale=0.04]{./tmp/x}}}

\makeatletter %<=====  Not needed here by TeX but as a LyX construct I am retaining for LyX users
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\makeatother %<=====  Not needed here by TeX but as a LyX construct I am retaining for LyX users

\usepackage{babel}

\pagestyle{fancy}% Change as you wish
\fancypagestyle{plain}{ % Change as you wish
\fancyhf{}
\fancyfoot[C]{\thepage}
}

% for example use only
\usepackage{lipsum}

\begin{document}
\pagestyle{plain}
\NoBgThispage
Hello World my name is X

\noindent\includegraphics[scale=0.7]{./tmp/x}
\lipsum[1-8]