Search code examples
latexr-markdownpandoc

RMarkdown to PDF: Full Cover Page with a pre-designed picture but I also need to write text at a specific place


I want to include this image as a cover-page:

Cover Page Image

I want to include the Author details from YAML at the "Prepared By" Location.

So far, this is my setup:

---
title: "Report for `r params$name`"
author: "ABC TEAM"
date: "`r Sys.Date()`"
params:
  name: "XYZ"
output: pdf_document
header-includes:
  - \usepackage{titling}
  - \pretitle{\begin{center}
    \includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{cover_image_report.png}}
  - \posttitle{\end{center}}
---

When I knit however, this is the result:

Rendered Image

I tried removing center attribute but it throws an error. I tried to remove the tilting but it also throws up an error. So I'm literally stuck.

How do I get the full cover page with the image I have but I also write on-top of the image at a specific place?


Solution

  • You can use the pdfpages package to add a title page as a full page. It comes with the picturecommand option which allows you to add things like additional text to the page:

    \documentclass{article}
    
    \usepackage{pdfpages}
    
    \begin{document}
    
    \includepdf[page=1,picturecommand={\put(50,100){text}}]{example-image-duck}
    
    \end{document}