34

I am generating one report where I need to use background image. But I found that image always starts leaving some margin space to left side.

\documentclass{article}
\usepackage{wallpaper}
\usepackage{mdframed}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\begin{document}
 Some content
\ThisLRCornerWallPaper{1.0}{image.jpg}
\end{document} 

How can I use background image covering whole page?

  • 3
    Not having access to image.jpg I can only guess. You might try one of the images in \usepackage{mwe}. Anyway, \ThisLRCormenrWallPaper preserves the aspect ratio and will leave a margin on the left if it hits the top. To ignore the aspect ratio, use \ThisTileWallPaper{\paperwidth}{\paperheight}{image.jpg} – John Kormylo Mar 26 '14 at 3:39
59

You can do this in number of ways. I will show three more methods.

With tikz:

\documentclass{article}
\usepackage{tikz}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\begin{document}
 Some content
\tikz[remember picture,overlay] \node[opacity=0.3,inner sep=0pt] at (current page.center){\includegraphics[width=\paperwidth,height=\paperheight]{example-image}};
\clearpage
text
\end{document}

With eso-pic:

\documentclass{article}
\usepackage{eso-pic,graphicx}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\begin{document}
 Some content
\AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image}};
\clearpage
text
\end{document}

\AddToShipoutPictureBG (instead of \AddToShipoutPictureBG*) puts the background in all pages.

With background package:

\documentclass{article}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\usepackage[pages=some]{background}

\backgroundsetup{
scale=1,
color=black,
opacity=0.4,
angle=0,
contents={%
  \includegraphics[width=\paperwidth,height=\paperheight]{example-image}
  }%
}
\begin{document}
 \BgThispage
 Some content
 \clearpage
 text
\end{document}

enter image description here

  • 2
    Remark: the functionality of background is based on tikz. So, you show actually two methods. ;-) – Speravir Mar 27 '14 at 2:24
  • For those, like me, that came here looking for a solution for .Rmd, the second one works, however it will insert a ';' into the document asif it were a character, and can be removed. I'm not sure if this is a special operator that LaTeX sees and .Rmd doesn't. The geometry argument also doesn't seem to be required. – DaveRGP Jun 29 '16 at 8:45
  • What does * do at the end of \AddToShipoutPictureBG? – bkarpuz Jun 7 '17 at 21:56
  • 2
    @bkarpuz From the manual of eso-pic: "\AddToShipoutPictureBG* works like \AddToShipoutPictureBG but only for the current page. " – esdd Jun 14 '17 at 11:45
  • @DaveRGP: This ";" comes from the command, you can safely remove it. Likely just a copy & paste error – Uwe Ziegenhagen Oct 17 '17 at 5:02

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.