Como usar imagem de fundo no LaTeX?

Como usar imagem de fundo no LaTeX?

Estou gerando um relatório onde preciso usar imagem de fundo. Mas descobri que a imagem sempre começa deixando algum espaço de margem para o lado esquerdo.

\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} 

Como posso usar a imagem de fundo cobrindo a página inteira?

Responder1

Você pode fazer isso de várias maneiras. Vou mostrar mais três métodos.

Com 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}

Com 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(em vez de \AddToShipoutPictureBG*) coloca o plano de fundo em todas as páginas.

Com backgroundpacote:

\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}

insira a descrição da imagem aqui

Responder2

Aqui está uma solução que usa a \AddToHookmacro (relativamente) nova.

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}

\AddToHook{shipout/background}{%
    \put (0in,-\paperheight){\includegraphics[width=\paperwidth,height=\paperheight]{mybg.pdf}}%
}

\begin{document}
\lipsum[1-5]
\end{document}

(O backgroundpacote agora emite um aviso porque usa macros obsoletas.)

Responder3

Algo que descobri e procurei há algum tempo como pular uma imagem de fundo para uma página específica. Eu descobri que a melhor maneira de fazer isso é com:

\usepackage[pages=some]{background}
\backgroundsetup{
scale=0.1,
color=black,
opacity=0.1,
angle=0,
contents={%
  \includegraphics[width=\paperwidth,height=\paperheight]{Picture.png}
  }%
}

----- Page Wanting to Omit -----

Blah Blah Blah

\NoBgThispage % <------- Skips for current page
\BgThispage % <------- Starts bg again for next page

Blah Blah Blah

Espero que isso ajude alguém.

informação relacionada