5

To add image in the header , I have written the code, basically the pagestyle modification. Now , just for a trial , I first modified only my plain page style. After the image gets inserted in the header , I get a horizontal line, How do I remove it?

Here is the MWE:

\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{wallpaper}  
\usepackage{fancyhdr}

\fancypagestyle{plain}{
 \fancyhf{}
 \fancyhead[C]{\includegraphics[scale=.25]{example-image-a}}
}

\begin{document}
\chapter{A Chapter}
\lipsum[4]
\section{blah blah blah}
\end{document}
8

You have to declare that you want a header line with no width:

\renewcommand{\headrulewidth}{0pt}

MWE:

\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{wallpaper}
\usepackage{fancyhdr}

\fancypagestyle{plain}{
 \fancyhf{}
 \fancyhead[C]{\includegraphics[scale=.25]{example-image-a}}
 \renewcommand{\headrulewidth}{0pt}
}

\begin{document}
\chapter{A Chapter}
\lipsum[4]
\section{blah blah blah}
\end{document} 

Output:

enter image description here

1

While Karl answered your question to the point, this is just another tikz crazy option to put some background material in only few pages:

\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}

\backgroundsetup{
pages=some,
scale=1,
opacity=1,
angle=0,
color=black,
contents={%
\begin{tikzpicture}[remember picture,overlay]
  \node[draw=green!50!blue,thick,fill=orange!30,rounded corners=1ex] at ($(current page text area.north) + (0,0in)$) {\includegraphics[scale=.25]{example-image-a}};
\end{tikzpicture}%
}
}


\begin{document}
\chapter{A Chapter}
\BgThispage
\lipsum[4]
\section{blah blah blah}
\end{document} 

enter image description here

Another variant of above snippet will be

\backgroundsetup{
pages=some,
scale=1,
opacity=1,
angle=0,
color=black,
position={0.55\textwidth,-0.1\textheight},    %%% this and 
contents={%
\includegraphics[scale=.25]{example-image-a}   %%% this also would work
}
}

In this case, you won't be needing

\usetikzlibrary{calc}
\usepackage{tikzpagenodes}

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.