1

INTRODUCTION

I am trying to fill the background of a LaTeX document with an imported background image.
The background image is in .png format.

Thus far, my code rotates the image, which I do not want.
Also, the scaled-up background image which goes off the edges of the page, which I also do not want.
Ideally, the background image will fit inside of the page boundaries.

comparison of background image and output pdf

A similar question was asked before. However, that user was okay with their picture going off the edges. They wanted the smallest background image possible which still managed to cover/coat the entire page. That is, the found the smallest scaling factor possible such that both of the following conditions we satisfied:

  • the background image width was at least as wide as the page width
  • the background image height was at least as tall as the page height.

I want to find the largest background image such that the image height and width are less than the page height and width.

I am okay having a "white border" at the top/bottom, or left/right sides of the background.

SOURCE CODE

My source code is provided below:

\documentclass[12pt]{article}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{graphicx}
\usepackage{background}
\backgroundsetup{contents=\includegraphics{bkrnd.png}}

\begin{document}
The universe is immense and it seems to be homogeneous, 
in a large scale, everywhere we look at.

mood when there is a subject topic
or WH-phrase.

\end{document}

I require the the following:

  • The background image is un-tilted (not-rotated)
  • The background image fully opaque, not washed-out.
  • The background image does not go off the edges of the page.
  • The background image does not affect text-alignment.
    • Text is not in-line with the background image.
    • All of the document text appears on a layer above of the background image.

If you want it for testing purposes, I will provide bkrnd.png below:

enter image description here

1

1 Answer 1

3
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{eso-pic,adjustbox}

\AddToShipoutPictureBG{%
 \AtPageCenter{%
  \adjincludegraphics[width=\paperwidth,height=\paperheight,
    keepaspectratio,valign=M,center=0pt]{example-image-a}%
  }}


\begin{document}
The universe is immense and it seems to be homogeneous,
in a large scale, everywhere we look at.

mood when there is a subject topic
or WH-phrase.

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .