2

I want to use a little pdf picture as a logo in every page of my file, exactly in the top of every page, no margin on top, no margin on left and right side, how to make it?

I use below simple settings, but obviously there are margins...

\usepackage{fancyhdr}
\setlength{\headheight}{55.2pt}
\setlength{\headwidth}{\textwidth}
\fancyhead[C]{\includegraphics[height=1.53in]{logo.pdf}}
\pagestyle{fancyplain}
postit
  • 415
  • 1
    Did you try the wallpaper package? – Alex Aug 03 '14 at 09:10
  • My answer at http://tex.stackexchange.com/questions/169808/what-are-the-ways-to-position-things-absolutely-on-the-page/169831#169831 shows how to place something anywhere on a page, If you want the same thing on every page, merely change the \AddThispageHook to \AddEverypageHook. – Steven B. Segletes Aug 03 '14 at 15:20

2 Answers2

1

Use of background is a feasible way. Here \newcommand\BackGroundImage[2][1] is defined to take one argument for image and one optional argument for the width of the image.

Note: If no margin on the left and right, remove the command option [0.5].

Code

\documentclass{article}
\usepackage[showframe,hmargin=2cm,bmargin=3cm,tmargin=4.5cm,centering]{geometry}
\usepackage[]{background}
\usetikzlibrary{calc}
\usepackage{lipsum}
\thispagestyle{empty}

\newcommand\BackGroundImage[2][1]{%
\BgThispage
\backgroundsetup{
pages=all,scale=1,angle=0,position={current page.north},vshift=-1.5cm,
contents={%
\includegraphics[width=#1\paperwidth,height=3.5cm]{#2}
}}}

\begin{document}
\BackGroundImage[0.5]{example-image-A}
\lipsum[2]
\lipsum[4-10]
\clearpage
\lipsum[4-10]
\clearpage
\lipsum[4-10]
\end{document}

enter image description here

Jesse
  • 29,686
1

Not sure to understand well what you want. Here is a way of doing what I've grasped, with the titlesec.titleps packages. Using \raisebox and defining a new page style is enough. I suppose it can be adapted to fancyhdr. I aloso loaded the geometry package, with option showframe to visually check the details:

    \documentclass[12pt, a4paper, twoside]{book}%

    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage[x11names]{xcolor}
    \usepackage{graphicx} 
    \usepackage[showframe, top = 2in, nomarginpar]{geometry}
    \usepackage[pagestyles]{titlesec}
    \usepackage{lipsum}

    \newpagestyle{mine}{%
    \sethead[\thepage][{\raisebox{\dimexpr\headheight + \topmargin + \voffset + 1in-1.53in\relax}[0pt][0pt]{\includegraphics[height = 1.53in]{euclid-1945}}}][]
    {}{{\raisebox{\dimexpr\headheight + \topmargin + \voffset + 1in-1.53in\relax}[0pt][0pt]{\includegraphics[height = 1.53in]{euclid-1945}}}}{\thepage}
    \setfoot{}{}{}
    }
    \pagestyle{mine}
    \setcounter{page}{121}

    \begin{document}

    \lipsum[1-16]

    \end{document} 

enter image description here

Bernard
  • 271,350