I am creating a book so my output is bookdown::pdf_book. I want the background of the last page to be an image instead of the plain white background. I just need to know how I can change the background of only one page to an image and not the entire document. I'm fine with using LaTeX code.
Hi @Amarakon,
There seems to be many ways to set backgrounds using LaTeX: graphics - How to use background image in LaTeX? - TeX - LaTeX Stack Exchange
So you just need to add some code to the preamble and then indicate which page should have a background. Note that image.jpeg
is an image in the same directory as the Rmd file.
---
title: "Untitled"
date: "`r Sys.Date()`"
output: pdf_document
header-includes:
- \usepackage[pages=some]{background}
- \backgroundsetup{scale=1,opacity=1,angle=0,contents={\includegraphics[width=\paperwidth,height=\paperheight]{image.jpeg}}}
---
# Important Section
Here is some important text.
\pagebreak
# Last Page
\BgThispage
Thank you! But I have one small issue; the image won't lose its aspect ratio in order to fill the page completely. Here is a screenshot:
https://imgur.com/RaMs4FY
I want the image to always take up the entire page even if it means losing its aspect ratio.
You can control this with the scale
argument to \backgroundsetup{}
. Larger values will stretch the image. Otherwise, with scale=1
, you need to make sure your image has the proper aspect ratio to avoid needing to stretch the image.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.