Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When inserting a figure into a TeX document is there an easy way to make it appear behind the text?

share|improve this question
    
Is the position dependent on the content? Have you looked at the background package? –  azetina Jan 31 at 21:21
    
Consider searching under watermark. –  Werner Jan 31 at 21:26
    
Are you referring to a single image on a particular page or do you want some image in the background of all pages? –  Gonzalo Medina Jan 31 at 21:48
    
Part a specific image needs to underlay the text on one page. –  Mike Jan 31 at 22:13
add comment

3 Answers

up vote 7 down vote accepted

You can put an image into zero width and zero height/depth box, so TeX will just runs over it. Also, you probably want to lower the figure since normally the reference point is at the bottom.

This works:

\documentclass{article}
\usepackage{graphicx,lipsum}
\pagestyle{empty}
\begin{document}
\noindent
\makebox[0pt][l]{%
  \raisebox{-\totalheight}[0pt][0pt]{%
    \includegraphics[width=4in]{book}}}%
\lipsum[1-2]


\end{document}

enter image description here

share|improve this answer
    
This looks really good, thanks. The image is opaque right? Just want to be sure this puts it in the background not on top. Could the same trick put the graphic over the foreground? –  Mike Feb 1 at 0:54
    
The image is opaque. To put it on the foreground, just typeset it after the text –  Boris Feb 1 at 2:58
add comment

You can use the background package. Initially, you use the pages=some option, so no background is initially used. Then on the page(s) in which you desire the image, you use the \BackImage command; its optional argument passes options to \includegraphics, and the mandatory argument contains the name of the image file:

\documentclass{article}
\usepackage[pages=some,scale=1,angle=0,opacity=0.7]{background}
\usepackage{graphicx}
\usepackage{lipsum}

\newcommand\BackImage[2][scale=1]{%
\BgThispage
\backgroundsetup{
  contents={\includegraphics[#1]{#2}}
  }
}

\begin{document}

\lipsum[2]
\BackImage[width=.5\textwidth]{example-image-a}% image on page 1
\lipsum[4-22]
\BackImage[width=.5\textwidth]{example-image-b}% image on page 4
\lipsum[3-4]

\end{document}

enter image description here

Using the available keys for \backgroundsetup you can easily change the attributes (opacity, position, scale, angle) of the included image.

In the case of a single image, it's enough to set contents to be the \includegraphics, pages=some and to use \BgThisPage for the page in which the image should be included.:

\documentclass{article}
\usepackage{graphicx}
\usepackage[pages=some]{background}
\usepackage{lipsum}

\backgroundsetup{
  scale=1,
  angle=0,
  opacity=0.7,
  contents={
    \includegraphics[width=\textwidth,height=4cm]{example-image-a}}
}

\begin{document}

\lipsum[1-20]
\BgThispage
\lipsum[3-4]

\end{document}
share|improve this answer
add comment

You could also do this with tikz:

\documentclass[]{article}

\usepackage{pgfpages,tikz,lipsum}

\begin{document}

\begin{tikzpicture}[remember picture, overlay]
      \node[anchor=center] at (current page.center){%
        \pgfimage{example-image-a}};
\end{tikzpicture}

\lipsum[1-10]

\end{document}

which puts the background image only on the required page:

background picture with <code>tikz</code>

Or you might prefer to use wallpaper which offers the same functionality, as well as a way to repeat the image on every page:

\documentclass[]{article}

\usepackage{wallpaper,lipsum}

\begin{document}

\lipsum[1-10]
\ThisCenterWallPaper{1}{example-image-b}
%\CenterWallPaper{1}{example-image-b}% use this instead if you want the background repeated


\end{document}

which gives:

background image on single page with <code>wallpaper</code>

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.